Void Authorization
After a card payment has been authorized, the payment is not complete until it has been captured. If you do not wish to capture the payment, you can void it using the void API as described.
The Request
Use the details below to set up your request.
Endpoints
Live
POST https://paymentservices.payfort.com/FortAPI/paymentApi
Sandbox
POST https://sbpaymentservices.payfort.com/FortAPI/paymentApi
The Request Example
Check out the request parameters by visiting this link
Sample Request
Here are the sample request you are required to send authorizing a purchase.
error_reporting(E_ALL);
ini_set('display_errors', '1');
$url = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';
$arrData = array(
'command' => 'VOID_AUTHORIZATION',
'access_code' => 'zx0IPmPy5jp1vAz8Kpg7',
'merchant_identifier' => 'CycHZxVj',
'merchant_reference' => 'XYZ9239-yu898',
'language' => 'en',
'signature' => '7cad05f0212ed933c9a5d5dffa31661acf2c827a',
'order_description' => 'iPhone 6-S',
);
$ch = curl_init( $url );
# Setup request to send json via POST.
$data = json_encode($arrData);
curl_setopt( $ch, CURLOPT_POSTFIELDS, $data );
curl_setopt( $ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));
# Return response instead of printing.
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);
# Print response.
echo "<pre>$result</pre>";
import urllib
import urllib2
import json
url = 'https://sbpaymentservices.payfort.com/FortAPI/paymentApi';
arrData = {
'command':'VOID_AUTHORIZATION',
'access_code':'zx0IPmPy5jp1vAz8Kpg7',
'merchant_identifier':'CycHZxVj',
'merchant_reference':'XYZ9239-yu898',
'language':'en',
'signature':'7cad05f0212ed933c9a5d5dffa31661acf2c827a',
'order_description':'iPhone 6-S',
};
values = json.dumps(arrData)
data = urllib.urlencode(values)
req = urllib2.Request(url, data)
response = urllib2.urlopen(req)
page = response.read()
print page + '\n\n'
require 'json'
require 'net/http'
require 'net/https'
require 'uri'
require 'openssl'
arrData = {
'command' => 'VOID_AUTHORIZATION',
'access_code' => 'zx0IPmPy5jp1vAz8Kpg7',
'merchant_identifier' => 'CycHZxVj',
'merchant_reference' => 'XYZ9239-yu898',
'language' => 'en',
'signature' => '7cad05f0212ed933c9a5d5dffa31661acf2c827a',
'order_description' => 'iPhone 6-S',
};
arrData = arrData.to_json
uri = URI.parse("https://sbpaymentservices.payfort.com/FortAPI/paymentApi")
http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
request = Net::HTTP::Post.new("/v1.1/auth")
request.add_field('Content-Type', 'application/json')
request.body = arrData
response = http.request(request)
String jsonRequestString = "{\"command\" : \"VOID_AUTHORIZATION\" , "
+ "\"access_code\" : \"zx0IPmPy5jp1vAz8Kpg7\", \"merchant_identifier\" : \"CycHZxVj\", \"merchant_reference\" : \"XYZ9239-yu898\","
+ "\"language\" : \"en\", \"signature\" : \"7cad05f0212ed933c9a5d5dffa31661acf2c827a\", "
+ "\"order_description\" : \"iPhone 6-S\"}";
// Define and Initialize HttpClient
HttpClient httpClient = HttpClientBuilder.create().build();
// Intialize HttpPOST with FORT Payment services URL
HttpPost request = new HttpPost("https://sbpaymentservices.payfort.com/FortAPI/paymentApi");
// Setup Http POST entity with JSON String
StringEntity params = new StringEntity(jsonRequestString);
// Setup request type as JSON
request.addHeader("content-type", "application/json");
request.setEntity(params);
// Post request to FORT
HttpResponse response = httpClient.execute(request);
// Read response using StringBuilder
StringBuilder sb = new StringBuilder();
BufferedReader reader = new BufferedReader(new InputStreamReader(
response.getEntity().getContent()), 65728);
String line = null;
while ((line = reader.readLine()) != null) {
sb.append(line);
}
// Print response
System.out.println(sb.toString());
curl -H "Content-Type: application/json" -d
'{"command":"VOID_AUTHORIZATION",
"access_code":"zx0IPmPy5jp1vAz8Kpg7",
"merchant_identifier":"CycHZxVj",
merchant_reference":"XYZ9239-yu898",
"language":"en",
"signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a",
"order_description":"iPhone6-S"}'
https://sbpaymentservices.payfort.com/FortAPI/paymentApi
The Response
If you receive response code 20064
with status code 04
it means that your request to void authorization has been accepted by PayFort server.
Response Example
json
{"command":"VOID_AUTHORIZATION",
"access_code":"zx0IPmPy5jp1vAz8Kpg7",
"merchant_identifier":"CycHZxVj",
"merchant_reference":"XYZ9239yu898",
"language":"en",
"signature":"7cad05f0212ed933c9a5d5dffa31661acf2c827a",
"order_description":"iPhone6-S",
"fort_id":"149295435400084008",
"response_message":"Success",
"response_code":"20064",
"status":"04"
}
You can check out various transaction codes by visiting this link
Go to Full API
Check out our full API by visiting this link
Need further help?
Thanks for using PayFort.com. If you need any help or support, then message our support team at support@payfort.com.