I have setup a PHP script on a cron which contacts Braintree via the API to look up the status of each subscription that we have on file. We then update our local records based on the customer's subscription status. Because I can manually cancel a subscription from the Braintree control panel, I have been able to test that my script can detect canceled subscriptions.
However, I can't find any way to test a past-due status other than to wait for the billing cycle to go 'round. Because the minimum length of a billing cycle in Braintree is one month, this makes debugging my script very difficult.
I know that in theory I should just see a different string for the status of the subscription, but I'm looking for a reproducible way to simulate past-due status, along with a positive balance and value for daysPastDue.
Can anyone help?
$BT_subscription = Braintree_Subscription::find($BT_subscription_id);
if ($BT_subscription && $BT_subscription instanceof Braintree_Subscription) {
if ($BT_subscription->status == 'Past Due' && $BT_subscription->balance > 0) {
// ...
I got the following reply from Braintree support about this issue:
Because our sandbox environment is meant to replicate our production environment there is no way to force a subscription to past due. However here is a little work around that might make this testing easier:
To put a subscription in the Past Due status in the Sandbox, you can create a subscription with a trial period of one day and a price of $2000. Then, when the one day trial expires, it will trigger a transaction create that will fail because of the dollar amount.
The $2000 price tag is likely for the Test Amounts for Unsuccessful Transactions to trigger the credit card payment to fail. I have setup a test, and will edit this if the test proves unsuccessful.
Adding on to Tyler V's response, and this is still the only way to test it, unfortunately.
From support:
Thanks for reaching out, and appreciate your patience. Using a sandbox account, the shortest amount of time you can simulate a result will be 1 day. Use the following example to create a Past Due status:
Create a plan with a 1 day trial and $2000 price Create a customer with a credit card Create a new subscription using the plan and customer The first charge attempt will be after 1 day (when the trial expires) and will fail The automatic retries will be at +10 and +20 days of the subscription going past due Please see the following page for Sandbox test values. I would recommend that the you create a LOT of these at one time so you have multiples to work with; otherwise you’ll have to wait a day for each new one they create to move into past due.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With