---
title: Apple Pay SDKs
slug: international-payments/apple-pay/sdks
excerpt: >-
  Learn how you can use our standalone SDKs to start accepting payments via
  Apple Pay.
hidden: false
sidebar_order: 5
metadata:
  title: Apple Pay SDK Integration – Pine Labs Payments
  description: >-
    The document provides a guide to integrating Apple Pay into an iOS app using
    a standalone SDK called ApplePaySDK.xcframework, detailing steps for backend
    API integration, SDK access, framework addition, payment option setup,
    delegate configuration, and payment data structure. Integrate Apple Pay
    using Pine Labs standalone SDK for mobile and web applications.
  image: []
  keywords: 'Apple Pay SDK, Standalone SDK'
  robots: index
---
Learn how you can integrate Apple Pay functionality directly to your iOS app without using the Pine Labs Payment SDK. We offer a lightweight, standalone SDK called ApplePaySDK.xcframework, which facilitates Apple Pay payments with minimal setup.

Follow the below steps to install the SDK.

1. [\[Prerequisite\] Integrate APIs in Your Backend](#integrate-api-in-backend)
   1. [Generate Token](#generate-token)
   2. [Create Order](#create-order)
2. [Get Access to the SDK](#get-access-to-sdk)
3. [Add the Framework to Your App](#add-famework)
4. [Add Apple Pay as a Payment Option](#add-apple-pay-as-payment-option)
5. [Delegate Setup](#delegate-setup)
6. [Payment Data Structure](#payment-data-structure)

***

<h2 id="integrate-api-in-backend">1. \[Prerequisite] Integrate APIs in Your Backend</h2>

Start a payment by triggering the payment flow. To start a payment, follow the below steps:

<h3 id="generate-token">1.1. Generate Token</h3>

Integrate our Generate Token API in your backend servers to generate the auth token. Use the token generated to authenticate Pine Labs Online APIs.

Below are the sample requests and response for the Generate Token API.

```curl cURL – UAT
curl --location 'https://pluraluat.v2.pinepg.in/api/auth/v1/token' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--data '
{
  "client_id": "a17ce30e-f88e-4f81-ada1-c3b4909ed232",
  "client_secret": "fgwei7egyhuggwp39w8rh",
  "grant_type": "client_credentials"
}
'
```
```curl cURL – PROD
curl --location 'https://api.pluralpay.in/api/auth/v1/token' \
--header 'accept: application/json' \
--header 'content-type: application/json' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--data '
{
  "client_id": "a17ce30e-f88e-4f81-ada1-c3b4909ed232",
  "client_secret": "fgwei7egyhuggwp39w8rh",
  "grant_type": "client_credentials"
}
'
```
```json Sample Response
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "expires_in": 3600
}
```

<GenerateToken />

Refer to our <a href="https://plcorp.uat.pinelabs.com/doc/online-payments/api/authentication/generate-token" >Generate Token API</a> documentation to learn more.

***

<h3 id="create-order">1.2. Create Order</h3>

To create an Order, use our Create Order API, for authentication use the generated access token in the headers of the API request.

Below are the sample requests and response for a Create Order API.

```curl cURL - UAT
curl --location 'https://pluraluat.v2.pinepg.in/api/pay/v1/orders' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json' \
--data '
{
  "order_amount": {
    "value": 250,
    "currency": "INR"
  },
  "purchase_details": {
    "customer": {
      "billing_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",,
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "billing"
      },
      "shipping_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",,
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "shipping"
      },
      "email_id": "joe.sam@gmail.com",
      "first_name": "Kevin",
      "last_name": "Smith",
      "mobile_number": "9876543210"
    },
    "merchant_metadata": {
      "key1": "val1",
      "key2": "val2"
    }
  },
  "pre_auth": false,
  "merchant_order_reference": "7bcd1b99-6d67-4c84-87dc-58e6a20a842d"
}
'
```
```curl cURL - PROD
curl --location 'https://api.pluralpay.in/api/pay/v1/orders' \
--header 'Authorization: Bearer {token}' \
--header 'Content-Type: application/json' \
--header 'Request-ID: c17ce30f-f88e-4f81-ada1-c3b4909ed235' \
--header 'Request-Timestamp: 2024-07-09T07:57:08.022Z' \
--header 'accept: application/json' \
--data '
{
  "order_amount": {
    "value": 250,
    "currency": "INR"
  },
  "purchase_details": {
    "customer": {
      "billing_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",,
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "billing"
      },
      "shipping_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",,
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "shipping"
      },
      "email_id": "joe.sam@gmail.com",
      "first_name": "Kevin",
      "last_name": "Smith",
      "mobile_number": "9876543210"
    },
    "merchant_metadata": {
      "key1": "val1",
      "key2": "val2"
    }
  },
  "pre_auth": false,
  "merchant_order_reference": "7bcd1b99-6d67-4c84-87dc-58e6a20a842d"
}
'
```
```json Sample Response
{
  "data": {
    "order_id": "v1-251111105815-aa-doqEsa",
    "merchant_order_reference": "7bcd1b99-6d67-4c84-87dc-58e6a20a842d",
    "type": "CHARGE",
    "status": "CREATED",
    "merchant_id": "108272",
    "order_amount": {
      "value": 250,
      "currency": "INR"
    },
    "pre_auth": false,
    "part_payment": false,
    "allowed_payment_methods": [
      "CARD"
    ],
    "purchase_details": {
      "customer": {
        "email_id": "joe.sam@gmail.com",
        "first_name": "Kevin",
        "last_name": "Smith",
        "customer_id": "cust-v1-251111105815-aa-wlYjLk",
        "mobile_number": "9876543210",
        "country_code": "91",
        "billing_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",,
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "billing"
      },
      "shipping_address": {
        "address1": "10 Downing Street Westminster London",
        "address2": "Oxford Street Westminster London",
        "address3": "Baker Street Westminster London",
        "pincode": "51524036",
        "city": "Westminster",
        "state": "Westminster",
        "country": "London",,
        "full_name": "Kevin Bob",
        "adddress_type": "Home",
        "address_category": "shipping"
      },
        "is_edit_customer_details_allowed": false,
        "status": "ACTIVE",
        "created_at": "2025-11-11T10:58:15.120478742Z",
        "updated_at": "2025-11-11T10:58:15.120486856Z"
      },
      "merchant_metadata": {
        "key1": "val1",
        "key2": "val2"
      }
    },
    "created_at": "2025-11-11T10:58:15.170Z",
    "updated_at": "2025-11-11T10:58:15.170Z",
    "integration_mode": "SEAMLESS",
    "payment_retries_remaining": 10,
    "is_mcc_transaction": false,
    "is_domestic_txn_for_risk_enabled": true,
    "order_token": "yup5t%2FwV8xE9QESj5MFhp6uqut4e2jK5QUmHJZeMjBM%3D"
  }
}
```

<CreateOrder />

Refer to our <a href="https://plcorp.uat.pinelabs.com/doc/online-payments/api/orders/create-order" >Create Order API</a> documentation to learn more.

***

<h2 id="get-access-to-sdk">2. Get Access to the SDK</h2>

To get the access to `ApplePaySDK`, please contact the Pine Labs Online integration team.

***

<h2 id="add-framework">3: Add the Framework to Your App</h2>

1. Drag and drop `ApplePaySDK.xcframework` into the file navigator of your Xcode project.
2. When prompted, make sure to:
   1. ✅ Check “Copy items if needed”
   2. ✅ Add to your app target
3. Open the General tab of your app target.
4. Under Frameworks, Libraries, and Embedded Content, ensure that `ApplePaySDK.xcframework` is set to **Embed & Sign**.

Once you have added the SDK, you can import it into your Swift files by using the below command.

```
import ApplePaySDK
```

***

<h2 id="add-apple-pay-as-payment-option">4. Add Apple Pay as a Payment Option</h2>

Below is an example showing how to start an Apple Pay payment using our SDK.

```swift
import UIKit
import PassKit
import ApplePaySDK

class ViewController: UIViewController, ApplePayHandlerDelegate {
    private var applePayHandler: ApplePayHandler!

    override func viewDidLoad() {
        super.viewDidLoad()

        let paymentData: [String: Any] = [
            "paymentAmount": 50000, // ₹500.00
            "currency": "INR",
            "merchantDisplayName": "Test Merchant"
        ]

        applePayHandler = ApplePayHandler(
            appleMerchantID: "merchant.com.test.applepay",
            orderToken: "sample-order-token",
            paymentData: paymentData
        )
        applePayHandler.delegate = self

        if applePayHandler.checkApplePayAvailability() {
            let button = PKPaymentButton(paymentButtonType: .buy, paymentButtonStyle: .black)
            button.addTarget(self, action: #selector(applePayTapped), for: .touchUpInside)
            button.center = view.center
            view.addSubview(button)
        } else {
            print("Apple Pay not available on this device")
        }
    }

    @objc func applePayTapped() {
        applePayHandler.onApplePayButtonClicked(from: self)
    }

    func applePayDidFinish(success: Bool, error: Error?) {
        print("Apple Pay Finished: success=\(success), error=\(String(describing: error))")
    }
}

```

> 📘 Note:
>
> - You can customize the appearance of the Apple Pay button by modifying the parameters in the following line of code.
> - Apple allows only limited customization options for the Apple Pay button’s style and type.

```swift
let button = PKPaymentButton(paymentButtonType: .buy, paymentButtonStyle: .black)
```

Refer to the <a href="https://developer.apple.com/design/human-interface-guidelines/apple-pay#Button-types" target="_blank">Apple Pay Button Customization</a> documentation for more details.

***

<h2 id="delegate-setup">5. Delegate Setup</h2>

The SDK provides a delegate protocol — ApplePayHandlerDelegate — which notifies your view controller about the status of an Apple Pay transaction.

```swift
func applePayDidFinish(success: Bool, error: Error?)
```

This method is triggered when an Apple Pay transaction completes, indicating whether it was successful or if an error occurred.

Ensure that your view controller conforms to this delegate protocol to properly handle and respond to payment outcomes.

***

<h2 id="payment-data-structure">6. Payment Data Structure</h2>

The `paymentData` dictionary must include key payment parameters required to initiate a transaction.

Below is the minimal structure used in the example:

```swift
let paymentData: [String: Any] = [
    "paymentAmount": 50000,  // Amount in paise (₹500.00)
    "currency": "INR",
    "merchantDisplayName": "Test Merchant"
]
```

You can also include additional fields if they are available from your payment initialization response:

```swift
let paymentAmount = fetchResponse?.paymentData?.paymentAmount?.amount ?? 0.00
let currency = fetchResponse?.paymentData?.paymentAmount?.currency ?? "INR"
let merchantId = fetchResponse?.merchantInfo?.merchantId ?? 0
let displayName = fetchResponse?.merchantInfo?.merchantDisplayName ?? "Display Name"
let mobileNo = fetchResponse?.customerInfo?.mobileNo ?? ""
let emailId = fetchResponse?.customerInfo?.emailId ?? ""
let applePayMID = fetchResponse?.merchantInfo?.applePayMerchantIdentifier ?? ""

let paymentData: [String: Any] = [
    "paymentAmount": paymentAmount,
    "currency": currency,
    "merchantId": merchantId,
    "merchantDisplayName": displayName,
    "mobileNo": mobileNo,
    "emailId": emailId
]

```

***

### Reference: Public Methods

The SDK exposes two primary public methods for initializing and handling payments.

`checkApplePayAvailability() -> Bool`

Determines whether Apple Pay is supported and available on the user’s device.

- **Returns**: `true` if Apple Pay is supported and the device has at least one eligible card added.

***

`onApplePayButtonClicked(from viewController: UIViewController)`

This is the primary method that triggers the Apple Pay payment flow. It:

1. Builds a `PKPaymentRequest` using the provided order details.
2. Presents the `PKPaymentAuthorizationController` to the user.
3. Handles merchant validation, payment processing, and authorization steps.
4. Notifies the delegate with the transaction’s success or failure status.

#### Delegate Protocol

```swift
public protocol ApplePayHandlerDelegate: AnyObject {
    func applePayDidFinish(success: Bool, error: Error?)
}
```

The delegate method is called when the Apple Pay transaction completes—either successfully or with an error—allowing the app to handle post-payment logic accordingly.

***
