Test your integration with Stripe test clocks

Ultimate Member Stripe extension integrates the stripe checkout page, and customer billing features, allowing users to pay, subscribe, and manage plans. Once you set up this extension, you must test its integrity.

Before testing your integration, make sure you've read and set the required details in the following documentation before you proceed:

Note: Use the Stripe CLI to simulate Stripe events in your local environment. You must add the parameter /?umm-stripe-webhook=true in the localhost URL e.g. http://localhost:4242/?umm-stripe-webhook=true as your local webhook URL.

To learn more about the Stripe CLI, please see this doc article: https://docs.ultimatemember.com/article/1864-stripe-cli-integration

The Stripe Test Clocks is one of the easiest way to test your Billing integration. It helps to simulate test cases of your billing resources like subscriptions. With the Stripe test clock, you can advance the time in test mode to avoid waiting for a few days, weeks, or even a year to check and test the integration of your billings. For more details about Stripe test clocks and how to use them, you can go to this link: https://stripe.com/docs/billing/testing/test-clocks

To see if the integration is working we suggest you create roles in  wp-admin> Ultimate Member> User Roles so you can set in wp-admin>Ultimate Member> Stripe Plans> Edit a plan and see what happens when a subscription is active, unpaid, paused, past due, canceled or trialing.

Testing Integration with Stripe Test Clocks

To effectively test your integration with Stripe Test Clocks, follow the steps outlined below:

1. Setup Test Environment

2. Create a Test Clock

  • Go to the 'Billing' tab and click on the 'Quick actions' button.
  • Click on the 'Create simulation'
  • It will redirect you to the Subscription page > Test Clocks tab. Click the  '+New simulation' button.
  • Set a simulation name and the starting date and time of your simulation. Then click on the 'Create' button, you may be presented with a security check when you click the button.
  • Once created, copy the Test Clock ID in the upper right corner.

3. Configure Ultimate Member Settings

  • Go to wp-admin>Ultimate Member> Settings> Extension>Stripe
  • Enable Sandbox/Test Mode setting.
  • Enable the Test Clock and paste the Test Clock ID in the field.  This will create a Stripe customer for the Test clock
  • Click the 'Save Changes' button

4. Setup your Testing Simulation

  • Create a user in wp-admin > Users. After creating the user, you can verify that the user is in Test Clock mode in the Subscription status.
  • Go back to the Stripe Dashboard > Subscription > Test clocks. Choose the test clocks simulation you created earlier by clicking on it.

  • Find the customer or user you created in wp-admin > Users in the Clock Objects section. Confirm and ensure that the customer email matches the one registered on your site.

    Note: When creating a customer in wp-admin>Users, the customer will only appear in test clocks if the Test Clocks option is enabled and the test clock ID is entered in wp-admin>Ultimate Member>Settings>Extensions>Stripe. Therefore, it is important to enable these settings before creating a user.

5. Execute Test Cases

Before you proceed with this test, please ensure you have read How to use test clocks

  • Trial & Subscription
    • Follow the steps above on how to create a customer then login to your site in another browser using the logins of the customer you've created.
    • Then go to the page where you added the subscription plans and select or click the subscribed button that links to the Stripe Plan you've set up with a free trial.
    • Enter the payment details. For testing, you can use this Credit Card Number 4242 4242 4242 4242. For the Year and Month, use 4/42; for the CCV, use 424. Then click on the 'Start trial' button.  Once the subscription is successful, you'll get redirected to the Stripe success page of your site.
    • Now go to your Stripe Dashboard>Billing> Subscription> Test clocks> Select your test clocks simulation and click on the user with the trial subscription.
    • You'll see in the customer's overview that the subscription is on trial, and then in the invoices section, you'll see that an invoice of $0.00 is generated due to the free trial.
    • Go to wp-admin>Users and check if the role and the status have changed to Trialing. 
  • Pause & Resume
    • Pause
      • Switch to the other browser where you have a user account with a trial subscription. If you're currently on the payment success page, you can click on the Customer Portal button. 
      • If you're not on the payment success page anymore, navigate to the page where you added the Customer Portal shortcode. Once you're on that page, click the "Manage billing" button to manage your billing. This button will automatically redirect you to the Stripe Customer Billing/Portal page. 
      • Click on the Cancel Plan button. You'll be redirected to Billing>Cancel or Pause. Under the current plan, select Pause Subscription, and click the Pause Plan button.
      • Take notice that in this example, the Plan Subscription will automatically renew after one month; therefore, we'll test it using the test clock.
      • Go to Stripe Dashboard> Billings> >Subscription>Test Clocks> Select your test clocks simulation> click on the customer with a paused plan. You'll see in the customer's Overview> Subscriptions that the collection is paused.
      • Go to wp-admin>Users and check if the role and status have changed.
    • Resume
      • On the customer's page in Stripe, you will find a banner at the top with an 'Advance Time' button. Simply click on this button.
      • As we mentioned earlier, the resume time of the subscription paused plan is after 1 month, so we'll advance the time to a month. The clock time date is January 28, 2024, so we'll advance it to February 28, 2024, or you can select "+1 month" from the shortcut. Once you've selected the date, click on the Advance button.
      • The clock time has advanced and the customer subscription plan has now resumed, you can see it in the customer's subscription overview. The subscription becomes active because the plan has been resumed. You can see in the Payments and Invoices that the payment for the 1st month was canceled and void because the subscription plan was paused.
      • Go to wp-admin> Users and check if the role and status have changed. The subscription status has been active again.
    • Canceled
      • To test the cancel integration, log in to your site in another browser using the customer's account with an active subscription, then go to the page where you've added the Customer Billing Portal shortcode and click on the Manage billing button.
      • Click on the Cancel Plan button. You'll be redirected to Billing>Cancel or Pause. Under the current plan, select the Cancel subscription, then click the Cancel plan button. 
      • In the customer's Overview> Subscriptions and Payments the subscription is canceled.
      • Go to wp-admin>Users and check if the role and status have changed.
    • Past Due
      • Log in to your site in another browser using the customer's account you've created in wp-admin>Users. Then go to the page where you added the subscription plans. Subscribe to the plan with a free trial using these payment details: Credit Card Number 4000 0000 0000 3220, expiring 3/24, and CCV 232
      • A 3D secure popup window will appear. To continue, click the "Complete" button. 
      • Once the Subscription Trial is Active, go to Stripe dashboard>Customers> click on the customer with an active trial subscription. You will see in the customer's overview>subscriptions that the subscription status is in Trial mode and will end on March 2.
      • Click on the 'Advance time' button and set the clock to the day after the end date of the trial. In this example, we have set the time to March 3. Click the 'Advance ' button after setting up the date and time.
      • Once the clock time has been advanced, the payment failed, the customer was not charged because the card is declined, so the status will be Past Due.
      • You can check in wp-admin> Users if the role and status have changed.
    • Unpaid
      • If all retries scheduled for the customer's subscription payment have failed instead of canceled subscription status, you can change the settings and turn it into an unpaid subscription status.
      • Go to: https://dashboard.stripe.com/settings/billing/automatic. In the settings, scroll to Manage failed payments> Subscription status > If all retries for a payment fail > Mark the subscription unpaid. Click the save button.
      • Log in to your site in another browser using a test customer's account you've created in wp-admin>Users. Then go to the page where you've added the subscription plans and subscribe to a plan with a free trial using these payment details: Credit Card Number: 4000000000000341, exp: 3/24 CCV: 232

      • In Stripe Dashboard, Go to the Customers tab> Click on the customer with an active trial subscription.
      • You will see that the subscription status is in Trial mode and will end on March 6. Click on the 'Advance time' button and set the clock to the day after the end date of the trial.
      • In this example, we have set the date to March 7, 2023. The subscription is now Past due because of the failed payment, so the invoice shows that it's retrying.
      • The charge retry schedule will be displayed if you hover your mouse over the Retrying notice
      • You'll get the Unpaid subscription status after 3 to 7 retries of failed payment charges. To test, keep advancing the time after the scheduled invoice date. The images below show the events for which we advanced the time and date multiple times and got the unpaid subscription status  when we advanced the time/date to April 10, a month after the scheduled invoice(March 7)
      • If you scroll down to the 'Recent Activity' section, you'll find here the multiple failed payments.
      • In the Events and Logs tab, you can also see in the Events the failed attempts of payments.
      • You can check in wp-admin>Users if the role and status have changed.