Take a One-Off Payment
Channels: Hosted · Embedded · Direct Methods: Card · BECS
The core flow behind every one-off payment:
- Create a payment intent on your server
- Collect payment details through your chosen channel
- Confirm the payment
- Treat the
payment_intent.succeededwebhook as the source of truth
Step 1 — Create a payment intent
Section titled “Step 1 — Create a payment intent”curl -X POST https://api.elasticpay.co/api/v1/payment_intents \ -H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{"amount": 5000, "currency": "AUD"}'Response:
{ "id": "pi_0abc123def456ghi789jkl012mn", "status": "requires_payment_method", "client_secret": "pi_0abc123def456ghi789jkl012mn_secret_xyz987", "amount": 5000, "currency": "AUD"}Pass the client_secret to your front end — it lets the widget confirm the
payment without exposing your secret key.
Step 2 — Collect payment details
Section titled “Step 2 — Collect payment details”Pick a channel:
- Hosted payment page — form-POST the customer to ElasticPay; no front-end code. Card only.
- Embedded widget — mount the card widget (or the
BECS widget) on your page. The widget
tokenises the details and returns a
pm_xxx. - Direct API — you already hold a
tokenised
pm_xxx(e.g. a saved method) and confirm server-side.
Step 3 — Confirm the payment
Section titled “Step 3 — Confirm the payment”curl -X POST https://api.elasticpay.co/api/v1/payment_intents/pi_0abc123def456ghi789jkl012mn/confirm \ -H "Authorization: Bearer sk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \ -H "Content-Type: application/json" \ -d '{"payment_method": "pm_0xyz789abc123def456ghi012jkl"}'Check status in the response:
| Status | Meaning |
|---|---|
succeeded |
Payment complete |
processing |
Pending — normal for BECS; wait for the webhook |
requires_action |
3D Secure challenge (card) — the widget handles it |
failed |
Declined |
For BECS, processing can last days and can still end in a dishonour — see
BECS Direct Debit.
Step 4 — Listen for webhooks
Section titled “Step 4 — Listen for webhooks”payment_intent.succeeded is the authoritative completion signal; don’t rely
on the synchronous response alone. See Webhooks.
Also saving the method?
Section titled “Also saving the method?”If the customer agrees to keep their card on file, create the intent with a
customer_id and "metadata": {"store_payment_method": "true"} — the first
purchase then establishes the stored credential in the same transaction. See
Save a Payment Method.