The Sale API allows the merchant to fully control the flow over the entire payment process allowing the merchant to provide a unique experience by designing their own payments page while also handling the payments process.
Making The Request
HTTP is used as the request-response protocol between a merchants site and the ABPAY API. In the back end, a merchant submits a HTTP POST request to the ABPAY server, the server will then return an JSON document where the merchant must then cater for the action listed, which could be either 3D Secure, Declined or A Successful Transaction. The response contains key information about the request and also contains the requested content.
The request string that is sent for the `Sale` call must be composed of the following information:
1. username = someName
2. password = somePassword
3. messageID = *GUID (e.g. f8caeef6-0b5f-4044-bc3f-3514f52fd8d2)
4. APISignature = Register
5. data = Form data in JSON format
The above parameters are required when sending HTTP POST data to our API in order to receive a successful response. The data parameter must be composed of the collected information the merchant gathered from the customer while using our Available Form Data fields.
Sample `Sale` Request
<?php
function httpPost($url, $params) //Post method
{
$params = json_encode($params); //Convert array of params into json string
$ch = curl_init($url); //create a new cURL resource
//set appropriate options
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER ,array(
"Content-Type: application/json"
);
$response = curl_exec($ch); //grab URL and pass it to the browser while assigning the response to `$response`
curl_close($ch); //close cURL resource, and free up system resources
return $response;
}
$APIURL = "http://acquirer-stage.myabpay.com/merchant/service"; //Set API URL to ABPAY staging environment
$params = array(
"APISignature" => "sale", //API Signature
"messageID" => GUID(), //A new GUID is required for every new API Call
"username" => "tester", //API Username
"password" => "testsersystem", //API Password
"data" => array(
"amount" => "5200",
"cardType" => "Debit",
"cardnumber" => "4120000000000001",
"cardName" => "Mark hile",
"cardCVV" => "255",
"cardMonth" => "12",
"cardYear" => "2020",
"transactionCode" => "A2tcj25lfz5tUuFgdh",
"currency" => "GBP",
"ipaddress" => "124.133.0.1",
"agentHeader" => "Mozilla/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)",
) //Data fields required for request "sale" API
);
$response= httpPost($APIURL, $params); //User defined function used to POST data to API and assign the response to `$response` variable
echo $response;
// More code...
?>
Sample `Sale` JSON Document
The below sample demonstrates what is expected when passing POST data into the data parameter. When forming the data parameter, please refer to our guidelines above.
{
"amount": "5200",
"cardType": "Debit",
"cardnumber": "4120000000000001",
"cardName": "Mark hile",
"cardCVV": "255",
"cardMonth": "12",
"cardYear": "2020",
"transactionCode": "A2tcj25lfz5tUuFgdh",
"currency": "GBP",
"ipaddress": "124.133.0.1",
"agentHeader": "Mozilla\/4.0 (compatible; Win32; WinHttp.WinHttpRequest.5)"
}