简体   繁体   English

PaypalExpressGateway上的Activemerchant Paypal重复付款错误

[英]Activemerchant Paypal Recurring Payment Error on PaypalExpressGateway

Environment: 环境:
Ruby 1.9.2 Ruby 1.9.2
Rails 3.2.8 Rails 3.2.8
gem 'ActiveMerchant' 1.34.1 gem'ActiveMerchant'1.34.1

I want to use Paypal recurring payment option for auto-renewal option. 我想使用Paypal定期付款选项进行自动续订选项。

For this, I am using Paypal payment option which goes to paypal website for allowing user to login and confirm payment and then process. 为此,我使用Paypal支付选项进入paypal网站,允许用户登录并确认付款然后处理。

It is working fine for normal payment (not recurring payment). 它适用于正常付款(不是经常性付款)。 For normal payment, I used: 对于正常付款,我用过:

In Class: 在班上:

ActiveMerchant::Billing::Base.mode = :test

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

In express_checkout method: 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)

In confirm method: confirm方法中:

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

Then details_response returns with success method true or false . 然后details_response以成功方法truefalse返回。 And I send it to complete or error page. 我发送它到完成或错误页面。 That is I want in recurring payment . 这是我想要定期付款


For recurring payment with PaypalExpressCheckout, I used following: 对于使用PaypalExpressCheckout定期付款,我使用了以下内容:

In class: 在班上:

ActiveMerchant::Billing::Base.mode = :test

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

In express_checkout method: 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)

In confirm method: 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"
})

Now I am getting error undefined method "add_credit_card" for #<ActiveMerchant::Billing::PaypalExpressGateway:0x00000006c831a0> 现在我收到错误undefined method "add_credit_card" for #<ActiveMerchant::Billing::PaypalExpressGateway:0x00000006c831a0>

The recurring method is defined Here (Active Merchant) which will return profile_id . 此处定义的重复方法(活跃商家)将返回profile_id

So I want to use PaypalExpressGateway (not PaypalGateway) for recurring payment where developer can't send credit_card details to recurring method as Payment is done on Paypal website. 因此,我想使用PaypalExpressGateway(而不是PaypalGateway)进行定期付款,开发人员无法在Paypal网站上完成付款时将信用卡详细信息发送到重复方法。

Then why is credit_card parameter being used in case of PaypalExpressGateway. 那么为什么在PaypalExpressGateway的情况下使用credit_card参数。 And method " build_create_profile_request(options) " called by recurring method should not check for credit_card as I am not passing any parameter 'credit_card' in options.(see line no 127 in given link ) 并且通过recurring方法调用的方法“ build_create_profile_request(options) ”不应该检查credit_card,因为我没有在选项中传递任何参数'credit_card'。(参见给定链接中的第 127行)

Please check code and let me know where I am wrong. 请检查代码,让我知道我错在哪里。 If anyone can provide me prepared code, then it will be more useful. 如果有人能为我提供准备好的代码,那么它会更有用。

I tried many blogs and solutions but not succeed. 我尝试了很多博客和解决方案但没有成功。 Please give me solution for this ASAP. 请尽快给我解决方案。

I have recurring PayPal payments working using ActiveMerchant. 我使用ActiveMerchant重复支付PayPal付款。 You need to pass nil rather than an empty string as the second parameter (which is some kind of object representing a credit card object but I don't think is implemented for ActiveMerchant's PayPal Express Checkout integration) to the recurring method. 您需要传递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" 
}) 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM