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

http://sandbox.hesabe.com/api/subscription/capture

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

https://api.hesabe.com/api/subscription/capture

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:

subscription-capture.php
    $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

FieldTypeDescriptionRequired
merchantCode
StringMerchant Code is a unique identifier generated by Hesabe for each activated merchantYes
amount
NumericTransaction amount to captureYes
orderReferenceNumber
StringOrder reference number for the transactionYes
paymentToken
AlphanumericPayment Token returned from the authorized subscription transactionYes

Response Details

The response will be encrypted and must be decrypted using Hesabe's decryption method.

Example Decrypted Response

success-response.json
{
  "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

FieldTypeDescription
transactionToken
AlphanumericUnique token identifying the transaction
amount
NumericCaptured transaction amount
orderReferenceNumber
StringOrder reference number
transactionStatus
StringStatus of the transaction (e.g., CAPTURED)
paymentType
StringPayment type identifier
datetime
StringDate and time of the transaction

Error Handling

Common errors you may encounter:

ErrorDescription
Invalid TokenToken provided is incorrect or expired
Invalid RequestRequest body not properly encrypted
Insufficient AuthorizationMissing or invalid accessCode

Example Error Response

error-response.json
{
  "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

Email address:itsupport@hesabe.com