我正在使用 activemerchant 实施贝宝直接付款以下是代码
def credit_card_details
credit_card = ActiveMerchant::Billing::CreditCard.new(
:first_name => 'Bob',
:last_name => 'Bobsen',
:number => '4242424242424242',
:month => '8',
:year => '2012',
:verification_value => '123')
errors.add(:expire_year, "Credit card expired") if credit_card.expired?
errors.add(:cc_number, "invalid credit card details") unless credit_card.valid?
if credit_card.valid?
# Capture $10 from the credit card
amount = 1000
response = PAYPAL_GATEWAY.purchase(amount, credit_card)
if response.success?
puts "Successfully charged $#{sprintf("%.2f", amount / 100)} to the credit card #{credit_card.display_number}"
else
raise StandardError, response.inspect
end
end
end
我正在尝试使用其他信用卡详细信息,但它导致“A 字段比服务器允许的长或短”这个错误。所以我用active_merchants github页面中指定的替换了cc详细信息仍然没有运气。我不明白出了什么问题?