Direct Apple Pay
This comprehensive guide will help you integrate your application or platform with Hesabe's Payment Gateway API, supporting multiple integration methods and advanced features.
📋 Implementation Steps
Enable Apple Pay Payment Gateway Service With Hesabe
Request Support Team To Enable Payment Gateway Service With Apple Pay
Verfiy your domain with Hesabe Payment Gateway
Request domain whitelisting and Apple verification setup
Once whitelisted, Hesabe will provide an Apple Domain Verification File
This file needs to be added on your website’s hosting server in the following path:
Domain Verification File Path
Create a Checkout Request
Send the encrypted data to Hesabe's checkout API endpoint with proper headers including the access code.
Pre-requisites Setup
You can follow the Checkout Setup guide to get started.
Hesabe Request Handler
You can follow the Hesabe Request Handler guide to get started.
NPM Package Available
A lightweight, framework-agnostic javaScript library for apple pay integration through the Hesabe payment gateway, works with React, Vue, Angular, or vanilla JavaScript.
Please refere npm package details here Hesabe Apple Pay Direct
Sandbox Checkout API
Below Checkout API strictly for sandbox testing only. Never use these sandbox URL's in production environment
Production Checkout API
Use the following Checkout API strictly for production transactions. Ensure that you never use these production URLs in the sandbox or testing environment
$baseUrl = "http://sandbox.hesebe.com/api/";
$CheckoutApiUrl = "{$baseUrl}/checkout";
$requestData = [
"merchantCode" => "842217",
"amount" => "2",
"paymentType" => "9", // Refer to the "List of apple pay payment types" section below for more information
"responseUrl" => "https://sandbox.hesabe.com/customer-response?id=842217",
"failureUrl" => "https://sandbox.hesabe.com/customer-response?id=842217",
"version" => "2.0",
"orderReferenceNumber" => "9874659805",
"currency" => "KWD",
"name" => "customername",
"email" => "customeremail@gmail.com",
"mobile_number" => "66666666",
"variable1" => "First__variable",
"variable2" => "Second__variable",
"variable3" => "Third__variable",
"variable4" => "forth__variable",
"variable5" => "example.com",
"webhookUrl" => 'https://yourdomain.com/example'
]; Read more about Hesabe Webhook URL
You can follow the Hesabe Webhook Request guide to get started.
| Field | Type | Description | Required |
|---|---|---|---|
merchantCode | Numeric | Assigned by Hesabe | Yes |
amount | Numeric | Amount in currency | Yes |
currency | String | ISO currency code | Yes |
responseUrl | Alphanumeric | Redirect URL on success | Yes |
failureUrl | Alphanumeric | Redirect URL on failure | Yes |
version | Alphanumeric | 2.0 | Yes |
orderReferenceNumber | String | Your reference / order ID | Yes |
paymentType | Numeric | Refer to the "List of apple pay payment types" section below for more information | Yes |
variable5 | String | Merchant Domain Name as example.com | Yes |
List of apple pay payment types
Below are the available apple pay payment method options supported by Hesabe
| Payment Types | Value |
|---|---|
| MPGS Apple Pay | "9" |
| CYBS Apple Pay | "10" |
| KNET Debit Apple Pay | "11" |
| KNET Credit Apple Pay | "12" |
| KNET Apple Pay International | "13" |
| AMEX Apple Pay International | "14" |
Additional Checkout API Parameters
Optional parameters that allow you to include extra data or customize the checkout flow in your API request
| Field | Type | Description | Required |
|---|---|---|---|
name | String | Customer Name | Optional |
mobile_number | Numeric (8) | Customer Mobile Number ( Without country code ) | Optional |
email | String | Customer Email Address | Optional |
webhookUrl | String | Your endpoint for receiving payment status | Optional |
variable1 | Alphanumeric | Custom user parameter which will be included in the response when it returns | Optional |
variable2 | Alphanumeric | Custom user parameter which will be included in the response when it returns | Optional |
variable3 | Alphanumeric | Custom user parameter which will be included in the response when it returns | Optional |
variable4 | Alphanumeric | Custom user parameter which will be included in the response when it returns | Optional |
Encrypt the Payload
Encrypt the payload using our encryption library, then post the encrypted payload to Hesabe’s checkout endpoint
$encryptedData = HesabeCrypto::encrypt($requestData, $encryptionKey, $ivKey);
$checkoutRequestData = new Request([
'data' => $encryptedData
]);
$checkoutRequest = Request::create($CheckoutApiUrl, 'POST', $checkoutRequestData->all());
$checkoutRequest->headers->set('accessCode', $accessCode);Decrypt the Response
Decrypt the response returned from the checkout request using the same encryption library used for encryption during the request.
$checkoutResponse = Route::dispatch($checkoutRequest);
$checkoutResponseContent = $checkoutResponse->content();
$decryptedResponse = HesabeCrypto::decrypt($checkoutResponseContent, $encryptionKey, $ivKey);
$responseDataJson = json_decode($decryptedResponse);Invoke Hesabe Apple Pay Script
Add the Apple Pay SDK and Hesabe script to your checkout/payment page:
$baseUrl = "http://sandbox.hesebe.com"; // Sandbox Endpoint
$hesabetoken= $responseDataJson->response->data;<script src="https://applepay.cdn-apple.com/jsapi/v1/apple-pay-sdk.js"></script>
<script src="{$baseUrl}/applepay?data={$hesabetoken}"></script>Set Up the Apple Pay Button
Add an Apple Pay button to your checkout page following official Apple guidelines:
Apple Pay Design Guidelines
Apple Pay Initialization
The Apple Pay button will only be displayed and functional on Apple Pay-capable devices. Ensure your code handles this condition appropriately.
Add ID Attribute
Ensure the Apple Pay button has an ID attribute assigned to it for proper initialization.
<button id="apple-pay-btn" onclick="handleApplePayClick()">
Pay with Apple Pay
</button>Apple Pay setup completed!
Please ensure that the Apple Pay functionality is working correctly.
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
🎯 Ready to Launch
In-Direct Payment Method
Customers are redirected to Hesabe's secure payment gateway landing page where they can select their preferred payment method. This method offers quick implementation with automatic security handling.
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.
