Capture Subscription
Capture payments for an active subscription transaction after the initial authorization, enabling flexible billing at any frequency or amount.
Capture Subscription Transaction
API Endpoint
Use the following API endpoint to capture a subscription payment:
Sandbox Capture API
Below capture API strictly for sandbox testing only. Never use these sandbox URL's in production environment
Production Capture API
Use the following capture API strictly for production transactions. Ensure that you never use these production URLs in the sandbox or testing environment
Authentication
- Requires Merchant Access Code in the request header.
- Requests must be encrypted using Hesabe's encryption method (same as Checkout API).
Request Details
Pass the following parameters in the encrypted request body:
$baseUrl = 'http://sandbox.hesabe.com/api/'; // sandbox
$captureApiUrl = "{$baseUrl}/subscription/capture";
$requestData = [
'merchantCode' => 842217,
'amount' => 10,
'orderReferenceNumber' => '1000',
'paymentToken' => '84221717315765789865847566756'
];
$encryptedData = HesabeCrypto::encrypt($requestData, $encryptionKey, $ivKey);
$checkoutRequestData = new Request([
'data' => $encryptedData
]);
$checkoutRequest = Request::create($captureApiUrl, 'POST', $checkoutRequestData->all());
$checkoutRequest->headers->set('accessCode', $accessCode);Request Parameters
| Field | Type | Description | Required |
|---|---|---|---|
merchantCode | String | Merchant Code is a unique identifier generated by Hesabe for each activated merchant | Yes |
amount | Numeric | Transaction amount to capture | Yes |
orderReferenceNumber | String | Order reference number for the transaction | Yes |
paymentToken | Alphanumeric | Payment Token returned from the authorized subscription transaction | Yes |
Response Details
The response will be encrypted and must be decrypted using Hesabe's decryption method.
Example Decrypted Response
{
"status": true,
"code": 200,
"message": "Capture successful.",
"data": {
"transactionToken": "84221717315765789865847566756",
"amount": "10.000",
"orderReferenceNumber": "1000",
"transactionStatus": "CAPTURED",
"paymentType": "15",
"datetime": "2024-11-25 12:15:30"
}
}Response Parameters
| Field | Type | Description |
|---|---|---|
transactionToken | Alphanumeric | Unique token identifying the transaction |
amount | Numeric | Captured transaction amount |
orderReferenceNumber | String | Order reference number |
transactionStatus | String | Status of the transaction (e.g., CAPTURED) |
paymentType | String | Payment type identifier |
datetime | String | Date and time of the transaction |
Error Handling
Common errors you may encounter:
| Error | Description |
|---|---|
| Invalid Token | Token provided is incorrect or expired |
| Invalid Request | Request body not properly encrypted |
| Insufficient Authorization | Missing or invalid accessCode |
Example Error Response
{
"status": false,
"code": 400,
"message": "Invalid token or subscription not found."
}For Any Technical Assistance
If you encounter any issues or need support during setup or integration, please contact our technical team for assistance.
Hesabe IT Support
Subscription Method
The Subscription Method allows merchants to set up and manage recurring payments seamlessly. It ensures automatic billing at regular intervals, reducing manual effort and improving payment consistency.
Cancel Subscription
Cancel an active subscription transaction upon customer request, deactivating it to prevent any further charges.