views:

171

answers:

1

Hello,

Is there a way to test your application's processing and handling of Paypal generated credit card errors? I'd like to verify that my application can handle a declined credit card or something like that.

So is there a way to have Paypal send an error message? Or would it be better to generate a stub and use it in the testing environment? If this is the better way, how would one generate a stub?

Thanks!

A: 

Yes! You can test by setting:

ActiveMerchant::Billing::Base.mode = :test

PayPal however will require you to enter complete billing information or the API won't even accept it and will return:

Error: There's an error with this transaction. Please enter a complete billing address.

In which case you can supply it with some generic info:

:billing_address => {
    :name     => "Test Guy",
    :address1 => "123 W 423 E",
    :city     => "Somewhere",
    :state    => "CA",
    :country  => "US",
    :zip      => "88888"
 }
Joseph Silvashy