Order Page
Create the order page having the following fields
- orderid
- amount
- currency

Submit these field to payment page.
Payment Page
Create the payment page. In this page, get the data post from order page and encrypt the value to generate the token.

Add the the following php code at the top:
<?php function encryptValue($payload = array()) { $secret_key = 'YOUR_SECRET_KEY'; $string = preg_replace("/[^A-Za-z0-9 ]/", '', $secret_key); $encryption_key = substr($string, 0, 16); // Generate an initialization vector $iv = openssl_random_pseudo_bytes(16); // Ensure IV length is 16 bytes // Encrypt the data using AES 256 encryption in CBC mode using our encryption key and initialization vector. $encrypted = openssl_encrypt(array_implode_with_keys($payload), 'aes-256-cbc', $encryption_key, 0, $iv); // The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::) return base64_encode($encrypted . '::' . $iv); } function array_implode_with_keys($array) { $return = ''; if (count($array) > 0) { foreach ($array as $key => $value) { $return .= $key . '||' . $value . '__'; } $return = substr($return, 0, strlen($return) - 2); } return $return; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $data = $_POST; $publicKey = 'YOUR_PUBLIC_KEY'; // generate token $tokenPayload = [ 'orderid' => $data['orderid'], 'amount' => $data['amount'], 'currency' => $data['currency'], 'frictionless' => 'no' ]; $token = encryptValue($tokenPayload); // This is you generated token. } else { echo "Invalid Request." die; } ?>
<?php function encryptValue($payload = array()) { $secret_key = 'YOUR_SECRET_KEY'; $string = preg_replace("/[^A-Za-z0-9 ]/", '', $secret_key); $encryption_key = substr($string, 0, 16); // Generate an initialization vector $iv = openssl_random_pseudo_bytes(16); // Ensure IV length is 16 bytes // Encrypt the data using AES 256 encryption in CBC mode using our encryption key and initialization vector. $encrypted = openssl_encrypt(array_implode_with_keys($payload), 'aes-256-cbc', $encryption_key, 0, $iv); // The $iv is just as important as the key for decrypting, so save it with our encrypted data using a unique separator (::) return base64_encode($encrypted . '::' . $iv); } function array_implode_with_keys($array) { $return = ''; if (count($array) > 0) { foreach ($array as $key => $value) { $return .= $key . '||' . $value . '__'; } $return = substr($return, 0, strlen($return) - 2); } return $return; } if ($_SERVER['REQUEST_METHOD'] === 'POST') { $data = $_POST; $publicKey = 'YOUR_PUBLIC_KEY'; // generate token $tokenPayload = [ 'orderid' => $data['orderid'], 'amount' => $data['amount'], 'currency' => $data['currency'], 'frictionless' => 'no', // change value to yes to use frictionless 'success_url' => 'https://your_success.url', 'fail_url' => 'https://your_fail.url', 'notify_url' => 'https://your_notify.url']; ]; $token = encryptValue($tokenPayload); // This is you generated token. } else { echo "Invalid Request." die; } ?>
Add the the following javascript:
<script src="https://sandbox-api.paymentechnologies.co.uk/js/v2?form=paymentForm&token=YOUR_GENERATED_TOKEN&key=YOUR_PUBLIC_KEY"></script>
<script src="https://api.paymentechnologies.co.uk/js/v2?form=paymentForm&token=YOUR_GENERATED_TOKEN&key=YOUR_PUBLIC_KEY"></script>
<script>
console.log('PTv2 JS Loaded');
// Select a payment form element
const paymentForm = document.querySelector("#payment_form");
// Attach a payment submit event handler to payment form
paymentForm.addEventListener("submit", handlePaymentSubmit);
async function handlePaymentSubmit(e) {
e.preventDefault();
var data = {
firstname: document.getElementById("firstname").value,
lastname: document.getElementById("lastname").value,
email: document.getElementById("email").value,
phone: document.getElementById("phone").value,
street: document.getElementById("street").value,
city: document.getElementById("city").value,
state: document.getElementById("state").value,
country: document.getElementById("country").value,
zip: document.getElementById("zip").value,
ccn: document.getElementById("ccn").value,
card_exp: document.getElementById("card_exp").value,
cvc_code: document.getElementById("cvc_code").value
};
await paymentInitiate(data, function(error, response) {
if (error) {
console.error('Error index:', error);
} else {
console.log('Response index:', response);
if(response.status == 'redirect-required') {
window.location.href = response.response.redirect_url;
}else if(response.status == 'success') {
document.getElementById("success-payment-message").innerHTML = response.response.message;
document.getElementById("success-payment-message").classList.remove('d-none');
//document.getElementById("paymentForm").classList.add('hidden');
}else{
document.getElementById("error-payment-message").innerHTML = response.response.message;
document.getElementById("error-payment-message").classList.remove('d-none');
//document.getElementById("paymentForm").classList.add('hidden');
}
// You can perform further actions with the response here
}
});
}
</script>
NOTE: Name the form "payment_form"
Get Status
https://sandbox-api.paymentechnologies.co.uk/v2/transaction/get-status
https://api.paymentechnologies.co.uk/v2/transaction/get-status
Request
{
"authenticate_id": "string",
"authenticate_pw": "string",
"transaction_id": 0,
}
Response
{
"code": 200,
"status": "success",
"response": {
"transactionid": 10000000,
"status": "PROCESSING",
"descriptor": "",
"date": "2021-12-12 17:17:35",
"orderid": "11007070",
"amount": "1.00",
"currency": "eur",
"client_fullName": "Jhon Deo",
"client_email": "jhon@domain.com",
"first4digit": "4111",
"last4digit": "1111"
}
}
Refund
The Refund operation, as its name states, consists of returning the money already collected by a Payment transaction.
The amount collected can be refunded in total. You cannot refund amounts bigger than the one sent in the original transaction.
The signature is a checksum which helps paymenTechnologies to ensure the authenticity of the request, e.g. that it was actually sent by the client and was not tampered on the way from the client to our gateway. It contains a 40 character long hexadecimal value. The value is computed from transaction-specific parameters and a “secret”, according to the secure encryption algorithm, SHA-1. The “secret” will be given to you via email by the paymenTechnologies administration and must be kept secret. Please refer to docs for an in-depth explanation of how to calculate the signature. The signature field is mandatory and must be transmitted to the system with each request.
https://sandbox-api.paymentechnologies.co.uk/v2/refund
https://api.paymentechnologies.co.uk/v2/refund
Request
{
"amount": 0,
"authenticate_id": "string",
"authenticate_pw": "string",
"currency": "string",
"customerip": "string",
"transaction_id": 0,
"signature": "string"
}
Response
{
"code": 200,
"status": "success",
"response": {
"refundid": 100000,
"message": "Refund successfully",
"amount": "1.00",
"currency": "USD",
"transactionid": "200001"
}
}
Currencies Listing
paymenTechnologies gateway supports payments using Cryptocurrency. Merchants may sell goods or services in their desired Fiat currency but allow for payment using Cryptocurrencies. During the checkout process, if the customer has chosen crypto as their payment method, they will be presented with a QR code for the sale amount.
The QR code contains the amount payable (represented in the Cryptocurrency), and a link to the unique wallet address that the payment must be sent.
This 'CURRENCIES LISTING' API uses to get the listing of all the types of currencies that are available for Crypto transactions. All requests to the transaction platform must be made using POST requests over HTTPS in UTF-8.
https://sandbox-api.paymentechnologies.co.uk/v2/crypto/currencies
https://api.paymentechnologies.co.uk/v2/crypto/currencies
Request
{
"authenticate_id": "string",
"authenticate_pw": "string",
}
Response
{
"status": "success",
"data": [
{
"id": "BTC",
"name": "Bitcoin"
},
{
"id": "ETH",
"name": "Ethereum"
}
]
}