This guide walks through creating a charge with items (products, services, discounts) via the API and collecting payment through the embedded payment component. Use this when your integration needs to show an itemized receipt before the patient pays.Documentation Index
Fetch the complete documentation index at: https://docs.decodahealth.com/llms.txt
Use this file to discover all available pages before exploring further.
Overview
- Create a charge with line items and discounts using the Create Charge or Convert Cart to Charge API.
- Build the embed URL with the charge ID.
- Patient pays in the embed — the form displays the full charge breakdown (items, discounts, total).
Step 1: Create a charge with items
You can create a charge in two ways:Option A: Convert a cart to a charge
If you have a cart with items already added:- Create a cart for the patient.
- Add items (products, services, packages) to the cart.
- Convert the cart to a charge.
id).
Option B: Create a charge directly
Use Create Charge with aChargeDetail body that includes:
patient_iditems— array of line items withname,quantity,price, and optionaldiscountstotal_outstanding— sum of item totals minus discounts
id (e.g. chg_xxx).
Step 2: Build the embed URL
Construct the embed URL with the charge ID:{tenant}— your organization’s subdomain{patientId}— the patient’s ID (must match the charge’s patient){chargeId}— the charge ID from step 1
Optional URL parameters
| Parameter | Description |
|---|---|
allowedMethods | Comma-separated payment methods. Use CARD to disable ACH, or CARD,APPLE_PAY for card and Apple Pay only. |
theme | light or dark |
showSummary | true (default) or false to hide the payment summary |
Step 3: Load the embed
Embed the URL in an iframe on your site:postMessage:
API flow
When the embed loads, it calls the Create Embed Payment Config endpoint withcharge_id. The endpoint:
- Loads the charge from the database (with items and discounts).
- Creates a Rainforest payin config for that charge.
- Returns the session key and payin config ID.
Disabling payment methods
To restrict which payment methods appear in the embed, addallowedMethods to the URL:
allowedMethods=CARD— card only (no ACH, no Apple Pay)allowedMethods=CARD,APPLE_PAY— card and Apple Pay (no ACH)allowedMethods=CARD,ACH— card and ACH (no Apple Pay)
CARD,ACH,APPLE_PAY when not specified.