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.