0

我在我的应用程序上设置 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

4

1 回答 1

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'

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

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

于 2012-07-26T14:34:24.703 回答