Skip to main content

Embedded Checkout Integration

Embed Gale’s secure checkout directly on your website using an iframe. Customers stay on your domain while Gale handles payment processing, eligibility verification, and compliance.

When to Use Embedded Checkout

Perfect for you if:
  • You want customers to stay on your website during checkout
  • You need a branded checkout experience
  • You’re building a platform or multi-tenant solution
  • You want Gale to handle checkout UI and compliance
  • You can integrate via API to create checkout sessions

How It Works

  1. Customer adds items to cart on your website
  2. Your site creates a checkout session via POST /api/v2/checkout
  3. Gale API returns a checkout_url
  4. Your site embeds the checkout URL in an iframe
  5. Customer completes payment in the iframe (stays on your domain)
  6. Gale processes the payment securely
  7. Gale sends webhook notification with order.created event
  8. Your site shows confirmation to customer

Implementation Steps

1

Create Checkout Session via API

When customer is ready to checkout, create a checkout session with their items
2

Embed the Checkout Iframe

Use the returned checkout_url in an iframe on your checkout page
3

Handle Payment Confirmation

Listen for webhooks or postMessage events to confirm payment
4

Fulfill the Order

Process the order and show confirmation to customer

Step 1: Create Checkout Session

Create a checkout session with customer info and line items.
All monetary amounts are integers in cents (e.g., 2995 = $29.95).
Response:

Step 2: Embed Checkout

Use the checkout_url in an iframe on your page:

Step 3: Handle Payment Confirmation

Learn more about Webhooks →

Option B: PostMessage Events

Listen for iframe postMessage events:
Check order status via webhooks instead of polling. If you must poll, use the Order API:

Subscription Support

Embedded checkout fully supports subscriptions:
Customers will see subscription terms in the checkout and agree to recurring billing.

Customization

Iframe Styling

Success/Failure URLs

Customize where customers land after checkout:
Variables available:
  • {CHECKOUT_SESSION_ID} - Checkout session identifier
  • {ORDER_ID} - Order identifier (after payment)
  • {CUSTOMER_EMAIL} - Customer’s email

Platform Integration Examples

Multi-Tenant Platform

Shopify App Example

Security Best Practices

Verify Webhooks

Always verify webhook signatures before processing

Use HTTPS

Only embed checkout on HTTPS pages

Validate Origins

Check event.origin in postMessage listeners

Secure API Keys

Never expose API keys in frontend code

Testing

Test Mode

Use test API keys for development:

Test the Flow

  1. Create a test cart
  2. Embed checkout iframe
  3. Use test HSA card: 4111111111111111
  4. Complete payment
  5. Verify webhook received
See all test cards →

Troubleshooting

Possible causes:
  • Incorrect checkout_url
  • Missing allow="payment" attribute
  • HTTPS required
  • Content Security Policy blocking iframe
Solution: Check browser console for errors, ensure HTTPS, add CSP exception
Solution: Verify origin check matches https://checkout.withgale.com exactly
Solution: Checkout sessions expire after 24 hours. Create a new checkout session.
Solution: Some mobile browsers have iframe limitations. Consider using redirect flow (payment links) for mobile.

API Reference

Complete API documentation:

Next Steps

Webhooks Setup

Configure real-time payment notifications

Custom API

Need more control? Try custom API integration

Subscriptions

Learn about subscription management

Test Cards

Test your integration with test HSA cards

Support

Questions about embedded checkout?