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.

Apple Pay Direct Integration

Native checkout experience

Implement Apple Pay directly on your website without redirects. This premium integration provides a native Apple Pay experience that significantly increases conversion rates and delivers the seamless checkout experience customers expect

📋 Implementation Steps

Enable Apple Pay Payment Gateway Service With Hesabe

Request Support Team To Enable Payment Gateway Service With Apple Pay

Contact Hesabe Merchant Support Team:support@hesabe.com

Verfiy your domain with Hesabe Payment Gateway

Request domain whitelisting and Apple verification setup

Contact Hesabe IT Team:itsupport@hesabe.com

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

[MerchantWebsite]/.well-known/apple-developer-merchantid-domain-association.txt

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

https://sandbox.hesabe.com/checkout

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

https://api.hesabe.com/checkout
Checkout.php
$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.

FieldTypeDescriptionRequired
merchantCode
NumericAssigned by HesabeYes
amount
NumericAmount in currencyYes
currency
StringISO currency codeYes
responseUrl
AlphanumericRedirect URL on successYes
failureUrl
AlphanumericRedirect URL on failureYes
version
Alphanumeric2.0Yes
orderReferenceNumber
StringYour reference / order IDYes
paymentType
NumericRefer to the "List of apple pay payment types" section below for more informationYes
variable5
StringMerchant Domain Name as example.comYes

List of apple pay payment types

Below are the available apple pay payment method options supported by Hesabe

Payment TypesValue
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

FieldTypeDescriptionRequired
name
StringCustomer NameOptional
mobile_number
Numeric (8)Customer Mobile Number ( Without country code )Optional
email
StringCustomer Email AddressOptional
webhookUrl
StringYour endpoint for receiving payment statusOptional
variable1
AlphanumericCustom user parameter which will be included in the response when it returnsOptional
variable2
AlphanumericCustom user parameter which will be included in the response when it returnsOptional
variable3
AlphanumericCustom user parameter which will be included in the response when it returnsOptional
variable4
AlphanumericCustom user parameter which will be included in the response when it returnsOptional

Encrypt the Payload

Encrypt the payload using our encryption library, then post the encrypted payload to Hesabe’s checkout endpoint

Checkout.php
$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.

Checkout.php
$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:

Checkout.php
$baseUrl =  "http://sandbox.hesebe.com"; // Sandbox Endpoint
$hesabetoken= $responseDataJson->response->data;
Checkout.php
<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

https://developer.apple.com/design/human-interface-guidelines/apple-pay

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

Email address:itsupport@hesabe.com

🎯 Ready to Launch

🚀

Launch Your Integration

Transform your checkout experience
Instant Payments
Reduce cart abandonment with seamless one-touch payments
🔒Bank-Level Security
Built-in fraud protection and secure tokenization
📱Mobile Optimized
Perfect experience across all Apple devices

By implementing Apple Pay Direct Integration, you're providing customers with the premium checkout experience they expect, resulting in higher conversion rates and increased customer satisfaction.