2012-07-19 83 views
0

我一直在设置我的应用程序的IPN通知时遇到问题,以便将所有信息 发送回我的应用程序。我的付款工作正常并且功能正常。我遇到了notify_action的问题。我想检索付款信息并将其发送回我的应用程序以获取付款中的所有信息。如何正确设置主动PayPal自适应支付IPN通知?

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

回答

1

如果你指定你遇到什么问题,这将有很大的帮助。例如,是否没有通过Paypal的IPN击中notify_action的问题?或者是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 

然后我给贝宝的网址是www.yourwebsite.com/pay/paypal

然后只需匹配的路由route.rb

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

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

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