user2268247
user2268247

Reputation: 33

braintree - creating subscription with expired credit card not resulting in error

I am trying to test out subscriptions using Braintree and PHP. I am able to post transactions successfully, but I am running into this issue with subscriptions.

Here are my steps:
1. Create customer with the credit card attached
2. Create subscription for the customer

Problem:
Step 1 or 2 both result in success even though the credit card I provided has an expiration date of Jan 2013.

I have followed the tutorial given on Braintree, with no luck or documentation help. Any ideas?

Thanks.

Upvotes: 3

Views: 6345

Answers (1)

agf
agf

Reputation: 176780

I work at Braintree. Feel free to contact our support team if you need more detailed help.

We don't check expiration date in our Sandbox environment. If we did, and you hardcoded an expiration date in your tests, they could fail after that date had passed.

Instead, you use an amount equal to the desired processor response code to simulate failures:

Test Amounts for Unsuccessful Transactions

When working with transactions, you can pass specific amounts to simulate different responses from the gateway.

  • Amounts between $0.01 - $1999.99 will simulate a successful authorization
  • Amounts between $2000.00 - $2060.99 and $3000.00 - $3000.99 will decline with the > - coordinating Processor Response
  • Amounts between $2061.00 - $2999.99 will simulate the generic decline message “Processor Declined.”
  • Amounts $3001.00 and greater will also simulate a successful authorization

An expired card is processor response code 2004:

Code    Text
2000    Do Not Honor
2001    Insufficient Funds
2002    Limit Exceeded
2003    Cardholder's Activity Limit Exceeded
2004    Expired Card

So setting the amount of your subscription to $2004.00 will cause it to fail as if the card were expired, regardless of the expiration date you use.

This way, you can write your tests once, and have them keep working even after any expiration dates have passed.

Upvotes: 11

Related Questions