【发布时间】:2011-11-18 12:25:13
【问题描述】:
我正在使用 activemerchant 实施 paypal 直接付款 以下是代码
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详细信息仍然没有运气。 不明白怎么回事?
【问题讨论】:
-
尝试:卡类型:Visa卡号:4929929650119738 CVV2:891 到期:05/2015(注意加载0)
-
@pravin 你有解决方案吗?
标签: ruby-on-rails ruby-on-rails-3 paypal activemerchant