尝试使沙盒贝宝与Rails一起工作时出错? [英] error trying to make sandbox paypal to work with rails?
问题描述
我在将Paypal付款网关与Rails集成时遇到问题.我将在下面解释我的步骤.
I am having problems integrating paypal payment gateway with rails. I will explain below the steps i did.
我首先去了 developer.paypal.com
我创建了两个沙箱帐户,一个用于买方,一个用于商业帐户.
I created two sandbox accounts one for buyer and one for business account.
我已将企业帐户更改为Business-Pro
I changed business account to Business-Pro
然后我将活跃商人的宝石安装在导轨中.
I then installed activemerchant gem in rails.
在config/environments/development.rb文件中,我粘贴了以下代码块
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!