如何在本地主机上的 PayPal 中获取 IPN 通知

How to get IPN notification in PayPal on localhost

我在 PayPal 中使用自适应支付。 我正在关注 https://github.com/paypal/adaptivepayments-sdk-ruby。 一切正常,除了我无法在本地接收 IPN 通知。

 @api = PayPal::SDK::AdaptivePayments.new
    @pay = @api.build_pay({
                              :actionType => "PAY",
                              :cancelUrl => "http://"+Rails.application.config.app_name+"/admin/dashboard",
                              :currencyCode => "USD",
                              :feesPayer => "SENDER",
                              :ipnNotificationUrl => "http://"+Rails.application.config.app_name+"/admin/receive_notification",
                              :receiverList => {
                                  :receiver => [{
                                                    :amount => amount,
                                                    :email => @paypal_id }] },
                              :returnUrl => "http://"+Rails.application.config.app_name+"/admin/dashboard" })

那么,如何在本地主机上接收通知

Paypal 将无法路由到本地主机以发送 IPN。您需要设置一个公开可用的域名和适当的 dns。

Localhost 始终特定于您的机器,您可以使用 dynamicdns,但它需要在您的机器和网络上进行网络更改。