Apple Pay SDK (Standalone)

Learn how you can use our standalone sdks to start accepting payments via Apple pay.

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
    1. Generate Token
    2. Create Order
  2. Get Access to the SDK
  3. Add the Framework to Your App
  4. Add Apple Pay as a Payment Option
  5. Delegate Setup
  6. Payment Data Structure

1. [Prerequisite] Integrate APIs in Your Backend

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

1.1. Generate Token

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 --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 --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"
}
'
{
  "access_token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.SflKxwRJSMeKKF2QT4fwpMeJf36POk6yJV_adQssw5c",
  "expires_in": 3600
}
Click here for request and response parameter information.
Request Parameters
Response Parameters

The table below lists the request parameters of our Generate Token API.

Parameter Type Description
client_id required string Unique client identifier in the Pine Labs Online database.

Example: a17ce30e-f88e-4f81-ada1-c3b4909ed232

Note: The Onboarding team has provided you with this information as part of the onboarding process.
client_secret required string Unique client secret key provided while onboarding.

Example: fgwei7egyhuggwp39w8rh

Note: The Onboarding team has provided you with this information as part of the onboarding process.
grant_type required string The grant type to generate an access token.

Accepted value: client_credentials

The table below lists the response parameters of our Generate Token API.

Parameter Type Description
access_token string The access token generated by the system.

• Minimum length: 1 character.
• Maximum length: 8192 characters.

Example: eyJhbGciOiJIUzI1NiIsIn

Note: Use this token in the authorization headers to authenticate Pine Labs Online APIs.
expires_at string Access duration timestamp.

Example: 2024-06-28T13:26:06.909140Z

Refer to our Generate Token API documentation to learn more.


1.2. Create Order

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 --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": "H.No 15, Sector 17",
        "pincode": "51524036",
        "city": "Chandigarh",
        "state": "Punjab",
        "country": "India"
      },
      "shipping_address": {
        "address1": "H.No 15, Sector 17",
        "pincode": "51524036",
        "city": "Chandigarh",
        "state": "Punjab",
        "country": "India"
      },
      "email_id": "[email protected]",
      "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 --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": "H.No 15, Sector 17",
        "pincode": "51524036",
        "city": "Chandigarh",
        "state": "Punjab",
        "country": "India"
      },
      "shipping_address": {
        "address1": "H.No 15, Sector 17",
        "pincode": "51524036",
        "city": "Chandigarh",
        "state": "Punjab",
        "country": "India"
      },
      "email_id": "[email protected]",
      "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"
}
'
{
  "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": "[email protected]",
        "first_name": "Kevin",
        "last_name": "Smith",
        "customer_id": "cust-v1-251111105815-aa-wlYjLk",
        "mobile_number": "9876543210",
        "country_code": "91",
        "billing_address": {
          "address1": "H.No 15, Sector 17",
          "pincode": "51524036",
          "city": "Chandigarh",
          "state": "Punjab",
          "country": "India"
        },
        "shipping_address": {
          "address1": "H.No 15, Sector 17",
          "pincode": "51524036",
          "city": "Chandigarh",
          "state": "Punjab",
          "country": "India"
        },
        "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"
  }
}
Click here for request and response parameter information.
Request Parameters
Response Parameters

The table below lists the request parameters of our create order API.

Parameter Type Description
merchant_order_reference required string Enter a unique identifier for the order request.

  • Minimum: 1 character.
  • Maximum: 50 characters.
Example: 1234567890

Supported characters:
  • A-Z
  • a-z
  • 0-9
  • -
  • _
order_amount required object An object that contains the transaction amount details.

Learn more about the order_amount child object.
pre_auth boolean The pre-authorization type.

Possible values:
  • false (default): When pre-authorization is not required.
  • true: When pre-authorization is needed.
allowed_payment_methods array of strings The type of payment methods you want to offer customers.

Accepted values:
  • CARD
  • UPI
  • POINTS
  • NETBANKING
  • WALLET
  • CREDIT_EMI
  • DEBIT_EMI
Example: CARD

Note: Before selecting a payment method, ensure it is configured for you.
notes string Note to show against an order.

Example: Order1
callback_url string URL to redirect customers based on order details.

Example: https://sample-callback-url
purchase_details object An object that contains purchase details.

Learn more about the purchase_details child object.

Order Amount [Child Object]

The table below lists the various parameters in the order_amount child object. This object is part of the create order request object.

Parameter Type Description
value required integer Transaction amount in Paisa.

  • Minimum value: 100 (₹1).
  • Maximum value: 100000000 (₹10 lakh).
Example: 1000
currency required string Type of currency.

Example: INR

Purchase Details [Child Object]

The table below lists the various parameters in the purchase_details child object. This object is part of the create order request object.

Parameter Type Description
customer object An object that contains the customer details.

Learn more about the customer child object.
merchant_metadata object An object of key-value pair that can be used to store additional information.

Example: "key1": "DD"

Customer [Child Object]

The table below lists the various parameters in the customer child object. This is part of the purchase_details object.

Parameter Type Description
email_id string Customer's email address.
  • Minimum length: 1 character.
  • Maximum length: 50 characters.
Example: [email protected]
first_name string Customer's first name.
  • Minimum length: 1 character.
  • Maximum length: 50 characters.
Example: Kevin
last_name string Customer's last name.
  • Minimum length: 1 character.
  • Maximum length: 50 characters.
Example: Bob
customer_id string Unique identifier of the customer in the Pine Labs Online database.
  • Minimum length: 1 character.
  • Maximum length: 19 characters.
Example: 123456
mobile_number string Customer's mobile number.
  • Minimum length: 9 characters.
  • Maximum length: 20 characters.
Example: 9876543210
billing_address object An object that contains the details of the billing address.

Learn more about our billing_address child object.
shipping_address object An object that contains the shipping address details.

Learn more about our shipping_address child object.

Billing Address [Child Object]

The table below lists the various parameters in the billing_address child object. This is part of the customer object.

Parameter Type Description
address1stringCustomer's billing address1.
  • Max length: 100 characters.
Example: 10 Downing Street Westminster London
address2stringCustomer's billing address2.
  • Max length: 100 characters.
Example: Oxford Street Westminster London
address3stringCustomer's billing address3.
  • Max length: 100 characters.
Example: Baker Street Westminster London
pincodestringPincode of the billing address.
  • Min length: 6 characters.
  • Max length: 10 characters.
Example: 51524036
citystringCity of the billing address.
  • Max length: 50 characters.
Example: Westminster
statestringState of the billing address.
  • Max length: 50 characters.
Example: Westminster
countrystringCountry of the billing address.
  • Max length: 50 characters.
Example: London

Shipping Address [Child Object]

The table below lists the various parameters in the shipping_address child object. This is part of the customer object.

Parameter Type Description
address1stringCustomer's shipping address1.
  • Max length: 100 characters.
Example: 10 Downing Street Westminster London
address2stringCustomer's shipping address2.
  • Max length: 100 characters.
Example: Oxford Street Westminster London
address3stringCustomer's shipping address3.
  • Max length: 100 characters.
Example: Baker Street Westminster London
pincodestringPincode of the shipping address.
  • Min length: 6 characters
  • Max length: 10 characters.
Example: 51524036
citystringCity of the shipping address.
  • Max length: 50 characters.
Example: Westminster
statestringState of the shipping address.
  • Max length: 50 characters.
Example: Westminster
countrystringCountry of the shipping address.
  • Max length: 50 characters.
Example: London

The table below lists the various parameters returned in the Create order response objects.

Parameter Type Description
order_id string Unique identifier of the order in the Pine Labs Online database.
  • Max length: 50 characters.
Example: v1-5757575757-aa-hU1rUd
merchant_order_reference string Unique identifier entered while creating an order.
  • Min length: 1 character.
  • Max length: 50 characters.
Example: 82d57572-057c-4826-5775-385a52150554
type string Payment type.

Possible values:
  • CHARGE
  • REFUND
status string Order status.

Possible values:
  • CREATED: When the order is successfully created.
  • PENDING: When the order is linked against a payment request.
  • PROCESSED: When the payment is received successfully.
  • AUTHORIZED: Only when pre_auth is true. When the payment is ready for authorization.
  • CANCELLED: When the payment gets cancelled.
  • ATTEMPTED: When the payment is unsuccessful due to incorrect OTP. You can retry OTP
  • FAILED: Payment acceptance failed for reasons such as cancel transactions, maximum retries for OTP verification etc.
  • FULLY_REFUNDED: When the payment is completely refunded.
  • PARTIALLY_REFUNDED: When the partial refund is successful.
challenge_url string Use the generated challenge_url to accept payment.

Note: This parameter is returned only after the payment is linked against the order_id.
merchant_id string Unique identifier of the merchant in the Pine Labs Online database.

Example: 123456
order_amount object An object that contains the transaction amount details.

Learn more about our order_amount child object.
notes string The note you want to show against an order.

Example: Order1
pre_auth boolean The pre-authorization type.

Possible values:
  • true: When pre-authorization is needed.
  • false: When pre-authorization is not required.
Example: false
allowed_payment_methods array of strings The type of payment methods you want to offer customers.

Accepted values:
  • CARD
  • UPI
  • POINTS
  • NETBANKING
  • WALLET
  • CREDIT_EMI
  • DEBIT_EMI
Example: CARD

Note: Before selecting a payment method, ensure it is configured for you.
callback_url string URL to redirect customers to success or failure pages.

Example: https://sample-callback-url
purchase_details object An object that contains the purchase details.

Learn more about the purchase_details child object.

Note: The presence of the object key-values depends on the Input request.
payments array of objects An array of objects that contains the payment details.

Note: Payment object is returned only for the orders linked with a payment.
created_at string The ISO 8601 UTC Timestamp when the order request was received.

Example: 2024-07-09T07:57:08.022Z
updated_at string The ISO 8601 UTC Timestamp when the order object was updated.

Example: 2024-07-09T07:57:08.022Z

Order Amount [Child Object]

The table below lists the various parameters in the order_amount child object. This object is part of the create order response object.

Parameter Type Description
value integer Transaction amount in Paisa.

  • Minimum value: 100 (₹1).
  • Maximum value: 100000000 (₹10 lakh).
Example: 1000
currency string Type of currency.

Example: INR

Purchase Details [Child Object]

The table below lists the various parameters in the purchase_details child object. This object is part of the create order response object.

Parameter Type Description
customer object An object that contains the customer details.

Learn more about the customer child object.
merchant_metadata object An object of key-value pair that can be used to store additional information.

Example: "key1": "DD"

Customer [Child Object]

The table below lists the various parameters in the customer child object. This is part of the purchase_details object.

Parameter Type Description
email_id string Customer's email address.
  • Minimum length: 1 character.
  • Maximum length: 50 characters.
Example: [email protected]
first_name string Customer's first name.
  • Minimum length: 1 character.
  • Maximum length: 50 characters.
Example: Kevin
last_name string Customer's last name.
  • Minimum length: 1 character.
  • Maximum length: 50 characters.
Example: Bob
customer_id string Unique identifier of the customer in the Pine Labs Online database.
  • Minimum length: 1 character.
  • Maximum length: 19 characters.
Example: 123456
mobile_number string Customer's mobile number.
  • Minimum length: 9 characters.
  • Maximum length: 20 characters.
Example: 9876543210
billing_address object An object that contains the details of the billing address.

Learn more about our billing_address child object.
shipping_address object An object that contains the shipping address details.

Learn more about our shipping_address child object.

Billing Address [Child Object]

The table below lists the various parameters in the billing_address child object. This is part of the customer object.

Parameter Type Description
address1stringCustomer's billing address1.
  • Max length: 100 characters.
Example: 10 Downing Street Westminster London
address2stringCustomer's billing address2.
  • Max length: 100 characters.
Example: Oxford Street Westminster London
address3stringCustomer's billing address3.
  • Max length: 100 characters.
Example: Baker Street Westminster London
pincodestringPincode of the billing address.
  • Min length: 6 characters.
  • Max length: 10 characters.
Example: 51524036
citystringCity of the billing address.
  • Max length: 50 characters.
Example: Westminster
statestringState of the billing address.
  • Max length: 50 characters.
Example: Westminster
countrystringCountry of the billing address.
  • Max length: 50 characters.
Example: London

Shipping Address [Child Object]

The table below lists the various parameters in the shipping_address child object. This is part of the customer object.

Parameter Type Description
address1stringCustomer's shipping address1.
  • Max length: 100 characters.
Example: 10 Downing Street Westminster London
address2stringCustomer's shipping address2.
  • Max length: 100 characters.
Example: Oxford Street Westminster London
address3stringCustomer's shipping address3.
  • Max length: 100 characters.
Example: Baker Street Westminster London
pincodestringPincode of the shipping address.
  • Min length: 6 characters
  • Max length: 10 characters.
Example: 51524036
citystringCity of the shipping address.
  • Max length: 50 characters.
Example: Westminster
statestringState of the shipping address.
  • Max length: 50 characters.
Example: Westminster
countrystringCountry of the shipping address.
  • Max length: 50 characters.
Example: London

Refer to our Create Hosted Checkout API documentation to learn more.


2. Get Access to the SDK

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


3: Add the Framework to Your App

  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

4. Add Apple Pay as a Payment Option

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

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.
let button = PKPaymentButton(paymentButtonType: .buy, paymentButtonStyle: .black)

Refer to the Apple Pay Button Customization documentation for more details.


5. Delegate Setup

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

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.


6. Payment Data Structure

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

Below is the minimal structure used in the example:

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:

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

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.



Ask AI
Assistant
Hourly Limit
0 / 20000 tokens used Resets in: 60m 0s
Order Lifecycle
Refunds
Settlements
Checkout
Dashboard
International Payments
How do I implement webhook notifications for payment status updates, and what's the recommended way to verify webhook authenticity?
How do I integrate Pine Labs payment gateway with my React Native mobile app and what are the required API credentials?
Can I customize the payment UI for card transactions, and what parameters can I pass to modify the checkout experience for my customers?
Assistant