A custom checkout page is attractive: your colours, your words, your steps, and no redirect to someone else's page. It is also where things go wrong, because you are handling money and personal data. This guide explains how to build a custom checkout page with 3D Secure, which parts to build yourself, and when it is smarter not to.
Three levels of control
- Hosted page. The provider shows the whole page on its domain. You send people there. Least work, least control.
- Embedded fields. Your page, with the provider's secure fields for card number and expiry inside it. You control the layout, the provider handles the card data.
- Direct card handling. Your server receives card numbers. Almost never a good idea for a small business, because of the compliance burden.
The sweet spot is level 2. Card numbers never touch your server, so your PCI scope is small, and you still decide how the page looks.
What 3D Secure does
3D Secure is the extra check where the card's bank confirms the payer, usually with an approval in their banking app. In Europe, strong customer authentication rules require it for most online card payments. The flow is:
- The payer enters card details in the embedded fields.
- Your page asks the provider to confirm the payment.
- If the bank wants a check, the provider shows a challenge, either in a frame on your page or by redirecting.
- The payer approves.
- The provider tells your page and your server whether it succeeded.
Your job is to handle every ending: success, failure, cancelled challenge and a challenge that times out.
The building blocks
A server step to create the payment. Your server creates a payment (an intent or order) with the amount, currency and reference. The amount comes from your own database, never from the browser. Give the provider an idempotency key so that a double click does not create two payments.
A client step to collect and confirm. Load the provider's script from the provider's domain, mount the card fields, and call its confirm function. Handle the challenge it returns.
A webhook to learn the truth. The browser can lie or close early. The provider sends a signed webhook to your server when the payment succeeds. Verify the signature, store the event once, and only then mark the invoice paid. Handle the same event arriving twice.
A match check. Compare the amount and currency in the webhook to what you expected. A mismatch needs a human, not an automatic "paid".
Design choices that raise payment rates
- Show the total, the currency and what is being paid for at the top.
- Ask for as little as you can. Email and card is often enough.
- Offer local methods such as iDEAL or bank transfer next to cards. See accept iDEAL without a webshop.
- Make errors human. "Your bank did not approve this. Try again or use another card" beats an error code.
- Work at 360 pixels wide. Most payers are on phones.
- Keep the page free of distractions. No menu, no promotions.
Security basics
- Serve everything over HTTPS only.
- Load provider scripts only from the provider's domain, and set a content security policy that names it.
- Never log card data, tokens or secret keys.
- Verify webhook signatures and reject old timestamps.
- Rate limit payment creation to stop card testing, where criminals try stolen numbers on your page.
- Keep keys in server environment settings, not in code.
- Keep a record of each attempt: who, how much, result.
Do you need to build this?
Often not. If you take a few payments a month, a hosted payment link does the job and the provider handles 3D Secure, receipts and failures. Compare payment fees first, since the page does not change the provider's price. Build your own checkout page when you need a consistent brand, a multi-provider choice, invoices that open straight into payment, or to embed it on your own site.
Testing a checkout properly
Before you take real money, test every ending, not just the happy one.
- Success with 3D Secure. Use the provider's test cards that trigger a challenge, and complete it.
- Failed challenge. Decline it and check the page offers another try without losing the order.
- Closed tab. Start a payment, pay, and close the tab before the redirect. The webhook should still mark the invoice paid.
- Double click and refresh. One payment, not two.
- Wrong amount or currency in the webhook. It should raise an alert, never mark the invoice paid.
- The same webhook twice. The second one must do nothing.
- A slow network. Throttle the connection and look for spinners that never end.
- Small screens and dark mode. The card fields must stay readable.
Then make one real payment with a small amount on your own card and refund it. Write down what you saw so the next change has something to compare against.
Where RespireSoft Invoicing fits
RespireSoft Invoicing is new, and building this page is part of what we did so you do not have to. Our checkout uses the provider's embedded card fields with 3D Secure for Stripe and Revolut, shows HesabPay in a frame, lists bank transfer details, and reads the result from signed webhooks before marking an invoice paid. You connect your own provider keys, which are stored encrypted, and there is an API if you want to start a payment from your own system. Whether that is better than building it yourself depends on how much you need to customise.
The short version
Use embedded provider fields for a custom checkout page, so card numbers never reach your server. Create the payment on your server, confirm it in the browser, handle 3D Secure outcomes and trust only the signed webhook. If you only need to get paid, a hosted payment link is simpler and safer.