Direct Apple Pay Integration
π Implementation Stepsβ
Contact Hesabe IT Team
Request domain whitelisting and Apple verification setup:
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:
[MerchantWebsite]/.well-known/apple-developer-merchantid-domain-association.txt
Create a Checkout Request
Send a checkout request with the required parameters following Hesabe's API guidelines.
π API Parametersβ
π» 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);
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";
$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:
Add ID Attribute
Ensure the Apple Pay button has an ID attribute assigned to it for proper initialization.
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.