Your First Transaction
This guide will walk you through making your first payment using Tonder’s Direct API in the sandbox (also referred as stage) environment.Prerequisites
Before you begin, make sure you have the following:- Tonder account credentials to sign in at app.tonder.io
- API key and secret from your developer dashboard
- Basic understanding of REST APIs and HTTP requests
Step 1: Set Up Your Environment
Use the sandbox environment for testing all features without processing real transactions. Use the base URL below when making requests.Base URL
Required Headers
When making requests, you must include these headers:Step 2: Implement HMAC Signature
For secure API access, you must generate an HMAC signature for each request. The signature is a hash of the request payload, calculated using your secret key.Python Implementation
Python Implementation
Here is a full example of a Python implementation for generating the signature.
Step 3: Make Your First Payment
Make your first payment by sending a POST request to the process endpoint. You can use the following request body to test a card payment.Basic Card Payment Request
Basic Card Payment Request
This is an example request to the process endpoint.
Expected Response
Expected Response
A successful request returns a
201
Created status code and a transaction object.Status Check Request
Status Check Request
After a payment is initiated, you can check its status by making a GET request.The expected response is as follows:
Test Different Payment Methods
After successfully completing the card payment, you can experiment with other payment methods. Below are the example request bodies for SPEI and OXXO cash payments.Test Data for Different Scenarios
The following tables provide test data for various scenarios and expected outcomes.Test Cards
Card Number | Scenario | Expected Result |
---|---|---|
4242424242424242 | Successful payment | authorized status |
4000000000000002 | Card declined | declined status |
4000000000009995 | Insufficient funds | declined status |
4000000000000119 | 3D Secure required | pending with redirect |
4000000000000341 | Processing error | failed status |
Test Bank Accounts
CLABE | Scenario | Expected Result |
---|---|---|
646180157000000004 | Successful transfer | processing status |
012345678901234567 | Invalid checksum | Validation error |
999999999999999999 | Non-existent bank | institution_not_found error |
Complete Test Flow Example
This is a complete test flow example of an implementation in Python.Common Testing Scenarios
Before going live, it’s a good idea to run through these typical test cases to make sure your integration is working as expected:Successful Payment
Successful Payment
To verify that your integration can process a standard payment, use the following test scenario:
- Test card number:
4242424242424242
- How to test: Submit a payment request using the above card details.
- What should happen: The API should return a response with a status of either
authorized
orsuccess
. - What to look for: Make sure the response includes a valid transaction ID, confirming that the payment was processed successfully.
Declined Payment
Declined Payment
This scenario checks how your integration handles declined transactions:
- Test card number:
4000000000000002
- How to test: Attempt a payment using this card number.
- What should happen: The API should respond with a status of
declined
. - What to look for: The response should contain an error message explaining why the payment was declined. Confirm that your application displays or logs this error appropriately.
3D Secure Challenge
3D Secure Challenge
Test your handling of payments that require additional authentication (3D Secure):
- Test card number:
4000000000000119
- How to test: Initiate a payment with this card number.
- What should happen: The API will return a status of
pending
and include anext_action.redirect_to_url
field in the response. - What to do: Simulate the customer being redirected to the provided URL and completing the authentication process. Ensure your integration can handle the redirect and update the transaction status accordingly.
OXXO Cash Payment
OXXO Cash Payment
Validate your support for cash payments via OXXO:
- Payment method: Select OXXO as the payment method in your request.
- How to test: Submit a payment request using OXXO.
- What should happen: The API should respond with a status of
pending
and provide apayment_instructions
object. - What to look for: Check that the response includes both a barcode and a reference code. These details are needed for the customer to complete the payment at an OXXO location. Make sure your application displays these instructions clearly to the user.
Troubleshooting
If you run into issues during testing, here are some common problems and how to resolve them:Issue | What to Do |
---|---|
401 Authentication Error | Double-check your API key – is it correct and in the right format? |
422 Validation Error | Make sure all required fields are present and data formats are valid |
500 Server Error | Try again, and if it keeps happening, contact support |
Rate limit exceeded | Add a delay and implement exponential backoff before retrying |
What’s Next?
- Review Payment Methods – Explore all the payment options you can offer
- Set Up Webhooks – Get real-time updates on transaction events
- Implement Error Handling – Make sure your app handles failures smoothly
- Go Live – Follow the Production Readiness checklist to launch safely