Authorize / Capture Request
🔄 Authorize / Capture
⚠️Important Note
Authorize and Capture features are only available with the MPGS payment gateway service.
🔒
Two-Step Payment Process
The Authorize/Capture payment flow is a two-step process that allows merchants to authorize a transaction first (ensuring funds availability) and capture the funds later when ready to deliver the service or product.
🎯 Authorize Transaction Request
To authorize a transaction, include the following parameter in the checkout request:
🔐authorize: Boolean flag to indicate authorization
Authorize Transaction Request
To authorized transaction, send a POST request with the following parameters:
Capture Transaction Request
To capture the authorized transaction, send a POST request with the following parameters:
Sample PHP Code for capture:
$baseUrl = 'http://sandbox.hesabe.com/api/'; // sandbox
$captureApiUrl = $baseUrl . 'capture';
$requestData = [
'merchantCode' => 842217,
'amount' => 10,
'paymentToken' => '84221717175011419773484853173'
];
$encryptedData = HesabeCrypto::encrypt($requestData, $encryptionKey, $ivKey);
$checkoutRequestData = new Request([
'data' => $encryptedData
]);
$checkoutRequest = Request::create($captureApiUrl, 'POST', $checkoutRequestData->all());
$checkoutRequest->headers->set('accessCode', $accessCode);
Response sample for capture
{
"status": true,
"message": "Your refund request is waiting for approval",
"data": {
"token": "521042117249344539468767555844",
"amount": "1.000",
"order_reference_number": "1724934434",
"transaction_status": "SUCCESSFUL",
"refund_status": "PENDING",
"payment_type": "KNET",
"service_type": "Payment Gateway",
"transaction_datetime": "2024-08-29 15:27:38",
"refund_requested_at": "2024-09-04 15:04:44"
}
}
Cancel Authorized Transaction
To cancel the Authorized transaction for further Capturing the Amount.
$baseUrl = 'http://sandbox.hesebe.com/api/' // sandbox
$CancelApiUrl = {{$baseUrl}}/cancel/{paymentToken}
$checkoutRequest = Request::create($CaptureApiUrl, 'DELETE');
$checkoutRequest->headers->set('accessCode', $accessCode);