Card payments and 3D Secure
On this page
Take a card payment, send the customer through 3D Secure when the bank asks for it and read the result.
A card payment is one payment intent:
- Your server calls
POST /v1/payment_intentswithconfirm: true. - If the status is
succeeded, the payment is done. - If the status is
requires_action, send the customer to the bank. They come back to yourreturn_url. - Read the payment with
GET /v1/payment_intents/{id}for its final status.
1. Choose how to collect the card
Both ways end in the same payment call, and everything after it works the same: 3D Secure, installments, capture, refunds and webhooks. Choose by who handles the card.
| Server-to-server | Browser tokenization | |
|---|---|---|
| How the card travels | Your checkout form posts it to your server. Your server sends it in payment_method_data.card of POST /v1/payment_intents with your secret key. |
A script on your page sends it to POST /v1/payment_methods with your publishable key and gets a pm_… id. Your server pays with the id. |
| Does your server receive the card? | Yes. | No. |
| What you build | A checkout form that posts to your server, and one API call. | A card form with a script that calls the API, a registered website for browser calls, and the payment call on your server. |
| Card-data security scope | Your server, and every system the request passes through. | Your checkout page and its scripts, because your script reads the card. Protect the page against script injection. |
| Typical use | Server-rendered checkouts, backends that already receive the card, integrations built like a bank virtual POS. | Checkout pages and apps whose backend should not receive card data. |
| Installment preview | By BIN (the first 6 to 8 digits). | By BIN or by the pm_… id. |
Both ways put part of your system in scope for the card-data security standard (PCI DSS), as the table shows. Which requirements apply depends on your volume and your agreement, so confirm them with your bank or your assessor. The guides for each way are server-to-server card payments and collect cards in the browser.
Both ways are open to an account by default. Your payment institution can limit an account to browser tokenization. A server-to-server request that carries a card then gets 403 card_data_not_allowed. See card entry policy.
2. Create and confirm the payment
With a pm_… id from browser tokenization:
{
"amount": 12500,
"currency": "try",
"confirm": true,
"payment_method": "pm_01J9ZQA2B4C6D8E1F3G5H7J9K2",
"payment_method_data": {
"billing_details": {
"name": "Ayşe Yılmaz",
"email": "ayse.yilmaz@example.com",
"address": {"line1": "Caferağa Mah. Moda Cad. No:12", "city": "Kadıköy", "state": "İstanbul", "postal_code": "34710", "country": "TR"}
}
},
"return_url": "https://modakitabevi.com.tr/odeme/sonuc",
"description": "Sipariş SIP-2026-10424",
"metadata": {"order_id": "SIP-2026-10424"}
}
curl -X POST https://api.pf.organizer.tr/v1/payment_intents \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY" \
-H "Idempotency-Key: order-SIP-2026-10424" \
-H "Content-Type: application/json" \
-d @payment.json
To send the card from your server, leave out payment_method and put the card in payment_method_data. The rest of the request stays the same. The full request and response are in server-to-server card payments.
{
"type": "card",
"card": {
"number": "4109090000000011",
"exp_month": 12,
"exp_year": 2030,
"cvc": "123",
"holder_name": "AYSE YILMAZ"
},
"billing_details": {
"name": "Ayşe Yılmaz",
"address": {"line1": "Caferağa Mah. Moda Cad. No:12", "city": "Kadıköy", "country": "TR"}
}
}
billing_detailsneedsname,address.line1,address.cityandaddress.country, unless your payment institution has exempted your account. See customers and billing.return_urlis where the customer comes back after 3D Secure. It must be on a registered website or callback URL.- To create the payment first and charge it later, leave out
confirmand the card. When you are ready, for example after the customer reviews the order, callPOST /v1/payment_intents/{id}/confirmwith the card or apm_…id.
3. Redirect to 3D Secure
If the response has status: requires_action, send the customer where next_action says:
next_action.type |
What to do |
|---|---|
redirect_to_url |
Redirect the browser to next_action.redirect_to_url.url. |
html_form |
Return next_action.html_form.html as the page. The form sends the customer to the bank. |
{
"id": "pi_01J9ZQ4V8K2M3N5P7R9T1W3Y5B",
"object": "payment_intent",
"amount": 12500,
"amount_charged": 12500,
"surcharge": 0,
"amount_capturable": 0,
"amount_received": 0,
"captured_minor": 0,
"refunded_minor": 0,
"amount_refundable": 0,
"currency": "try",
"status": "requires_action",
"capture_method": "automatic",
"installments": 1,
"three_d_secure": {"requested": "automatic", "effective": "required"},
"next_action": {
"type": "redirect_to_url",
"redirect_to_url": {
"url": "https://pay.example.com/3ds/pi_01J9ZQ4V8K2M3N5P7R9T1W3Y5B",
"return_url": "https://modakitabevi.com.tr/odeme/sonuc"
}
},
"return_url": "https://modakitabevi.com.tr/odeme/sonuc",
"latest_attempt": "att_01J9ZQ4V8K2M3N5P7R9T1W3Y5D",
"created": 1795167600,
"livemode": false
}
After the customer authenticates, we complete the payment. We then send the browser to your return_url with payment_intent=pi_… and argus_signature=… added to the query. Your return page uses the signature to check that the redirect came from us. See verify the redirect.
4. Handle the result
On the return page, read the payment from your server. The redirect alone does not prove the result.
curl https://api.pf.organizer.tr/v1/payment_intents/pi_01J9ZQ4V8K2M3N5P7R9T1W3Y5B \
-H "Authorization: Bearer sk_sandbox_YOUR_KEY"
status |
What to do |
|---|---|
succeeded |
Paid. Deliver the order. |
requires_capture |
Authorized (capture_method: manual). Capture when you ship. |
processing |
The bank has not answered yet. Show "Payment received, confirming" and wait for the webhook. |
requires_payment_method |
Declined, or authentication failed. last_payment_error has the reason. Offer to try another card. |
requires_action |
The customer has not finished 3D Secure. |
Also subscribe to the payment_intent.succeeded and payment_intent.payment_failed webhooks. They arrive even when the customer closes the tab on the bank's page.
A decline comes back as an error on the confirm call, not as a status. See What can go wrong.
Payments without 3D Secure
payment_method_options.card.three_d_secure controls authentication per payment:
| Value | Behavior |
|---|---|
automatic (default) |
We decide per payment, based on your account's settings and risk screening. |
required |
Always authenticate. |
none |
Charge without 3D Secure. Only when your account is enabled for it, and within the amount limits agreed with you. |
{
"card": {"three_d_secure": "none"}
}
A payment without 3D Secure completes in the confirm call, with no redirect. The response is succeeded, or requires_capture for a pre-authorization. If your account or the amount is not enabled for it, the call returns 400 non_secure_not_allowed. Send the payment with automatic instead. three_d_secure.effective on the payment shows what was used.
What can go wrong
| Error | Cause | What to do |
|---|---|---|
400 card_without_confirm |
The request carries a card but not confirm: true. Nothing was stored. |
Add confirm: true. To charge later, create the payment without a card and send the card to the confirm call. |
400 billing_details_required |
billing_details lacks a name, address line, city or country. |
Send all four. See customers and billing. |
400 return_url_not_allowed |
return_url is not on a registered website or callback URL. |
Register the address on the Websites & callbacks tab of Business details. |
400 non_secure_not_allowed |
Your account or the amount is not enabled for payments without 3D Secure. | Send the payment with automatic. |
402 card_declined |
The bank declined the card. decline_code says why. The payment exists, in requires_payment_method, and the error carries it as payment_intent. |
Ask for another card and confirm the same payment again with POST /v1/payment_intents/{id}/confirm. |
402 invalid_card, expired_card, incorrect_cvc |
The card failed a check before it reached the bank. No payment was created. | Ask the customer to check the card, then send the corrected request. |
402 fraudulent |
Fraud screening stopped the payment. | Do not retry with the same card. |
403 card_data_not_allowed |
Your account accepts cards only from the browser. | Collect the card in the browser and send payment_method. |
403 merchant_not_active, 403 merchant_setup_incomplete |
Your account is not active or not fully set up. Nothing was charged. | Contact your payment institution. Retrying does not help. |
Every decline code is in errors.
Metadata and description
Attach your own references to every payment:
description: free text of up to 1000 characters, shown in the merchant panel.metadata: up to 50 key-value strings. Keys have up to 40 characters, values up to 500. Find a payment by it:GET /v1/payment_intents?metadata[order_id]=SIP-2026-10424.receipt_email: the email address the receipt is sent to.
In the API reference
- Create a payment intent
- Confirm a payment intent
- Retrieve a payment intent
- List payment attempts
- List payment intents
Next: Receive the result on your server with Webhooks, and return money with Refunds.