Payments

Overview

TendoPay payment API supports the following operations:


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

ParameterData TypeRequiredDescriptionExample
tp_amountIntegerYesTotal amount to request1000
tp_currencyStringYesISO-4217 code. Only PHP is accepted'PHP'
tp_merchant_order_idStringYesThe unique identifier of the order on the merchant side'TEST_ORDER_ID_12345'
tp_redirect_urlURLYesURL which redirect to the merchant with the transaction result'https://domain.com/redirect_url_path?query=string'
tp_merchant_user_idStringNoThe unique identifier of the user'123'
tp_descriptionString (50)NoSimple description of the order'Test order'
tp_billing_cityStringNoBilling address' city'Manila'
tp_billing_address1StringNoBilling address'123 Street'
tp_billing_postcodeStringNoBilling address' postal code'1234'
tp_shipping_cityStringNoShipping address' city'Manila'
tp_shipping_address1StringNoShipping address'123 Street'
tp_shipping_postcodeStringNoShipping 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

ParameterData TypeReturnedDescriptionExample
tp_transaction_statusStringYesStatus of the transaction'PAID', 'FAILED', 'CANCELED'
tp_transaction_idStringYesUnique transaction ID
tp_merchant_order_idStringOptionalMerchant Unique Order ID
tp_messageStringIf 'FAILED'Brief error message
tp_amountStringIf 'PAID'Approved amount
x_signatureStringYesHash 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

ParameterData TypeRequiredDescriptionExample
tp_amountIntegerYesTotal amount to request1000
tp_currencyStringYesISO-4217 code. Only PHP is accepted'PHP'
tp_merchant_order_idStringYesThe unique identifier of the order on the merchant side'TEST_ORDER_ID_12345'
tp_redirect_urlURLYesURL which redirect to the merchant with the transaction result'https://domain.com/redirect_url_path?query=string'
tp_merchant_user_idStringNoThe unique identifier of the user'123'
tp_descriptionString (50)NoSimple description of the order'Test order'
tp_billing_cityStringNoBilling address' city'Manila'
tp_billing_address1StringNoBilling address'123 Street'
tp_billing_postcodeStringNoBilling address' postal code'1234'
tp_shipping_cityStringNoShipping address' city'Manila'
tp_shipping_address1StringNoShipping address'123 Street'
tp_shipping_postcodeStringNoShipping 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

ParameterData TypeReturnedDescriptionExample
tp_transaction_statusStringYesStatus of the transaction'PAID', 'FAILED', 'CANCELED'
tp_transaction_idStringYesUnique transaction ID
tp_merchant_order_idStringOptionalMerchant Unique Order ID
tp_messageStringIf 'FAILED'Brief error message
tp_amountNumericIf 'PAID'Approved amount
x_signatureStringYesHash for tp_xxxx parameters

Cancel Payment

Resource URL

https://sandbox.tendopay.ph/payments/api/v2/cancelPayment

Parameters

ParameterData TypeDescriptionExample
tp_transaction_idStringUnique transaction ID
x_signatureStringHash 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

ParameterData TypeDescriptionExample
tp_merchant_order_idStringUnique transaction ID
tp_partial_refundIntegerIndicate if it is partial cancellation or not0: Full cancellation (default), 1: partial cancellation
tp_amountNumericIf 'tp_partial_refund' is 1Amount to cancel
tp_transaction_idNumericIf you need to partially cancel multiple times, this field is necessary, otherwise, API returns 'order id is already canceled' error.
x_signatureStringHash 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

ParameterData TypeDescriptionExample
tp_transaction_idStringUnique transaction ID
x_signatureStringHash 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

ParameterData TypeDescriptionExample
tp_merchant_order_idStringUnique transaction ID on merchant side
x_signatureStringHash 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

ParameterData TypeDescriptionExample
tp_order_tokenStringUnique order Token ID
x_signatureStringHash 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"
}