Payments
Overview
TendoPay payment API supports the following operations:
- Create Payment Order: Create a payment with details.
- Payment: Authorization and payment with the payment token.
- Cancel Payment: Cancel previously completed payment(s).
Merchant can choose either API with Authorization or Payment Gateway method to make the operations above. You can head to Authorization page for more information.
API with Authorization
API with authorization works by creating the payment order through API and redirects the order for authorization to complete the payment.
Create Payment Order
In order to create the payment order send a request to the resource url https://sandbox.tendopay.ph/payments/api/v2/order
with the following parameters in the table below:
Parameters
Parameter | Data Type | Required | Description | Example |
---|---|---|---|---|
tp_amount | Integer | Yes | Total amount to request | 1000 |
tp_currency | String | Yes | ISO-4217 code. Only PHP is accepted | 'PHP' |
tp_merchant_order_id | String | Yes | The unique identifier of the order on the merchant side | 'TEST_ORDER_ID_12345' |
tp_redirect_url | URL | Yes | URL which redirect to the merchant with the transaction result | 'https://domain.com/redirect_url_path?query=string' |
tp_merchant_user_id | String | No | The unique identifier of the user | '123' |
tp_description | String (50) | No | Simple description of the order | 'Test order' |
tp_billing_city | String | No | Billing address' city | 'Manila' |
tp_billing_address1 | String | No | Billing address | '123 Street' |
tp_billing_postcode | String | No | Billing address' postal code | '1234' |
tp_shipping_city | String | No | Shipping address' city | 'Manila' |
tp_shipping_address1 | String | No | Shipping address | '123 Street' |
tp_shipping_postcode | String | No | Shipping address' postal code | '1234' |
Sample Code
Request
curl -XPOST 'https://sandbox.tendopay.ph/payments/api/v2/order' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-D '
{
"tp_amount": 1000,
"tp_currency": "PHP",
"tp_merchant_order_id": "TEST_ORDER_ID_12345",
"tp_redirect_url": "https://domain.com/redirect_url_path?query=string",
"tp_merchant_user_id": "unique_user_authorization-with-order-token"
}'
Response
{
"tp_order_token": "9615de35-d338-48bc-9635-e301d2837d89",
"authorize_url": "https://sandbox.tendopay.ph/payments/authorise/9615de35-d338-48bc-9635-e301d2837d89"
}
{info}
tp_order_token
is valid for one time request only. If the payment fails, the merchant should create another payment order.
Authorization with Order Token
When a user is redirected to the URL below, they will be met with a pop-up to authorize their credentials (ID/password).
Redirect URL
https://sandbox.tendopay.ph/payments/authorise/{tp_order_token}
Response
Parameter | Data Type | Returned | Description | Example |
---|---|---|---|---|
tp_transaction_status | String | Yes | Status of the transaction | 'PAID', 'FAILED', 'CANCELED' |
tp_transaction_id | String | Yes | Unique transaction ID | |
tp_merchant_order_id | String | Optional | Merchant Unique Order ID | |
tp_message | String | If 'FAILED' | Brief error message | |
tp_amount | String | If 'PAID' | Approved amount | |
x_signature | String | Yes | Hash for tp_xxxx parameters |
{info} The result will be redirected to
tp_redirect_url
when the merchant adding this response.
Payment Gateway
Payment gateway simplifies the process by acting both as creating a payment order and an order token.
Parameters
Parameters are the same as create payment order
Parameter | Data Type | Required | Description | Example |
---|---|---|---|---|
tp_amount | Integer | Yes | Total amount to request | 1000 |
tp_currency | String | Yes | ISO-4217 code. Only PHP is accepted | 'PHP' |
tp_merchant_order_id | String | Yes | The unique identifier of the order on the merchant side | 'TEST_ORDER_ID_12345' |
tp_redirect_url | URL | Yes | URL which redirect to the merchant with the transaction result | 'https://domain.com/redirect_url_path?query=string' |
tp_merchant_user_id | String | No | The unique identifier of the user | '123' |
tp_description | String (50) | No | Simple description of the order | 'Test order' |
tp_billing_city | String | No | Billing address' city | 'Manila' |
tp_billing_address1 | String | No | Billing address | '123 Street' |
tp_billing_postcode | String | No | Billing address' postal code | '1234' |
tp_shipping_city | String | No | Shipping address' city | 'Manila' |
tp_shipping_address1 | String | No | Shipping address | '123 Street' |
tp_shipping_postcode | String | No | Shipping address' postal code | '1234' |
Sample Code
HTML Form
<form method="POST" action="https://sandbox.tendopay.ph/pg/tendopay/order">
<input type="hidden" name="access_token" value="eyJ0eXAiOiJKhbGciOiJSUz...JKV1QiLCJhbGciOiJSU">
<input type="hidden" name="x_signature" value="f04168237131b7c96f8b3d....89db4525b87aa1895dc8">
<input type="hidden" name="tp_amount" value="1000">
<input type="hidden" name="tp_currency" value="PHP">
<input type="hidden" name="tp_merchant_order_id" value="TEST_ORDER_ID_12345">
<input type="hidden" name="tp_redirect_url" value="https://domain.com/redirect_url_path?query=string">
<input type="hidden" name="tp_merchant_user_id" value="unique_user_id_in_merchant_side">
<input type="hidden" name="tp_description" value="Test order">
</form>
Response
Parameter | Data Type | Returned | Description | Example |
---|---|---|---|---|
tp_transaction_status | String | Yes | Status of the transaction | 'PAID', 'FAILED', 'CANCELED' |
tp_transaction_id | String | Yes | Unique transaction ID | |
tp_merchant_order_id | String | Optional | Merchant Unique Order ID | |
tp_message | String | If 'FAILED' | Brief error message | |
tp_amount | Numeric | If 'PAID' | Approved amount | |
x_signature | String | Yes | Hash for tp_xxxx parameters |
Cancel Payment
Resource URL
https://sandbox.tendopay.ph/payments/api/v2/cancelPayment
Parameters
Parameter | Data Type | Description | Example |
---|---|---|---|
tp_transaction_id | String | Unique transaction ID | |
x_signature | String | Hash for tp_xxxx parameters |
Sample Code
CURL
curl -XPOST 'https://sandbox.tendopay.ph/payments/api/v2/cancelPayment' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-D '
{
"tp_transaction_id": 123456,
"x_signature": "b7c96f8b3df04168237131....7aa1895dc889db4525b8"
}
'
Response
{info} Success: Return 200 status code
Failure: Return greater than 400 status code with an error message.
{
"error": "This transaction cannot be canceled."
}
Cancel Payment By Merchant Order ID
Resource URL
https://sandbox.tendopay.ph/payments/api/v2/cancelPaymentByOrderId
Parameters
Parameter | Data Type | Description | Example |
---|---|---|---|
tp_merchant_order_id | String | Unique transaction ID | |
tp_partial_refund | Integer | Indicate if it is partial cancellation or not | 0: Full cancellation (default), 1: partial cancellation |
tp_amount | Numeric | If 'tp_partial_refund' is 1 | Amount to cancel |
tp_transaction_id | Numeric | If you need to partially cancel multiple times, this field is necessary, otherwise, API returns 'order id is already canceled' error. | |
x_signature | String | Hash for tp_xxxx parameters |
Sample Code
CURL
curl -XPOST 'https://sandbox.tendopay.ph/payments/api/v2/cancelPaymentByOrderID' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-D '
{
"tp_merchant_order_id": "TEST_ORDER_ID_12345",
"tp_partial_refund": 1,
"tp_amount": 1000,
"x_signature": "b7c96f8b3df04168237131....7aa1895dc889db4525b8"
}
'
Response
{info} Success: Return 200 status code
Failure: Return greater than 400 status code with an error message.
{
"error": "This transaction cannot be canceled."
}
Show Transaction Detail
Resource URL
https://sandbox.tendopay.ph/payments/api/v2/showTransaction
Parameters
Parameter | Data Type | Description | Example |
---|---|---|---|
tp_transaction_id | String | Unique transaction ID | |
x_signature | String | Hash for tp_xxxx parameters |
Sample Code
CURL
curl -XPOST 'https://sandbox.tendopay.ph/payments/api/v2/showTransaction' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-D '
{
"tp_transaction_id": 123456,
"x_signature": "b7c96f8b3df04168237131....7aa1895dc889db4525b8"
}
'
Response
{
"tp_transaction_id": 11267,
"tp_transaction_status": "CANCELED",
"tp_amount": 1500,
"tp_currency": "PHP",
"tp_merchant_order_id": "TEST_ORDER_ID_12346",
"tp_description": "INVOICE-#00001",
"tp_created_at": "2020-09-04T08:26:25+08:00",
"tp_updated_at": "2020-09-04T09:20:17+08:00",
"x_signature": "9b431d8ae1756b3b89d1...c7286cb987ec6f594857ade8"
}
Show Transaction Detail By Merchant Order ID
Resource URL
https://sandbox.tendopay.ph/payments/api/v2/showTransactionByOrderId
Parameters
Parameter | Data Type | Description | Example |
---|---|---|---|
tp_merchant_order_id | String | Unique transaction ID on merchant side | |
x_signature | String | Hash for tp_xxxx parameters |
Sample Code
CURL
curl -XPOST 'https://sandbox.tendopay.ph/payments/api/v2/showTransactionByOrderId' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-D '
{
"tp_merchant_order_id": "TEST_ORDER_ID_12346",
"x_signature": "b7c96f8b3df04168237131....7aa1895dc889db4525b8"
}
'
Response
{
"tp_transaction_id": 11267,
"tp_transaction_status": "CANCELED",
"tp_amount": 1500,
"tp_currency": "PHP",
"tp_merchant_order_id": "TEST_ORDER_ID_12346",
"tp_description": "INVOICE-#00001",
"tp_created_at": "2020-09-04T08:26:25+08:00",
"tp_updated_at": "2020-09-04T09:20:17+08:00",
"x_signature": "9b431d8ae1756b3b89d1...c7286cb987ec6f594857ade8"
}
Show Order Detail
Resource URL
https://sandbox.tendopay.ph/payments/api/v2/showOrder
Parameters
Parameter | Data Type | Description | Example |
---|---|---|---|
tp_order_token | String | Unique order Token ID | |
x_signature | String | Hash for tp_xxxx parameters |
Sample Code
CURL
curl -XPOST 'https://sandbox.tendopay.ph/payments/api/v2/showOrder' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-H 'Authorization: Bearer {accessToken}' \
-D '
{
"tp_order_token": 82338d33-8e5b-4088-89c8-a6a9901bbf1b,
"x_signature": "a9b12f8b3df04168237131....7aa1895dc889db4525b8"
}
'
Response
{
"tp_order_token": "82338d33-8e5b-4088-89c8-a6a9901bbf1b",
"tp_amount": 1500,
"tp_currency": "PHP",
"tp_merchant_order_id": "TEST_ORDER_ID_12346",
"tp_merchant_user_id": "",
"tp_description": "INVOICE-#00001",
"tp_billing_city": "",
"tp_billing_address1": "",
"tp_billing_zip": "",
"tp_shipping_city": "",
"tp_shipping_address1": "",
"tp_shipping_zip": "",
"tp_created_at": "2020-09-04T08:35:48+08:00",
"x_signature": "db6a94db7428e981e40...144b5ab68cee82e5cdf69e853"
}