Skip to main content

Direct Apple Pay Integration

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​

1

Contact Hesabe IT Team

Request domain whitelisting and Apple verification setup:

πŸ“§Contact:itsupport@hesabe.com

Request to whitelist your merchant domain for Apple Pay integration

βœ… Once whitelisted, Hesabe will provide an Apple Domain Verification Value

🎯 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
2

Create a Checkout Request

Send a checkout request with the required parameters following Hesabe's API guidelines.

πŸ“Š API Parameters​

🏷️ ParameterπŸ“ DescriptionRequiredType/Length
amountAmount must be greater than zeroYesNumeric
responseUrlWebpay will be redirected back to this URL after payment completesYesAlphanumeric [200]
failureUrlWebpay will be redirected back to this URL after payment is declinedYesAlphanumeric [200]
merchantCodeMerchant Code is a unique identifier generated by Hesabe for each activated merchantYesNumeric
access_codeAccess code is used to revalidate a Merchant. To be used only for Indirect IntegrationYesAlphanumeric [32]
paymentTypePayment Type: 9 - ApplePay-Visa/Master, 11 - ApplePay-KnetYesNumeric
versionVersion of the API (example: 2.0)YesAlphanumeric [10]
variable1Custom user parameter which will be included in the response when it returns OptionalAlphanumeric [100]
variable2Custom user parameter which will be included in the response when it returns OptionalAlphanumeric [100]
variable3Custom user parameter which will be included in the response when it returns OptionalAlphanumeric [100]
variable4Custom user parameter which will be included in the response when it returns OptionalAlphanumeric [100]
variable5Merchant Domain Name as example.comYesValid Domain

πŸ’» Code Implementation Example​

$baseUrl =  "http://sandbox.hesebe.com/api/";
$CaptureApiUrl = "{$baseUrl}/checkout";
$requestData = [
"merchantCode" => "842217",
"amount" => "2",
"serviceTypeId" => "3",
"paymentType" => "9",
"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",
"description" => "authorize transaction",
"name" => "customername",
"email" => "customeremail@gmail.com",
"mobile_number" => "98758889",
"variable1" => "First__variable",
"variable2" => "Second__variable",
"variable3" => "Third__variable",
"variable4" => "forth__variable",
"variable5" => "example.com"
];

$encryptedData = HesabeCrypto::encrypt($requestData, $encryptionKey, $ivKey);
$checkoutRequestData = new Request([
'data' => $encryptedData
]);

$checkoutRequest = Request::create($CaptureApiUrl, 'POST', $checkoutRequestData->all());
$checkoutRequest->headers->set('accessCode', $accessCode);
3

Decrypt the Response

Decrypt the response returned from the checkout request using the same encryption library used for encryption during the request.

Example Response Decryption:
$checkoutResponse = Route::dispatch($checkoutRequest);
$checkoutResponseContent = $checkoutResponse->content();
$decryptedResponse = HesabeCrypto::decrypt($checkoutResponseContent, $encryptionKey, $ivKey);
$responseDataJson = json_decode($decryptedResponse);
4

Invoke Hesabe Apple Pay Script

Add the Apple Pay SDK and Hesabe script to your checkout/payment page:

Required Scripts:
$baseUrl =  "http://sandbox.hesebe.com";
$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>
5

Set Up the Apple Pay Button

Add an Apple Pay button to your checkout page following official Apple guidelines:

πŸ“–Reference:Apple Pay Design Guidelines
6

Add ID Attribute

Ensure the Apple Pay button has an ID attribute assigned to it for proper initialization.

7

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.

🎯 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.