Add 3D Secure to card payments
What you will learn
✅ How 3D Secure (3DS) works with Cross River card payments
✅ Which 3DS values to send for Visa and Mastercard cards
✅ How to send a pull payment with 3DS values
✅ How to handle 3DS validation errors and test in the sandbox
If you are new to card payments, check out the Card payments overview.
This tutorial builds on Send card payments. Complete that tutorial first.
This tutorial uses these API endpoints:
API | Description |
|---|---|
Creates a card token by validating the card with the card network | |
Sends a push or pull payment to or from a debit card | |
Retrieves payment details |
How 3DS works with Cross River
3D Secure (3DS) is a card network protocol. It confirms that the cardholder is the person using the card. Visa calls it Visa Secure. Mastercard calls it Mastercard Identity Check. 3DS authentication can shift fraud chargeback liability to the card issuer.
With Cross River, 3DS has 3 parts:
- You authenticate the cardholder. You integrate with Cardinal Commerce or another 3DS provider of your choice. Only you can start 3DS authentication, through your 3DS provider.
- You pass the 3DS results to Cross River. Add your 3DS provider's values to the threeDomainSecure object in POST /cardpayments/v1/payments.
- The rest of the payment flow stays the same. Cross River validates the 3DS values. It then sends them to the card network with the payment. Card tokens, webhooks, statuses, and payment retrieval work as they do today.
sequenceDiagram
participant C as Cardholder
participant P as Your platform
participant D as Your 3DS provider
participant X as Cross River
participant N as Card network
C->>P: Starts a payment with their card
P->>D: Authenticate the cardholder
D-->>C: Challenge, if the issuer requires one
D-->>P: 3DS results (ECI, CAVV or UCAF, transaction ID)
P->>X: POST /cardpayments/v1/payments with threeDomainSecure
X->>N: Payment with 3DS values
N-->>X: Approved or rejected
X-->>P: Webhook events, as for any card paymentIMPORTANT
3DS applies to pull payments only. Send the threeDomainSecure object with pull payments, and leave it out of push payments. On a push payment, the object never reaches the card network.
The threeDomainSecure object is optional. Without it, Cross River processes the pull payment as it does today.
Before you begin
Make sure you have:
- Your partner ID
- Your product ID
- An account number
- An approved card token. See Create a card token.
- A working integration with a 3DS provider
- Registered the card payment webhook events listed in Send card payments
You should be familiar with these terms:
Term | Definition |
|---|---|
3DS provider | The service that authenticates the cardholder with the card issuer, for example Cardinal Commerce |
ECI | Electronic Commerce Indicator, a 2-digit code that shows the result of 3DS authentication |
CAVV | Cardholder Authentication Verification Value, Visa's proof that the issuer authenticated the cardholder |
UCAF | Universal Cardholder Authentication Field, Mastercard's proof that the issuer authenticated the cardholder |
DS transaction ID | The 3DS 2 Directory Server transaction ID (dsTransactionId), a 36-character UUID |
Liability shift | When a 3DS-authenticated payment moves fraud chargeback liability from you to the card issuer |
Map your 3DS results
Your 3DS provider returns the authentication results. Map them to the threeDomainSecure object by card brand:
Attribute | Card brand | Description |
|---|---|---|
eci | Visa and Mastercard | The Electronic Commerce Indicator (ECI) from the 3DS authentication. Exactly 2 characters. |
cavv | Visa | Cardholder Authentication Verification Value (CAVV). A hexadecimal string of exactly 40 characters (20 bytes). |
ucaf | Mastercard | Universal Cardholder Authentication Field (UCAF) value, as your 3DS provider returns it (Base64). Maximum 32 characters. |
xid | Mastercard | The 3DS 2 DS transaction ID (dsTransactionId). Exactly 36 characters. Optional for Visa cards, which ignore it. |
The ECI values you can send depend on the card brand:
Card brand | ECI | Meaning | Also required |
|---|---|---|---|
Visa | 05 | Fully authenticated | cavv |
Visa | 06 | Authentication attempted | cavv |
Visa | 07 | Not authenticated | None |
Mastercard | 02 | Fully authenticated | ucaf |
Mastercard | 01 | Authentication attempted | ucaf |
Mastercard | 00 | Not authenticated | None |
IMPORTANT
Send the ECI values for the card's own brand. Cross River rejects a Mastercard ECI (00, 01, or 02) on a Visa card. It also rejects a Visa ECI (05, 06, or 07) on a Mastercard card.
Some 3DS providers use one field for both brands' authentication value. Route that value by card brand. For Visa, convert it to hexadecimal and send it in cavv. For Mastercard, send it unchanged in ucaf.
Convert a Visa CAVV to hexadecimal
3DS providers usually return the Visa CAVV as a 28-character Base64 string. Cross River accepts the CAVV only as 40 hexadecimal characters. To convert it:
- Base64-decode the 28-character value. The result is 20 bytes.
- Hex-encode the 20 bytes. The result is 40 characters.
For example, AAABCZIhcQAAAABZlyFxAAAAAAA= becomes 0000010992217100000000599721710000000000.
import base64
def cavv_to_hex(cavv_base64: str) -> str:
return base64.b64decode(cavv_base64).hex()
print(cavv_to_hex("AAABCZIhcQAAAABZlyFxAAAAAAA="))
# 0000010992217100000000599721710000000000Send a pull payment with 3DS
In this example, Alice Johnson authenticates with 3DS, then pays $15.50 with a Mastercard. You will send the pull payment with Alice's 3DS results.
Call POST /cardpayments/v1/payments.
Build the request as in Send a pull payment, then add the threeDomainSecure object. Alice's card is a Mastercard. The request sends eci 02, ucaf, and xid.
IMPORTANT
We recommend an idempotency key in the request header. It prevents duplicate payments if a request fails.
POST /cardpayments/v1/payments
{
"productId": "31cae717-408e-4813-a6b1-ad6600e48632",
"cardToken": "11FB445C487140A9BEA51457A796172A000000",
"accountNumber": "2287979807",
"amount": 1550,
"paymentType": "Pull",
"correspondingEntity": {
"firstName": "Alice",
"lastName": "Johnson",
"externalAccountIdentifier": "****9905",
"address": {
"street1": "456 Oak Avenue",
"street2": "Apt 12B",
"city": "Portland",
"state": "OR",
"postalCode": "97201",
"countryCode": "US"
}
},
"businessType": "P2P",
"clientIdentifier": "payment-pull-3ds-001",
"threeDomainSecure": {
"eci": "02",
"ucaf": "jJ0VwIGOGZAQABIiRlNUQkFTRTI0AA==",
"xid": "3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d"
}
}A successful API call returns the payment details, the same as any pull payment. The response also echoes your 3DS values in threeDomainSecureEci, threeDomainSecureUcaf, threeDomainSecureCavv, and threeDomainSecureXid. Any value you left out is null.
{
"id": "f8c4d823-7a21-4956-b7e2-c93b01aef4d2",
"clientIdentifier": "payment-pull-3ds-001",
"amount": 1550,
"paymentType": "Pull",
"status": "Created",
"source": "Api",
"productId": "31cae717-408e-4813-a6b1-ad6600e48632",
"partnerId": "82a1cfb9-de92-4cc2-8a74-ad6600e36d7a",
"cardId": "26acd726-dade-4064-996a-b42b00b634df",
"cardToken": "11FB445C487140A9BEA51457A796172A000000",
"cardBrand": "Mastercard",
"panLastFour": "9905",
"issuerCountryCode": "US",
"correspondingEntity": {
"firstName": "Alice",
"lastName": "Johnson",
"externalAccountIdentifier": "****9905",
"address": {
"street1": "456 Oak Avenue",
"street2": "Apt 12B",
"city": "Portland",
"state": "OR",
"postalCode": "97201",
"countryCode": "US"
}
},
"accountNumber": "2287979807",
"businessType": "P2P",
"wasRefunded": false,
"createdAt": "2026-05-10T15:40:15.2134567-04:00",
"limitsEligibleOn": "2026-05-10T15:40:15.2134567-04:00",
"lastModifiedAt": "2026-05-10T15:40:15.3245678-04:00",
"threeDomainSecureEci": "02",
"threeDomainSecureUcaf": "jJ0VwIGOGZAQABIiRlNUQkFTRTI0AA==",
"threeDomainSecureCavv": null,
"threeDomainSecureXid": "3f2b8c1e-7a4d-4e9b-9c6f-1d2e3a4b5c6d"
}The payment then follows the usual webhook flow: CardPayments.Payment.Cleared, then CardPayments.Payment.Completed or CardPayments.Payment.Rejected. See Push payment webhook flow for sample events.
IMPORTANT
When a rail fails, Cross River retries the payment on your product's next rail. Each rail sends only the 3DS values for its own card network. A retry on another network's rail loses the 3DS data. A rail without 3DS support loses it too. You may then lose the liability shift.
Handle 3DS errors
Cross River checks the threeDomainSecure object before it creates the payment. If a check fails, the API returns HTTP 400 and doesn't create the payment.
Error | Cause | How to fix it |
|---|---|---|
2111 Invalid 3D Secure data | The ECI is for the other brand, or isn't in the ECI table | Send the ECI values for the card's brand |
2111 Invalid 3D Secure data | Visa ECI 05 or 06 sent without cavv | Add the cavv from your 3DS provider |
2111 Invalid 3D Secure data | Mastercard ECI 01 or 02 sent without ucaf | Add the ucaf from your 3DS provider |
Validation error | cavv isn't exactly 40 hexadecimal characters | Convert the CAVV to hexadecimal |
Validation error | eci isn't 2 characters, ucaf is over 32 characters, or xid isn't 36 characters | Check the value against the field table in Map your 3DS results |
Test 3DS in the sandbox
You can test 2 things in the sandbox:
- Validation errors. Send any error from the table in Handle 3DS errors. Each request returns HTTP 400.
- Stored values. Call GET /cardpayments/v1/payments/{id} for a pull payment you sent with 3DS. The response shows the 3DS values that Cross River stored.
The stored values confirm that Cross River received your 3DS data. The authentication outcome, such as a liability shift, happens only in production.