Saved payment methods are switched on per merchant account. Ask your Gale contact to enable them for your test account before you start.
How it works
- Your server creates a checkout with
setup_future_usage: "off_session". - The shopper ticks a consent box on the hosted page and pays.
- Gale stores the card and returns a
payment_methodwith an id that starts withpm_. - Later, your server calls
POST /api/v2/payment-methods/{id}/chargeswith the items and amounts for that order. - Gale charges the card, creates an order, and sends
order.completed.
Step 1: Ask for storage at checkout
Create the checkout as usual and add one field.setup_future_usage: "off_session" and the checkout_url to send the shopper to.
Step 2: The shopper consents and pays
The hosted page shows a consent box for later charges. The shopper cannot pay until it is ticked. Gale records the consent with the payment.Step 3: Receive the payment method
Once the card is stored, the samepayment_method object appears in three places:
GET /api/v2/checkout/{id}- the
order.completedwebhook for that order - the
payment_method.savedwebhook
id against your customer. Gale never returns the card number.
Step 4: Charge the card later
Send the items for this order. Amounts are integers in cents. AnIdempotency-Key header of 22 to 255 characters is required. Use one key per order: the same key sent again returns the first result and never charges twice.
A successful charge returns
201 with the order.
order.completed with the same payment_method block. Fulfil from the webhook, as you do for a checkout.
When a charge does not go through
A decline looks like this:
payment.failed for a declined charge. Gale does not retry a declined charge for you.
A charge is refused before the card is touched when:
- the card was removed,
- the card was stored without consent to later charges,
- the order mixes eligible and non-eligible items,
- an item in the order needs a Letter of Medical Necessity. The shopper has to complete that on the hosted checkout.
Manage stored cards
Remove a card when the shopper asks you to. A removed card cannot be charged again.
Refunds
Refund an order from a stored card the same way as any other order, withPOST /api/v2/refunds.
Test and live
A card stored with aglm_test_ key can only be charged with a glm_test_ key, and the same holds for live. Use Gale’s test cards in test mode.
Limits
- A card is stored only on a paid checkout.
- To change a shopper’s card, create a new checkout with
setup_future_usageand remove the old payment method. - One checkout stores one card.
- A stored-card charge cannot mix eligible and non-eligible items, and cannot include an item that needs a Letter of Medical Necessity.
Reference
- Payment Method Object
- Charge a Payment Method
- List, Get and Remove a payment method
- Webhooks
