Testing
Truemed’s sandbox lets you run the whole subscription lifecycle without moving real funds: provision a token, charge it, force it into a blocked state, and recover it. The flow is identical to production; only the credentials and base URL differ.
Test the failure paths, not just the happy path. A subscription integration that has never handled a
422 will break on its first expired LMN.
Set up the sandbox
A sandbox key only works against the dev base URL. See Before You Begin for the full setup.
Provision a test token
-
Create a payment session against dev with
tokenize: true, exactly as in New Subscriber. -
Open the
redirect_urland complete the health survey as the customer would. -
Enter the test card—no real funds move:
- Card number: 4242 4242 4242 4242
- Expiration: any future date
- CVC / ZIP: any values
-
In the Payments tab of the dev dashboard, open the Actions menu on the test payment and choose Approve LMN.
-
Confirm both webhooks arrive:
payment_session_completewithstatus: captured, andpayment_token_updatedcarrying thepayment_token.
Store the payment_token from the webhook. The rest of this page uses it. If payment_token_updated
never arrives, the LMN wasn’t approved—no token was provisioned.
Charge the token
Charge it the way your billing job will, with no customer present:
There’s nothing to approve this time—a recurring charge runs no new survey and issues no new LMN, so it
bills against the approved LMN already on file and the dashboard offers no Approve action. Confirm
payment_session_complete reports status: captured. That’s a complete billing period.
Drive a failure
Use the Actions menu on a test payment to push the token into a blocked state.
To test the requalification loop end to end: expire the LMN, charge the token, confirm you get 422
with next_action: "TakeHealthSurvey", send yourself to the redirect_url, complete the survey,
confirm payment_token_updated arrives with a failed_payment_session_id, then charge again with a
new payment session.
Also confirm your handler treats payment_token_updated as a stand-down signal and clears whatever
warning you raised. See Token
Lifecycle.
There’s no dashboard lever for forcing an expired or declined card, so a charge that fails that way
can’t be driven end to end. The closest you can get is calling
update_payment_token with
update_card_info: true, which returns the same next_action and redirect_url shape. That
exercises your update-card handling only—it is not a failed charge, and no 422 is involved.
Before you go live
- Swap credentials and base URL. Production key, and
https://api.truemed.com/. - Recreate both webhooks in production.
payment_session_completeandpayment_token_updated. Missing the second one means you never receive tokens. -
next_actionis wired to customer messaging. BothUpdatePaymentMethodandTakeHealthSurveyreach the customer with theredirect_url. - The expiration-monitoring job is scheduled. See Prevent failures before they happen.
- Fulfillment is idempotent. Webhook retries must not duplicate shipments, emails, or credits.
- Item changes call
update_payment_token. And you only confirm the change whennext_actioncomes back"None". - Walk the Implementation Readiness Checklist.