PaypalExpressGateway上的Activemerchant Paypal经常性支付错误



环境:
Ruby 1.9.2
轨道3.2.8
gem‘ActiveMerchant’1.34.1

我想使用Paypal定期付款选项作为自动续订选项

为此,我使用贝宝支付选项,该选项将转到贝宝网站,允许用户登录并确认付款,然后进行处理。

正常付款(非经常性付款)可以正常工作。对于正常付款,我使用:

同类:

ActiveMerchant::Billing::Base.mode = :test
@@paypal_express_gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(
    :login => 'my_login_id@domail.com',
    :password => 'password',
    :signature => 'Signature'
)

express_checkout方法中:

setup_response = @@paypal_express_gateway.setup_purchase(@@amount,
      :ip                => request.remote_ip,
      :return_url        => url_for(:action => 'confirm', :only_path => false),
      :cancel_return_url => url_for(:action => 'new', :only_path => false)
)
redirect_to @@paypal_express_gateway.redirect_url_for(setup_response.token)

confirm方法中:

details_response = @@paypal_express_gateway.details_for(params[:token])

则CCD_ 3返回成功方法CCD_ 4或CCD_。我把它发送到完整或错误页面这就是我想要的经常性付款


对于PaypalExpressCheckout的定期付款,我使用了以下内容:

课堂上:

ActiveMerchant::Billing::Base.mode = :test
@@paypal_express_gateway = ActiveMerchant::Billing::PaypalExpressGateway.new(
    :login => 'my_login_id@domail.com',
    :password => 'password',
    :signature => 'Signature'
)

express_checkout方法中:

setup_response = @@paypal_express_gateway.setup_purchase(@@amount, <br>
    :ip                => request.remote_ip, <br>
    :return_url        => url_for(:action => 'confirm', :only_path => false),
    :cancel_return_url => url_for(:action => 'new', :only_path => false)
)
redirect_to @@paypal_express_gateway.redirect_url_for(setup_response.token)

confirm方法中:

details_response = @@paypal_express_gateway.recurring(@@amount, "", options = {
    :token => params[:token],
    :period => "Month",
    :frequency => 3,
    :start_date => Time.now,
    :description => "Checking recurring auto-renewal"
})

现在我得到错误undefined method "add_credit_card" for #<ActiveMerchant::Billing::PaypalExpressGateway:0x00000006c831a0>

此处定义了重复方法(活动商户),该方法将返回profile_id

所以我想使用PaypalExpressGateway(而不是PaypalGateway)进行经常性支付,因为开发者无法将信用卡详细信息发送到经常性方法,因为支付是在Paypal网站上完成的

那么为什么在PaypalExpressGateway的情况下使用credit_card参数。recurring方法调用的方法"build_create_profile_request(options)"不应检查credit_card,因为我没有在选项中传递任何参数"credit_card'"。(参见给定链接中的127行)

请检查代码,让我知道我错在哪里。如果有人能为我提供准备好的代码,那么它会更有用。

我尝试了很多博客和解决方案,但都没有成功。请尽快给我解决方案。

我使用ActiveMerchant进行定期PayPal支付。您需要将nil而不是空字符串作为第二个参数(这是一种表示信用卡对象的对象,但我不认为它是为ActiveMerchant的PayPal Express Checkout集成实现的)传递给recurring方法。

details_response = @@paypal_express_gateway.recurring(@@amount, nil, { 
  :token => params[:token], 
  :period => "Month", 
  :frequency => 3, 
  :start_date => Time.now, 
  :description => "Checking recurring auto-renewal" 
}) 

最新更新