Embedded Checkout (iFrame)
Embedded Checkout (iFrame)
The iFrame is an alternative presentation of the standard payment session—the same eligibility survey, card entry, statuses, and webhooks as the hosted redirect, just rendered inline on your page instead of sending the customer to a Truemed-hosted page. Use it when you want customers to stay on your site through checkout.
Everything you build for the redirect flow still applies—creating the session, handling
payment_session_complete, and fulfilling on captured. Only two things change:
Fulfillment is unchanged: the payment_session_complete webhook with status: captured is still the
source of truth. The postMessage success flag is only for updating your own UI.
Enable the iFrame
Add the optional use_iframe parameter to
create_payment_session. When use_iframe
is true, the redirect_url in the response is an iframe-compatible URL you render inline instead of
redirecting to.
Example Request
Example Response
Handling iFrame Responses
Partner sites can set the iframe element’s src to redirect_url and this will render Truemed’s survey and checkout in the iframe. A message event listener will need to be added to listen for messages from the iframe. Upon completion of the survey and payment, Truemed will send a message from the iframe to the parent using the browser’s PostMessage API with two parameters success and redirectUrl. After handling the message, the iframe can be removed.
success- boolean that returnstrueif checkout flow was successful on Truemed’s end,falseif otherwiseredirectUrl- string that will be set tosuccess_urlfrom the original create request body ifsuccessistrueorfailure_urlifsuccessisfalse. Only need to be used if redirect is desired or need to handle success and failure differently.
Apple Pay requires allow="payment" on the iframe and HTTPS on the parent page. Card payments and Link work without it.