3DS in a Payment
By default, creating a card payment runs 3D Secure automatically — this is the recommended approach for most integrations. You don't call any 3DS endpoint yourself; Moyasar authenticates the cardholder as part of the payment.
How it works
- Create a payment with a card
source. With 3DS enabled (the default), the payment comes backinitiatedwith asource.transaction_url. - Redirect the cardholder to
source.transaction_url. They complete the challenge with their bank (frictionless authentications complete without a visible challenge). - The cardholder is returned to your
callback_url, and the payment moves topaidorfailed. Always confirm the final status by fetching the payment.
Endpoint: POST /v1/payments
Authentication: Publishable key
- JSON
- cURL
{
"amount": 10000,
"currency": "SAR",
"callback_url": "https://merchant.example/return",
"source": {
"type": "creditcard",
"name": "John Doe",
"number": "4111111111111111",
"month": "12",
"year": "2030",
"cvc": "123",
"3ds": true
}
}
curl -X POST https://api.moyasar.com/v1/payments \
-u pk_test_YOUR_PUBLISHABLE_KEY: \
-H "Content-Type: application/json" \
-d '{
"amount": 10000,
"currency": "SAR",
"callback_url": "https://merchant.example/return",
"source": {
"type": "creditcard",
"name": "John Doe",
"number": "4111111111111111",
"month": "12",
"year": "2030",
"cvc": "123",
"3ds": true
}
}'
Controlling 3DS
The source["3ds"] flag toggles authentication for the payment. It defaults to
true.
| Value | Behavior |
|---|---|
true (default) | The payment is authenticated with 3DS before authorization. |
false | 3DS is skipped (MOTO). Only allowed if your account is enabled for MOTO. |
Skipping 3DS with "3ds": false is only permitted for accounts enabled for
mail-order/telephone-order (MOTO) transactions. Contact your account manager to
enable it. Without 3DS, fraud liability stays with the merchant.
Beyond the default
If you need to authenticate without charging, reuse an authentication across payments, or supply values you obtained elsewhere, see:
When a payment fails during authentication, see 3DS Errors for the failure reasons.