next_action
object, telling you how to proceed.
The 3DS Payment Flow
Here is the visual representation of the flow for a payment that requires 3D Secure authentication: The 3D Secure flow follows these key steps:- The customer initiates a payment and your app sends a POST request to the Tonder API with card payment details.
- Tonder detects that 3DS authentication is required and returns a 202 status with a redirect URL in the next_action field.
- Your app saves the transaction ID and redirects the customer to the 3DS authentication URL.
- The customer completes the bank’s authentication challenge (OTP, biometric, etc.) and the bank redirects them back to your return URL.
- Your app queries the transaction status using the saved transaction ID and displays the final result to the customer.
Step 1: Initiating the Payment
The initial request follows the same structure as a standard card payment, but it’s crucial to include areturn_url
so the customer can be redirected back to your site after completing the 3DS challenge.
Send a POST
request to the Process Transaction endpoint with the required parameters below:
Required Parameters
Parameter | Type | Description |
---|---|---|
operation_type | string | Must be "payment" to process a payment |
amount | number | Payment amount (e.g., 150.00 ) |
currency | string | Currency code (e.g., "MXN" for Mexican Peso) |
customer | object | Customer information containing name and email |
payment_method | object | Payment method details including type and card information |
client_reference | string | Your unique reference for this transaction |
return_url | string | URL where customer returns after 3DS authentication |
Initial Request
Step 2: Handling the next_action
Response
If 3DS authentication is required, the API will respond with a status
of pending
and a next_action
object containing the redirect URL for the customer’s authentication.
Important: Save the transaction IDYou must save the
id
from this response as you’ll need it later to check the final payment status after the customer completes the 3DS challenge.Next Action Response
next_action
, you need to:
- Store the
responseData.id
for later status verification. - Check for the redirect URL in
next_action.redirect_to_url.url
. - Redirect the customer to complete the 3DS challenge.
Step 3: Verifying the Final Status
Once the customer completes the 3DS challenge, their bank will redirect them back to thereturn_url
you provided.
At this point, the transaction has been processed, but you still need to get its final status. Use the transaction id
that you saved from the initial response to query the Get Transaction Status endpoint:
Final Status Response
While polling the status endpoint after the redirect works, the best practice is to use Webhooks. A webhook will proactively notify your server as soon as the final status is available, providing a more efficient and reliable update mechanism.
Next Steps
- Try creating payments with card tokens to securely store and reuse customer payment methods.
- Set up webhooks to receive real-time notifications when payment statuses change.
- Explore HTTP response codes to understand how to handle different API responses and error scenarios.