Skip to content
Advertisement

How to simulate Past-Due status on Subscription

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) {
        // ...

Advertisement

Answer

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.

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement