Hosted Payment Page
Overview
Section titled “Overview”The hosted payment page is the fastest way to accept a card payment: create a payment intent server-side, POST the customer to ElasticPay, and we handle card collection, 3D Secure, and confirmation. The customer returns to your site when they’re done.
No front-end payment code, no PCI exposure beyond SAQ A.
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"}'Keep the returned id and client_secret.
Step 2 — Send the customer to the checkout
Section titled “Step 2 — Send the customer to the checkout”The hosted checkout expects a browser form POST (it sets an encrypted session cookie and 303-redirects to the checkout page):
<form method="POST" action="https://pay.elasticpay.co/v1/checkout"> <input type="hidden" name="payment_intent" value="pi_0abc123def456ghi789jkl012mn"> <input type="hidden" name="client_secret" value="pi_0abc123_secret_xyz987"> <input type="hidden" name="pk" value="pk_sandbox_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"> <input type="hidden" name="return_url" value="https://yoursite.com/payment/complete"> <input type="hidden" name="cancel_url" value="https://yoursite.com/cart"> <button type="submit">Pay</button></form>| Field | Purpose |
|---|---|
payment_intent |
The intent id from step 1 |
client_secret |
The intent’s client_secret |
pk |
Your publishable key |
return_url |
Where the customer lands after completing payment |
cancel_url |
Where the customer lands if they abandon checkout |
With a sandbox publishable key, the checkout shows a “Test mode — no real payment will be processed” banner, so you can tell a test checkout from a live one at a glance. Live checkouts show no banner.
Step 3 — Handle the return
Section titled “Step 3 — Handle the return”After payment, the customer is redirected to return_url with the payment
intent ID as a query parameter. Treat this as a navigation event, not proof of
payment — fetch the intent or wait for the webhook.
Step 4 — Confirm via webhook
Section titled “Step 4 — Confirm via webhook”payment_intent.succeeded is the authoritative signal that money moved. See
Webhooks for signature verification.