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.
- [Prerequisite] Integrate APIs in Your Backend
- Get Access to the SDK
- Add the Framework to Your App
- Add Apple Pay as a Payment Option
- Delegate Setup
- 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.
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-c3b4909ed232Note: 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: fgwei7egyhuggwp39w8rhNote: 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: eyJhbGciOiJIUzI1NiIsInNote: 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.
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.
1234567890Supported characters:
|
| 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:
|
| allowed_payment_methods | array of strings |
The type of payment methods you want to offer customers. Accepted values:
CARDNote: 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.
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.
[email protected] |
| first_name | string |
Customer's first name.
Kevin |
| last_name | string |
Customer's last name.
Bob |
| customer_id | string |
Unique identifier of the customer in the Pine Labs Online database.
123456 |
| mobile_number | string |
Customer's mobile number.
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 |
|---|---|---|
| address1 | string | Customer's billing address1.
10 Downing Street Westminster London |
| address2 | string | Customer's billing address2.
Oxford Street Westminster London |
| address3 | string | Customer's billing address3.
Baker Street Westminster London |
| pincode | string | Pincode of the billing address.
51524036 |
| city | string | City of the billing address.
Westminster |
| state | string | State of the billing address.
Westminster |
| country | string | Country of the billing address.
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 |
|---|---|---|
| address1 | string | Customer's shipping address1.
10 Downing Street Westminster London |
| address2 | string | Customer's shipping address2.
Oxford Street Westminster London |
| address3 | string | Customer's shipping address3.
Baker Street Westminster London |
| pincode | string | Pincode of the shipping address.
51524036 |
| city | string | City of the shipping address.
Westminster |
| state | string | State of the shipping address.
Westminster |
| country | string | Country of the shipping address.
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.
v1-5757575757-aa-hU1rUd |
| merchant_order_reference | string |
Unique identifier entered while creating an order.
82d57572-057c-4826-5775-385a52150554 |
| type | string |
Payment type. Possible values:
|
| status | string |
Order status. Possible values:
|
| 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:
false |
| allowed_payment_methods | array of strings |
The type of payment methods you want to offer customers. Accepted values:
CARDNote: 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.
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.
[email protected] |
| first_name | string |
Customer's first name.
Kevin |
| last_name | string |
Customer's last name.
Bob |
| customer_id | string |
Unique identifier of the customer in the Pine Labs Online database.
123456 |
| mobile_number | string |
Customer's mobile number.
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 |
|---|---|---|
| address1 | string | Customer's billing address1.
10 Downing Street Westminster London |
| address2 | string | Customer's billing address2.
Oxford Street Westminster London |
| address3 | string | Customer's billing address3.
Baker Street Westminster London |
| pincode | string | Pincode of the billing address.
51524036 |
| city | string | City of the billing address.
Westminster |
| state | string | State of the billing address.
Westminster |
| country | string | Country of the billing address.
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 |
|---|---|---|
| address1 | string | Customer's shipping address1.
10 Downing Street Westminster London |
| address2 | string | Customer's shipping address2.
Oxford Street Westminster London |
| address3 | string | Customer's shipping address3.
Baker Street Westminster London |
| pincode | string | Pincode of the shipping address.
51524036 |
| city | string | City of the shipping address.
Westminster |
| state | string | State of the shipping address.
Westminster |
| country | string | Country of the shipping address.
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
- Drag and drop
ApplePaySDK.xcframeworkinto the file navigator of your Xcode project. - When prompted, make sure to:
- ✅ Check “Copy items if needed”
- ✅ Add to your app target
- Open the General tab of your app target.
- Under Frameworks, Libraries, and Embedded Content, ensure that
ApplePaySDK.xcframeworkis 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:
trueif 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:
- Builds a
PKPaymentRequestusing the provided order details. - Presents the
PKPaymentAuthorizationControllerto the user. - Handles merchant validation, payment processing, and authorization steps.
- 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.
Updated 15 days ago
