Stripe - Test your integration
Sandbox/Test Mode allows you to process subscriptions and simulate different payment responses using Stripe.com Test Cards. Toggle the Sandbox/Test Mode checkbox and ensure the API Keys are listed in the Ultimate Member > Settings > Extensions > Stripe. After that, click the Subscription button or add a Stripe Subscription Plan field to a Register form to redirect you to the Stripe Checkout page and then add the test card details.
To test the integration, ensure that you've read and set the required details in the following documentation before you proceed:
- Setting up Webhook and Test/Public Keys
- Setting up Stripe Success and Cancel Payment Pages
- Create Subscription Prices
- Shortcodes & Subscription Events
- Add Subscription Plans to a Register Form
- Create & Test Customer Billings
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
Recommendation: Stripe has a Test Clock feature where you can simulate the Stripe events by advancing time. Please see this article: https://docs.ultimatemember.com/article/1803-test-your-integration-with-stripe-test-clocks
Warning: When testing, please use a subscriber account instead of an administrator account. When you use an administrator account, it won't remove the roles assigned to it, and this is to prevent you from being locked out as an admin.
Testing the Subscription Statuses and Assigning Roles
- Using your Admin account, add a new user with a subscriber role.
- Open the WP Admin > Users page with your Admin account and see the Role column. Keep this browser window open during testing.
- Add the Stripe shortcode to a Page or the Stripe Plan predefined field to a Register form.
- Using a different browser, log in to the site using the subscriber account you've created.
- Then go to the subscription page where you've setup your products or subscription, click on the Stripe button to proceed to the checkout page. A user must be logged in for the redirection to work when using the Stripe button.
- Use the Test Credit Cards from Stripe.com Test Cards to pay the subscription plan. 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.
- When the payment processing is successful with the test account, you can go to the other browser with the Admin account and then check in the WP Admin > Users and see if the test subscriber's role and status have changed. The user role you've set in your Stripe Plan Subscription settings should be assigned to this user.
- Now to test if pause and resume roles are getting assigned to the test subscriber account, go to the other browser and use the subscriber account and then go to the Customer Billing page and click on the button to proceed to the Stripe Customer Billing/Portal page. Click the "Cancel Plan" button.
- Choose "Pause Subscription" then click the "Pause plan" button. Using the Admin account, check in WP Admin > Users if the role has changed. Ensure that the "pause" attribute has a role for it to work.
Note: We created the roles in wp-admin>Ultimate Member>User Roles to demonstrate the integration; the subscription status in the Role column is not the actual status but a role.
- On the same subscriber's Stripe Customer Portal, click on "Resume Plan." Again, check if the test account's user role has changed in the WP Admin > Users.
- In the subscriber's account go Customer Billing Portal page>Manage Billings>Click the "Cancel" button to test the "Cancel Plan" role. From the billing page,select "Cancel Subscription" and click on the "Cancel plan" button. Check in wp-admin>Users if the role has changed.
- To the the "Trialing" and "Past Due" status and roles,use the user's account and subscribe to a plan with Free Trial. In the example below, Premium Plan has 3 days trial. So the test subscriber account will subscribe to the Premium plan using this Credit Card Number 4000 0000 0000 3220. For the Year and Month, use 3/24; for the CCV, use 232. After clicking the "Start trial" button a popup 3D secure will show. Click the "Complete" button to continue.
- Check in the wp-admin>Users if the role and status has changed to 'Trialing.'
- Then go to https://dashboard.stripe.com/test/customers, look for the test subscriber and click on it. You'll be redirected to the customer's overview. In 'Subscriptions,' click the pencil icon to "Update subscription."
Scroll down to the Subscription schedule, then change the Free Trial days value to 0. Click on the "Update subscription" button.
-
-
A 3D secure popup window will appear. To continue, click the
"Update subscription" button.< After the update, check if the role and status changed to
"Past due" in
wp-admin>Users.
Note: When the trial period ends, it will automatically set the subscription status to "active." Ensure that the "active" attribute has a role assigned to it so that the subscriber's role will be changed.