---
updatedAt: 2025-09-09T21:12:12.000Z
agentTools:
  projectIndex: https://developer.paylink.sa/llms.txt
---

# JS & Apple Pay

Use this library to integrate Paylink payments into your app and grow your business with Paylink APIs to proceed with easy Payment and generate customer invoices.

## Step 1: SDK Initialization

Please ensure the [SDK Initialization steps](https://developer.paylink.sa/docs/java-script-sdk-initialization) are completed before proceeding with the following steps. This is crucial for the proper functioning of the payment process.

***

## Step 2: Opening ApplePay Payment Window

Call the **openApplePay** function to open the ApplePay payment window. It takes the generated "token" in the server-side and the "order" object.

```javascript
payment.openApplePay(token, order, successCallback);
```

The **openApplePay** function takes the following parameters:

| Parameters name | Description                                                            | value type          |
| :-------------- | :--------------------------------------------------------------------- | :------------------ |
| token           | The token is programmatically generated on the server side (Step 1).   | string              |
| order           | The order object for the new Invoice.                                  | Order object type   |
| successCallback | the callback function that will be called when the popup screen opens. | JavaScript function |

***

## Step 3: Handling Payment Process Response

Finally, from the server side, programmatically process the payment response sent by Paylink after the payment process finishes. This step is crucial for security reasons; carefully follow [Get Invoice](https://developer.paylink.sa/docs/get-invoice) to handle the payment result from Paylink.

***

> ❗️ Important
>
> * Merchant's application must call **GetInvoice** ([here](https://developer.paylink.sa/docs/get-invoice)) endpoint immediately after the payment from the server side. First, check the integrity of the price by checking the payment status "**orderStatus**" and the amount paid "**amount**".
> * Then proceed with the order processing of the client as paid or not. Otherwise, avoid using the endpoint **GetInvoice** and checking the amount and status will jeopardize the security of the payment.

***

## Sample Code

You can download a sample of the code written in PHP from [here](https://developer.paylink.sa/assets/downloads/paylinkpaymentdemo_sample.zip).