ruby-on-rails - 如何正确设置 Active Paypal Adaptive Payment IPN Notifications?

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

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

最佳答案

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

对于严格的 IPN,这是我的工作 Controller 的样子:

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的网址是www.yourwebsite.com/pay/paypal

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

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

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

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

关于ruby-on-rails - 如何正确设置 Active Paypal Adaptive Payment IPN Notifications?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11554524/

相关文章:

css - Font Awesome 图标对齐

ruby - 使用 Ruby 从键盘读取

php - Paypal (PHP) : unable to use client certificate (no key found or wrong pass phrase? )

ruby - Logstash 5 ruby 过滤器

javascript - 使用 ERB 在 Javascript 中设置 CSS backgroundImage 路径

php - Paypal 按钮 : How to return a specified value when a payment is successful?

paypal - 页面保护

javascript - 为什么我的 Rails 资源管道中的 js 文件没有被编译?

css - Bootstrap Rails,为内容索引添加分页

ruby-on-rails - 重新加载模块/类后仍定义 Ruby 方法