Is there a way to test your application's p开发者_Python百科rocessing 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!
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"
}
精彩评论