问题
I want to add some unit tests for our billing system which is using braintree but I don't know how to change the subscription period from 1 month (minimum in braintree for now) to 1 day. I cannot wait 1 month to execute my test. is there any solution to do that?
回答1:
I recently asked Braintree support a similar question and here is the advice I was given:-
The sandbox environment is setup to mimic the production environment exactly. Unfortunately, this leaves us at the mercy of real time as well. However you can definitely test the subscription_charged_unsuccessfully and subscription_went_past_due webhooks in the sandbox by creating a past due subscription using the steps below:
Create a plan with a 1 day trial and $2000 price (a test amount that will automatically simulate a decline) 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 – this timeline can be changed by updating the recurring billing retry logic in your Control Panel You could also test the subscription_charged_successfully webhook using the same basic principles – simply create a plan with a 1 day trial and a price less than $2000.
I hope that helps.
回答2:
I work at Braintree. Feel free to reach out to support@braintreepayments.com with any further questions.
You can't modify the subscription billing period to shorter then a month. Sandbox is designed to mimic production for end-to-end testing and since Braintree doesn't offer subscription billing in smaller increments then a month we have decided to not offer a shorter billing period in sandbox.
来源:https://stackoverflow.com/questions/28430001/how-can-i-change-subscription-period-on-braintree