5 Dec 2011, 1:10pm
/dev/rails
by

leave a comment

ActiveMerchant, Bogus Gateways, and Credit Cards

When working with ActiveMerchant‘s BogusGateway, it wants very explicit credit card numbers for testing. But it doesn’t really want numbers, it wants strings.

If you’re seeing this error, as I was:

Bogus Gateway: Use CreditCard number 1 for success, 2 for exception and anything else for error

make sure that your 1 and 2 are not integers but rather are strings.

When you create your credit card instance, I highly recommend casting the number explicitly:

ActiveMerchant::Billing::CreditCard.new( :number => number.to_s, :verification_value => security_code.to_s