You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在PayPal JavaScript SDK中配置notify_url以实现即时付款通知(IPN)

PayPal JavaScript SDK 配置 IPN 指南

Hey there! I get you—moving from the classic PayPal button form to the JS SDK can feel like missing some familiar parameters, like notify_url. Let's break down exactly how to handle IPN with the JS SDK, and whether just setting it in your PayPal account backend works.

1. How to Configure IPN in the PayPal JavaScript SDK

First off, the notify_url parameter is specific to PayPal's older NVP/SOAP API (the one your classic form used). The JS SDK is built on PayPal's modern REST Orders API, which doesn't expose this parameter directly in the frontend code. But don't worry—you have two solid options:

Option 1: Global IPN Setup (PayPal Account Backend)

This is the simplest approach if all your transactions should send IPNs to the same URL:

  • Log into your PayPal merchant account, head to Settings > Instant Payment Notifications (IPN).
  • Enable IPN and enter your ipn.php URL (same one you used in your form: <?php echo $HTTP_DIR."method/paypal/ipn.php"; ?>).
  • Once saved, every transaction processed via the JS SDK (or any other method linked to your account) will automatically send an IPN to this URL.

Option 2: Per-Order IPN URL (Backend API Call)

If you need different IPN URLs for specific orders, you can specify the notify_url when creating the order via PayPal's REST API (this happens in your backend code, not the frontend JS):

  • When you call PayPal's v2/checkout/orders endpoint to create an order, add the notify_url inside the application_context object.
  • Example JSON request body (for a PHP backend):
    {
      "intent": "CAPTURE",
      "purchase_units": [
        {
          "amount": {
            "currency_code": "USD",
            "value": "10.00"
          }
        }
      ],
      "application_context": {
        "notify_url": "https://your-domain.com/method/paypal/ipn.php"
      }
    }
    
  • This per-order URL takes priority over your global account setting, so only this order's IPN will go to the specified address.

2. Does Just Setting IPN in the PayPal Account Backend Work?

Absolutely! If you don't need per-order custom URLs, the global backend setup is all you need. Every payment completed through the JS SDK will trigger an IPN to your configured ipn.php address—no extra code changes required.

Just remember to keep validating the IPN requests in your ipn.php script, same as you did before. You must send the received POST data back to PayPal's verification endpoint to confirm it's a legitimate request (never trust unvalidated IPN data!).

Quick Note: IPN vs Webhooks

While IPN works perfectly with the JS SDK, PayPal recommends using Webhooks for new projects. Webhooks are the REST API's native notification system, support more event types, and integrate more smoothly with modern workflows. But if you already have a robust ipn.php setup, there's no need to switch—IPN will continue to function reliably.

内容的提问来源于stack exchange,提问作者Gunnarius

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.04.28 11:57:45