Setup Guide (API)
Setup Guide (API)
Setup Guide (API)
This guide walks you through implementing Truemed directly via our API. It’s written for merchants on custom or non-standard commerce platforms; if you’re on Shopify or WooCommerce, use the platform-specific integration instead. By the end, you’ll know what to build, how the payment flow works end-to-end, and how to test before going live.
Before you begin, your team should have:
If you restrict inbound traffic by source IP, ask your Solutions Engineer for the Truemed IP allowlist so our webhooks don’t get blocked at your edge.
Here’s the full lifecycle of one HSA/FSA transaction, from product page to fulfillment.
create_payment_session endpoint with the cart contents and customer info. Truemed returns a redirect_url.processing. Show the shopper an order-placed confirmation, but do not fulfill yet.captured: The LMN was issued and Truemed captured the funds. Fulfill the order.rejected: The LMN was not issued. The authorization hold will expire. Cancel the order and notify the shopper.Truemed authorization holds are valid for 6.95 days and are not re-authorized once they expire. In the rare case that practitioner review runs past that window, the order will be canceled even if the LMN is later approved.

Implementing the flow above requires five concrete pieces of work on your side. Each is independent enough that different team members can own different pieces.
Add “Pay with HSA/FSA” as a payment method alongside your existing options (credit card, PayPal, and so on). Selecting it should kick off step 3 below.

The widget educates shoppers about HSA/FSA eligibility before they reach checkout and indicates that they may qualify for HSA/FSA spending or reimbursement on the product. Truemed provides the widget as a snippet you embed on product pages where eligibility applies.

create_payment_session When the Shopper Selects Truemed at CheckoutWhen the shopper clicks “Pay with HSA/FSA,” your backend calls the create_payment_session endpoint with the cart line items, total, customer info, and your success_url and failure_url. Truemed returns a redirect_url for the hosted checkout.
Send the shopper to the redirect_url returned in step 3. Truemed handles the clinical intake form, eligibility decision, and card authorization. After completion, the shopper is redirected back to your success_url or failure_url.
Stand up an HTTPS endpoint that accepts POST requests from Truemed. Treat the webhook as the source of truth for whether an order can be fulfilled. Never fulfill based on the redirect alone. The relevant event is payment_session.completed. See the Webhooks guide for full details on signature verification, retries, and idempotency.
Use signed webhooks. They’re tamper-evident, include a built-in idempotency key (webhook_delivery_id), and only take a few lines of code to verify.
If you sell subscriptions, Truemed supports partner-managed recurring billing through the payment_token product. There are two approaches depending on the customer:
create_payment_session with tokenize=True. The initial order is processed and a reusable payment token is provisioned in the same flow.create_payment_token to provision a token for a customer who already has an active subscription with you.In either case, Truemed sends the payment_token.updated webhook once the token is ready to be used for subsequent billing periods. See the Subscriptions overview for the full implementation.
Run end-to-end test transactions in sandbox before promoting your integration to production.
To get started:
The Sandbox Testing Guide walks through test cases for the various LMN approval and rejection outcomes you’ll want to cover before going live.
If you restrict inbound traffic by source IP, add Truemed’s webhook source IPs to your allowlist before testing. Your Solutions Engineer can provide the current list.
Once your sandbox integration is complete and your team has run through the end-to-end test cases, the Truemed team will run validation transactions on our side to confirm the integration is behaving correctly. After both teams sign off, your Solutions Engineer will help you promote to production:
dev-api.truemed.com to api.truemed.com in your application configEmail merchants@truemed.com, or reach out to your Solutions Engineer directly.