Skip to main content

S2S APM (NAPS only)

Version: 1.0.0
Released: 2022/12/10

Introduction


This document describes integration procedures and VIRTUAL PAYMENT GATEWAY protocol usage for e-commerce merchants. Merchants using only NAPS (Local Qatari Debit Cards) can use this integration method.

VIRTUAL PAYMENT GATEWAY protocol implements acquiring payments (purchases) with using specific API interaction.

Integration Process


Definitions

{{API_HOST}} = https://api.tesspayments.com/post-va

Client Registration

Before you get an account to access Payment Platform, you must provide the following data to the Payment Platform administrator.

DataDescription
Callback URLURL which will be receiving the notifications of the processing results of your request to Payment Platform
Contact e-mailClient`s contact email
IP ListList of your IP addresses, from which requests to Payment Platform will be sent.

With all Payment Platform POST requests at Callback URL the Client must return the string "OK" if he/she successfully received data or return "ERROR".

You should get the following information from administrator to begin working with the Payment Platform.

ParameterDescription
CLIENT_KEYUnique key to identify the account in Payment Platform (used as request parameter). In the administration platform this parameter corresponds to the "Merchant key" field
PASSWORDPassword for Client authentication in Payment Platform (used for calculating hash parameter). In the administration platform this parameter corresponds to the "Password" field
PAYMENT_URLURL to request the Payment

Payment Platform Interaction

For the transaction you must send the server to server HTTPS POST request to the Payment Platform URL (PAYMENT_URL). In response Payment Platform will return the JSON (http://json.org/)) encoded string.

List of possible actions in Payment Platform

When you make request to Payment Platform, you need to specify action that needs to be done. Possible actions are:

ActionDescription
SALECreates SALE transaction
CREDITVOIDCreates REFUND transaction
GET_TRANS_STATUSGets status of transaction in Payment Platform

List of possible transaction results and statuses

Result – value that system returns on request. Possible results are:

ResultDescription
SUCCESSAction was successfully completed in Payment Platform
DECLINEDResult of unsuccessful action in Payment Platform
REDIRECTAdditional action required from requester
ACCEPTEDAction was accepted by Payment Platform, but will be completed later
ERRORRequest has errors and was not validated by Payment Platform

Status – actual status of transaction in Payment Platform. Possible statuses are:

StatusDescription
PREPAREStatus is undetermined, final status will be sent in callback
REDIRECTThe transaction awaits SALE
SETTLEDSuccessful transaction
REFUNDTransaction for which refund was made
DECLINEDNot successful transaction

Transactions requests

SALE request


Use SALE request to create a payment in the Payment Platform.

If you want to send a payment for the specific sub-account (channel), you need to use channel_id that specified in your Payment Platform account settings.

This request is sent by POST in the background (e.g. through PHP CURL).

Request Parameters

ParameterDescriptionLimitationsRequired
actionAction to perform (=SALE)= SALE+
client_keyUnique client key (CLIENT_KEY)+
channel_idPayment channel (Sub-account)String up to 16 characters-
brandBrand through which the transaction is performedString up to 36 characters(Appendix B)+
order_idTransaction ID in the Clients systemString up to 255 characters+
order_amountThe amount of the transactionNumbers in the format XXXX.XX
Pay attention that amount format depends on currency exponent.
If exponent = 0, then amount is integer (without decimals). It used for currencies: CLP, VND, ISK, UGX, KRW, JPY.
If exponent = 3, then format: XXXX.XXX (with 3 decimals). It used for currencies: BHD, JOD, KWD, OMR, TND.
+
order_currencyCurrency3-letter code+
order_descriptionDescription of the transaction (product name)String up to 1024 characters [a-zA-Z0-9,]+
payer_first_nameCustomer's nameString up to 32 characters-
payer_last_nameCustomer's surnameString up to 32 characters-
payer_addressCustomer's addressString up to 255 characters-
payer_countryCustomer's country2-letter code-
payer_stateCustomer's stateString up to 32 characters-
payer_cityCustomer's cityString up to 32 characters-
payer_zip ZIP-code of the CustomerString up to 32 characters-
payer_emailCustomer's emailString up to 256 characters-
payer_phoneCustomer's phoneString up to 32 characters-
payer_birth_dateCustomer's birthdayDate format is "YYYY-MM-DD"-
payer_ipIP-address of the CustomerXXX.XXX.XXX.XXX+
return_urlURL to which Customer should be returned after operation in third-party systemString up to 1024 characters+
identifierExtra parameter for transaction. It could be token, account information, additional descriptor etc. Value should be unique.String up to 255 characters+
hashSpecial signature to validate your request to Payment PlatformSee Appendix A, Sale signature.+

Response Parameters

You will get JSON encoded string with transaction result.

Successful sale response

ParameterDescription
actionSALE
resultSUCCESS
statusSETTLED
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Payment Platform
trans_dateTransaction date in the Payment Platform
descriptorThis is a string which the owner of the credit card will see in the statement from the bank. In most cases, this is the Customers support web-site.

Unsuccessful sale response

ParameterDescription
actionSALE
resultDECLINED
statusDECLINED
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Payment Platform
trans_dateTransaction date in the Payment Platform
decline_reasonThe reason why the transaction was declined

Redirect transaction response

ParameterDescription
actionSALE
resultREDIRECT
statusREDIRECT
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Payment Platform
trans_dateTransaction date in the Payment Platform
redirect_urlURL to which the Client should redirect the Customer
redirect_paramsArray of specific parameters
redirect_methodThe method of transferring parameters (POST/GET)

Callback parameters

Successful sale response

ParameterDescription
actionSALE
resultSUCCESS
statusSETTLED
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Client's system
trans_dateTransaction date in the Payment Platform
descriptorThis is a string which the owner of the credit card will see in the statement from the bank.In most cases, this is the Customers support web-site
hashSpecial signature to validate callback. See Appendix A, Callback signature.

Unsuccessful sale response

ParameterDescription
actionSALE
resultDECLINED
statusDECLINED
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Client's system
trans_dateTransaction date in the Payment Platform
descriptorTransaction date in the Payment Platform
decline_reasonDescription of the cancellation of the transaction
hashSpecial signature to validate callback. See Appendix A, Callback signature.

Redirect transaction response

ParameterDescription
actionSALE
resultREDIRECT
statusREDIRECT
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Client's system
trans_dateTransaction date in the Payment Platform
redirect_urlURL to which the Client should redirect the Customer
redirect_paramsArray parameters
redirect_methodThe method of transferring parameters (POST/GET)
hashSpecial signature to validate callback. See Appendix A, Callback signature.

CREDITVOID request


CREDITVOID request is used to complete REFUND transactions.

REFUND transaction is used to return funds to account, previously submitted by SALE transactions.

This request is sent by POST in the background (e.g. through PHP CURL).

Request parameters

ParameterDescriptionLimitationsRequired
actionAction to perform= CREDITVOID+
client_keyUnique client key (CLIENT_KEY)+
trans_idTransaction ID in the Payment PlatformString up to 255 characters+
amountThe amount for partial refund. Several partial refunds allowed.Numbers in the format XXXX.XX
Pay attention that amount format depends on currency exponent.
If exponent = 0, then amount is integer (without decimals). It used for currencies: CLP, VND, ISK, UGX, KRW, JPY.
If exponent = 3, then format: XXXX.XXX (with 3 decimals). It used for currencies: BHD, JOD, KWD, OMR, TND.
-
hashSpecial signature to validate your request to Payment PlatformSee Appendix A, Creditvoid signature.+

Response parameters

ParameterDescription
actionCREDITVOID
resultACCEPTED
order_idTransaction ID in the Client's system
trans_idTransaction ID in the Payment Platform

Callback parameters

Successful refund response

ParameterDescription
actionCREDITVOID
resultSUCCESS
statusREFUND (full refund) / SETTLED (partial refund)
order_idTransaction ID in the Client system
trans_idTransaction ID in the Payment Platform
creditvoid_dateDate of the refund/reversal
amountAmount of refund
hashSpecial signature, used to validate callback. See Appendix A, Creditvoid signature.

Unsuccessful refund response

ParameterDescription
actionCREDITVOID
resultDECLINED
order_idTransaction ID in the Client system
trans_idTransaction ID in the Payment Platform
decline_reasonDescription of the cancellation of the transaction
hashSpecial signature, used to validate callback. See Appendix A, Creditvoid signature.

GET_TRANS_STATUS request


Gets order status from Payment Platform. This request is sent by POST in the background (e.g., through PHP CURL).

Request parameters

ParameterDescriptionValuesRequired
actionGET_TRANS_STATUSGET_TRANS_STATUS+
client_keyUnique client key (CLIENT_KEY)+
trans_idTransaction ID in the Payment PlatformString up to 255 characters+
hashSpecial signature to validate your request to Payment PlatformSee Appendix A, GET_TRANS_STATUS signature+

Response parameters

ParameterDescription
actionGET_TRANS_STATUS
resultSUCCESS
statusDECLINED/SETTLED
order_idOrder ID in the Client’s system
trans_idTransaction ID in the Payment Platform
decline_reasonReason of transaction decline. It shows for the transactions with the “DECLINED” status

Errors


In case error you get synchronous response from Payment Platform:

ParameterDescription
resultERROR
error_messageError message

Appendix A


Hash is signature rule used either to validate your requests to payment platform or to validate callback from payment platform to your system. It must be md5 encoded string calculated by rules below:

Sale signature

Hash is calculated by the formula:

md5(strtoupper(strrev(identifier + order_id + order_amount + order_currency + PASSWORD)));

Creditvoid signature

Hash is calculated by the formula:

_md5(strtoupper(strrev(trans_id + PASSWORD)));

GET_TRANS_STATUS signature

$hash = md5(strtoupper(strrev($trans_id)) . $ PASSWORD);

Callback signature

Hash is calculated by the formula:

array_walk_recursive($params, static function (&$value) {
$value = strrev($value);
});
$params['hash'] = md5(strtoupper(convert($params) . PASSWORD));
function convert($params)
{
foreach ($params as &$value) {
if (is_array($value)) {
$value = $this->convert($value);
}
}
ksort($params);
return implode($params);
}