Pay Buttons
The Virtual Terminal can be used to generate links within the MMS Platform or they can be generated via a request to the Gateway. Processing Pay Button requests requires knowledge of server-side scripting languages, such as PHP, ASP, Java, etc.
The following details allow you to have full control over what information is passed to our Gateway via the Pay Button using the list of Hosted Integration fields outlined in Request Fields.
Please be aware that data retention is the responsibility of the Merchant. This includes prefilled personal data in the details section, such as name/address, as this will be visible to anyone who views the payment page. It is recommended that if you do include personal data, then you should only share the generated Pay Button with the person whose data you have included and not reuse it for anyone else. Adding a Pay Button expiry date helps to ensure data is not stored for longer than necessary.
Pre-Requisites
| Merchant ID | Your Gateway Merchant Account ID. | |
| Integration URL | <gatewayUrl>button/{data} Generated using your unique Integration URL | |
| Signature Key | Configured value on the specified Merchant used in signing requests to the Gateway. |
Gateway Request
To create the button request, any fields valid in a Hosted Integration HTTP Request may be used, with the addition of the fields documented below. This request must be first URL encoded as documented in Section 1.7.1 of the Gateway Integration Guide and then Base64URL encoded to provide the final button data. This button data can optionally be compressed using the DEFLATE algorithm to make any final URL shorter.
The resultant encoded data is appended to your Gateway URL as indicated by <data> to provide the final URL which can be used as the 'href' attribute's value in a web link to open the Gateway's Hosted Payment Page. For example:
<a href="https://<gatewayUrl>button/<data>" target="_blank">Pay Online</a>.
Pay Button Optional Request Fields
| Field Name | Description |
|---|---|
| redirectURLFail | An alternative redirectURL to redirect the Customer's browser to on completion of an unsuccessful transaction. If not provided then the redirectURL will be used for both successful and unsuccessful transactions as documented in Section 1.7.6 of the Gateway Integration Guide. |
| buttonExpiry | The date the Pay Button link will expire. If the Pay Button request includes this field and is submitted after the date specified, the transaction will be aborted. |
Example Request Code
The following is an example test request built in PHP. (Use your Merchant test MID, Signature Key, and GatewayURL in place of the example details below):
<?php
function createSignature(array $data, $key, $algo = null) {
if ($algo === null) {
$algo = 'SHA512';
}
ksort($data);
// Create the URL encoded signature string
$ret = http_build_query($data, '', '&');
// Normalise all line endings (CRNL|NLCR|NL|CR) to just NL (%0A)
$ret = preg_replace('/%0D%0A|%0A%0D|%0A|%0D/i','%0A', $ret);
// Hash the signature string and the key together
$ret = hash($algo, $ret . $key);
// Prefix the algorithm if not the default
if ($algo !== 'SHA512') {
$ret = '{' . $algo . '}' . $ret;
}
return $ret;
}
If (!isset($_GET['payment_response'])) {
$gateway_url = 'https://gateway.example.com/button/';
$signature_key = 'examplesignature;
$fields = array(
'merchantID' => examplemid,
'amount' => 1100,
'action' => 'SALE',
'type' => 1,
'countryCode' => 'GB',
'currencyCode' => 'GBP',
'transactionUnique' => uniqid(),
'orderRef' => 'XXXXXX Payments',
'redirectURL' => ($_SERVER['HTTPS'] == 'on' ? 'https' : 'http') .
'://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . '?payment_response',
);
$fields['signature'] = createSignature($fields, $signature_key);
//Convert array to Query String
$link = http_build_query($fields);
$link = gzdeflate($link, 9);
//Base64 encode the string and remove any padding or invalid
//URL characters including =,+,/,
$link = strtr(trim(base64_encode($link), '='), '+/', '-_');
echo $link = $gateway_url . $link;
echo "<p><a href='{$link}'>Pay Now</a></p>";
} else if (isset($_GET['payment_response'])){
//Handle the response
echo '<h1>Response from hosted form</h1>';
print_r($_POST);
}
?>