Dashboard Stripe - Subscription Feature
Environment test: Test all status and automatic paiement workflow of the subscription services
Why / Which context
The subscription feature allows automatic recurring payment for one booking.
Payments are automatic in production, but in environment tests, it will take a few days to complete a workflow. It is the reason why we implemented a Stripe tool to handle delays and fake dates.
Steps to reproduce
During this process, you will switch between the Stripe dashboard and your platform.
1. Login into your Stripe dashboard
Log in to your Stripe account: https://dashboard.stripe.com
Once you are connected, switch to Test mode thanks to the button (figure 1) at the top right corner of your Stripe dashboard.
2. Make a booking on your platform
Go on your platform and log in as an asker, then create a booking request.
Learn more about the process of booking requests here: Booking confirmation pages (Subscription)
Once you are on the checkout booking page, please take the ID checkout number in the URL (figure 2).
3. Create a new simulation on the Stripe dashboard
Path: Stripe dashboard > Test mode> Payments > Subscription > Test clock
Click on “test clocks” (figure 3), and you will be redirected to the subscription test environment of the Stripe dashboard.
Click on the button “New simulation” (figure 4), and a modal will appear (figure 5).
You will have to fill the field (figure 5) “Nom de la simulation” as follow: Subscription#IDcheckout and click on the button “Créer”
Please respect the naming convention: Subscription#12345678910 otherwise the test clock will not work. This is sensitive data.
Go back to the Checkout page and proceed to the payment. Once the payment is done, you should see “Client” (figure 6) on the new subscription page created on the Stripe dashboard
Tips: If you do not see the client appear that means your Stripe webhook is incorrectly configured, to do so you can go in the SBO > Others > Commands > run the command: Dashboard Stripe - Inter-user subscription bundle - Commands
4. Accept the subscription request and enable payments
Once the payment has been made by the asker, the offeror can accept the subscription.
Learn more about the process of booking management here:
Then on the Stripe dashboard, you should proceed to the payin.
By default, the Payin is done x days before the start date of the subscription period. This is set with the following configuration: subscription_automatic.
To test it quicker you can force the payin. In the Stripe dashboard, go on the subscription that matches your booking and click on Subscription (figure 7).
In the Invoice section, click on the label “brouillon” or draft, (figure 8 ) it will send you to the invoices menu of the Stripe dashboard.
Then click on the “charging the customer” (figure 9) button
The status of the subscription period will be Paid.
5. Test the active period
Go in the SBO and fill the arguments in the command subscription.status
Arguments: --test --id=1868442188 --clock=P1Y1MT1H1M
The same process to enable the payout: the command cocorico:subscription:validate.
Arguments: --test --delay-weekly=-P1M
No space between the = and the Clock naming convention
Do not forget the - before the period
Period
Clock naming convention
One minute
T1M
One hour
T1H
One month
P1M
One year
P1Y
6. Test the next subscription period
To finish the complete workflow you should test the next period.
Once the period T is active it will create the next subscription period is pending.
You can go on the Stripe dashboard and charge the customer for the new next period. For the subscription, you want to test you will see a new draft payment. Same as before, you can click on this label and charge the customer.
The payment will have the paid status. Then you can reproduce point 5. test the active period.
The expected behavior is:
The current subscription period is done
The next subscription period is active
The payout is available
You can reproduce steps 5 and 6 as many as you want in order to test several subscription period.
7. Test a payment failure
In some cases, a subscription payment may not be approved. If this happens, it's important to update the payment method to a valid one. To test this scenario, we need to access the draft invoice in Stripe Dashboard (Test mode > Billing) before the next billing cycle begins.
Click and open the invoice and attempt a new payment method by pressing the button "Charge Customer". Add a "Decline after attaching Stripe card" (4000000000000341). To complete the process, we need to check the following message displayed in Stripe:
Return to the asker account and refresh the page. A button "Update card details" should be displayed.
Commands
second:stripe:webhook
This command allows you to configure the Stripe webhook dashboard. Before a day of test please run this command
No arguments
second:subscription:expire
Simulate a subscription request that has not been accepted or declined
No arguments
second:subscription:status
Simulate the day of the platform to test payin and status
Args: --test --id=1868442188 --clock=P1M
second:subscription:validate
Simulate the day of the platform to test payout and status and enable another subscription period
Args: --test --delay-weekly=-P1M
Reminder
No space between the = and the Clock naming convention
Do not forget the - before the period
Period
Clock naming convention
One minute
T1M
One hour
T1H
One month
P1M
One year
P1Y
Status
Subscription period
Workflow
The subscription period workflow for a Accepted susbcription request is:
Pending > Accepted > Paid > Active > Done
Status
Pending: the next period, it is waiting for subscription acceptance or for payment
Canceled: the next period was canceled by the asker
Declined: the subscription request was canceled by the offerer
PaymentError: the next period has a payment issue
Paid: the next period was paid successfully but the period didn’t start yet (payment attempt delay)
Active: the next period becomes active when the period starts (new cron command required)
Done: the current period becomes done when the period ends (new cron command required)
Canceled: the current period is paid or pending, and the active period (if any) becomes Done when the period ends.
Subscription status
Pending: the subscription request is waiting for the offerer acceptation
Canceled: the subscription request was canceled by the asker
Declined: the subscription request was canceled by the offerer
Accepted: the subscription request was accepted by the offerer
PaymentError: the next subscription period has a payment issue
Paid: the first period was paid successfully but the period didn’t start yet (payment attempt delay)
Active: the next period starts and it’s paid (new cron command required)
Canceled: the next period was canceled and ( there is no current paid period or the current paid period ends ) (new cron command required)
Last updated
Was this helpful?