invoice.paid. Gale charges the shopper’s HSA/FSA card for each invoice and tells Stripe, so Stripe marks the invoice paid and keeps the subscription active.
Your system starts every charge. Gale keeps no schedule.
This flow is switched on per merchant account. Ask your Gale contact to enable it for your test account before you start.
Who does what
Before you start
- Create a custom payment method type in Stripe for Pay with FSA/HSA, as in Step 1 of the Stripe Payment Element page. You need its
cpmt_...id. - Save a restricted key on Gale on Stripe. Set Payment Records to Write and Invoices to Write. Gale needs nothing on charges, balance or payouts.
- Saved payment methods are enabled for your account.
- The product you sell is registered in your Gale catalog. Gale reviews each product for HSA/FSA eligibility. A digital product needs no UPC.
How it works
- You create the Stripe customer and the subscription, with your custom payment method as its default.
- For the first invoice, you create a Gale checkout that stores the card and names the Stripe customer and invoice.
- The shopper pays on Gale’s page. Gale writes a payment record to your Stripe account and attaches it to the invoice.
- Stripe marks the invoice paid and the subscription active, and sends
invoice.paid. - For each renewal, Stripe sends you
invoice.payment_attempt_required. You charge the stored card through Gale and name the new invoice.
Step 1: Create the subscription in Stripe
Create a payment method of your custom type, attach it to the customer, and create the subscription withpayment_behavior: "default_incomplete".
Step 2: Collect the first invoice
Create a Gale checkout for the invoice amount. Three keys inmetadata tie it to Stripe.
The checkout total has to equal the invoice total. Stripe refuses a payment of a different amount.
customer.email, customer.first_name and customer.last_name are required. customer.phone is optional. shipping_info is required even for a digital product, so send the customer’s billing address there. Card details are entered on Gale’s page.
When the shopper pays, you receive payment_method.id on the order.completed webhook. Store it against the Stripe customer.
Step 3: Collect each renewal
Listen forinvoice.payment_attempt_required on your Stripe webhook. Charge the stored card for that invoice.
invoice.paid once the payment is captured.
What you see where
Declines
A declined renewal returns422 with PAYMENT_METHOD_010 and a checkout_url. Send that link to the shopper so they can pay with another card. Gale does not retry a declined charge. If you use Stripe’s retry schedule, each retry sends invoice.payment_attempt_required again, and you call the charge again with a new Idempotency-Key.
Refunds and disputes
Refund the Gale order withPOST /api/v2/refunds. Gale reports the refund to the payment record in Stripe. Stripe does not send charge.refunded, and Gale does not create a credit note. Create one in Stripe if your books need it.
Stripe does not hold disputes for payments processed outside Stripe, so a dispute on one of these payments does not appear in your Stripe account. Stripe lists this in its limitations.
Cancelling
Cancel the subscription in Stripe, the way you do today. There is nothing to cancel on Gale, because Gale only charges when you ask. If the customer wants their card removed, callDELETE /api/v2/payment-methods/{id}.
Webhooks
Gale signs every webhook withX-Gale-Signature and retries a failed delivery. Add your endpoint in the Gale dashboard under Developer Tools > Webhooks. See Webhooks for the signature check and every event.
Testing
Use aglm_test_ key and a restricted key from your Stripe sandbox. Put the Stripe customer on a test clock and advance it one cycle to make Stripe send invoice.payment_attempt_required. Pay with Gale’s test cards.
Limits
- One invoice per charge, and the amounts have to match.
- A renewal cannot mix eligible and non-eligible items, and cannot include an item that needs a Letter of Medical Necessity.
- To change the shopper’s card, send them a new checkout with
setup_future_usageand remove the old payment method.
