【问题标题】:How to set up Active Paypal Adaptive Payment IPN Notifications correctly?如何正确设置 Active Paypal 自适应支付 IPN 通知?
【发布时间】:2012-07-18 06:21:20
【问题描述】:

在我的应用上设置 IPN 通知以获取所有信息时遇到问题 发回我的申请。我的付款工作正常且功能正常。我在使用 notify_action 时遇到问题。我想检索付款信息并将其发送回我的应用程序以获取付款的所有信息。

 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

【问题讨论】:

    标签: ruby-on-rails ruby paypal paypal-ipn


    【解决方案1】:

    如果您指定您遇到的问题,这会很有帮助。比如notify_action没有被Paypal的IPN命中的问题?还是 notify.acknowledge 返回 false?

    对于严格的 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
    

    那么我给 Paypal 的 URL 是 www.yourwebsite.com/pay/paypal

    然后简单匹配route.rb中的路由

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

    通知对象应包含给定购买的所有数据。

    重要提示:查看日志文件以查看函数是否被调用,如果是,打印的内容是什么?

    【讨论】:

      猜你喜欢
      • 2014-06-23
      • 2012-05-05
      • 2013-03-20
      • 1970-01-01
      • 2012-04-22
      • 2012-06-10
      • 2016-02-10
      • 2016-07-22
      • 2011-08-27
      相关资源
      最近更新 更多