I am having problems integrating paypal payment gateway with rails. I will explain below the steps i did.
I first went to developer.paypal.com
I created two sandbox accounts one for buyer and one for business account.
I changed business account to Business-Pro
I then installed activemerchant gem in rails.
In config/environments/development.rb i pasted the following chunk
config.after_initialize do
ActiveMerchant::Billing::Base.mode = :test
paypal_options = {
login: "aGthYkgkYXVA_api1.gmail.com",
password: "DH2RB21WR2EWNSTM",
signature: "ApBHX2qbpxJW-Ll3oP22LSao0WeuAT.A.uNyDDqIArQeMLYzMTqsZnCW"
}
::GATEWAY = ActiveMerchant::Billing::PaypalGateway.new(paypal_options)
end
Then in controller i created a test method and pasted code to do checkout
# ActiveMerchant accepts all amounts as Integer values in cents
amount = 1000 # $10.00
# The card verification value is also known as CVV2, CVC2, or CID
credit_card = ActiveMerchant::Billing::CreditCard.new(
:brand => 'visa',
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '4132033791119477',
:month => 3,
:year => 2022,
:verification_value => '123')
# Validating the card automatically detects the card type
if credit_card.validate.empty?
# Capture $10 from the credit card
response = GATEWAY.purchase(amount, credit_card, :ip => '128.1.1.1')
if response.success?
puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
else
raise StandardError, response.message
end
end
when i execute the controller method i get the following error
This transaction cannot be processed. The merchant's account is not
able to process transactions.
I am wondering the reason for this error.
I used credit card number and exp date from the buyer sandbox account i created above.
I appreciate any help!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…