简体   繁体   English

如何正确设置活动贝宝自适应支付IPN通知?

[英]How to set up Active Paypal Adaptive Payment IPN Notifications correctly?

I've been having trouble setting up the IPN Notification on my app to get all the information send back to my application. 我一直无法在我的应用程序上设置IPN通知,以便将所有信息发送回我的应用程序。 My payment is working properly and is functional. 我的付款工作正常并且可以正常使用。 I am having trouble with the notify_action. 我在使用notify_action时遇到麻烦。 I would like to retrieve the information of the payment and send it back to my app to get all the informations from the payment. 我想检索付款信息并将其发送回我的应用程序,以从付款中获取所有信息。

 def checkout
  ....
  response = @gateway.setup_purchase(
     :return_url => "http://localhost:3000",
     :cancel_url => "http://localhost:3000",
     :ipn_notification_url => orders_notify_action_url,
     :receiver_list => recipients
     )
  ..
  redirect_to (@gateway.redirect_url_for(response["payKey"]))
 end

 def notify_action
     notify =  ActiveMerchant::Billing::Integrations::PaypalAdaptivePayment::Notification.new(request.raw_post)
    p "Notification object is #{notify}"
    if notify.acknowledge
      p "Transaction ID is #{notify.transaction_id}"
      p "Notification object is #{notify}"
      p "Notification status is #{notify.status}"
    end
    render :nothing => true
end

https://gist.github.com/8acceeee72fe12312c09 https://gist.github.com/8acceeee72fe12312c09

It would help a lot if you specified what problem you're having. 如果您指定自己遇到的问题,将会很有帮助。 For example, is the problem that notify_action is not being hit by Paypal's IPN? 例如,是否不是Paypal的IPN击中notify_action的问题? Or is notify.acknowledge returning false? 还是notify.acknowledge返回false?

For strictly IPN this is what my working controller looks like: 对于严格的IPN,这是我的工作控制器的外观:

class PayController < ApplicationController
    include ActiveMerchant::Billing::Integrations   

    def paypal
        notify = Paypal::Notification.new(request.raw_post)
        logger.debug "Notification object is #{notify}"
        if notify.acknowledge
            logger.debug "Transaction ID is #{notify.transaction_id}"
            logger.debug "Notification object is #{notify}"
            logger.debug "Notification status is #{notify.status}"
        end        
        render :nothing => true
    end
end

Then the URL I gave to Paypal is www.yourwebsite.com/pay/paypal 然后,我给贝宝的URL是www.yourwebsite.com/pay/paypal

Then simply match the route in route.rb 然后只需匹配route.rb中的路由

match 'pay/paypal' => 'pay#paypal'

The notify object should contain all the data for the given purchase. 通知对象应包含给定购买的所有数据。

Important: Watch the log file to see if the function is ever getting called, and if so, what is being printed? 要点:查看日志文件以查看是否曾经调用过该函数,如果是,则正在打印什么?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM