Activemerchant Paypal Recurring payment error on PaypalExpressGateway

Environment: -
Ruby 1.9.2
Rails 3.2.8
gem 'ActiveMerchant' 1.34.1

I want to use the Paypal option for re-payment for automatic updates.

To do this, I use the Paypal payment option that goes to the PayPal website, allowing the user to log in and confirm the payment, and then process it.

It works fine for regular payment (non-recurring payment). For regular 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 the 'express_checkout' method: -

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' mode: -

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

Details_response then returns with a successful method of true or false. And send it to the completion or error page. This is what I want when paying again .


When paying again using PaypalExpressCheckout, I used the following: -

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 the 'express_checkout' method: -

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' mode: -

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

Now I get the undefined method "add_credit_card" for #<ActiveMerchant::Billing::PaypalExpressGateway:0x00000006c831a0> error undefined method "add_credit_card" for #<ActiveMerchant::Billing::PaypalExpressGateway:0x00000006c831a0>

The repeating method is defined here (active merchant) , which will return profile_id .

So, I want to use PaypalExpressGateway (not PaypalGateway) for periodic payments, when the developer cannot send credit card information again, because payment is made on the Paypal website.

Then why is the * credit_card * parameter used in the case of PaypalExpressGateway. And the method " build_create_profile_request (options) ", called by the recurring method, should not check for credit_card, since I do not pass any parameter "credit_card" in the parameters. (See Line No. 127 in this link )

Please check the code and let me know where I am going wrong. If someone can provide me with prepared code, then it will be more useful.

I tried many blogs and solutions, but could not. Please give me a solution for this as soon as possible.

Thanks for the advanced.

+4
source share
1 answer

I have PayPal recurring payments working using ActiveMerchant. You need to pass nil , not an empty string, as the second parameter (which is some kind of object representing a credit card object, but I don’t think it is implemented to integrate ActiveMerchant PayPal Express Checkout) into the recurring method.

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

Source: https://habr.com/ru/post/1492261/


All Articles