Paypal IPN on Rails应用程序未被调用



我们使用Paypal自适应链式支付来允许在众筹网站上捐款。我已经做好了一切工作,直到付款,并在成功付款后返回到"return_url"(在沙盒中)。

关于在沙盒中测试IPN的Paypal文档很少。也许我在某个地方错过了启用IPN回调的设置?

我希望能够使用IPN回调来验证成功付款。我希望看到回调JSON,这样我就知道要捕获和比较哪个字段。我找到了示例代码,但IPN回调似乎没有在Sandbox中调用。我试过这样输出params(也没有调用put语句):

****backers_controller.rb
class BackersController < ApplicationController    
include ActiveMerchant::Billing::Integrations
  def callback_ipn
    puts "callback: ipn"
    notify = PaypalAdaptivePayment::Notification.new(request.raw_post)
    puts notify.to_yaml
  end
  def callback_return
    puts "callback: return"
    @backer = Backer.find(params[:id])
    @reward = @project.rewards.find_by_id(@backer.reward_id)
    @backer.callback
    respond_to do |format|
      format.html { render :layout => 'application_proj_back_blog' }
      format.json { render json: @backer }
    end
  end

("callback_return"操作正在工作)

****backer.rb
class Backer < ActiveRecord::Base
  include ActionDispatch::Routing::UrlFor
  include Rails.application.routes.url_helpers
def purchase
  project = Project.find(self.project_id)
  default_url_options[:host] = 'localhost:3000'
  proj_owner_email = User.find(project.user_id).email
  recipients = [{:email => PRIMARY_EMAIL,
               :amount => total_pledge,
               :primary => true},
              {:email => project.paypal_email,
               :amount => project_owner_cut,
               :primary => false}
  ]
  response = GATEWAY.setup_purchase(
    :action_type => "PAY_PRIMARY",
    :return_url => callback_return_project_backer_url(project, self),
    :cancel_url => callback_cancel_project_backer_url(project, self),
    :ipn_notification_url => callback_ipn_project_backer_url(project, self),
    :currency_code =>"USD",
    :receiver_list => recipients
  )
  puts response.to_yaml
  pay_key = response["payKey"]
  pledge_transactions.create!(:action => "purchase", :amount => total_pledge, :response => response)
  return response["payKey"]
end

回到backers_controller.rb,"def购买"调用购买:

****backers_controller.rb
class BackersController < ApplicationController
  def purchase
    @backer = Backer.find(params[:id])
    @backer.purchase
    redirect_to (GATEWAY.redirect_url_for(@backer.purchase))
  end

原来我的身份验证阻止了paypal调用我的ipn侦听器。

相关内容

  • 没有找到相关文章

最新更新