In this part we will talk about how you can integrate iOS SDK and initiate payment:
Demo App
Prerequisites
- XCode 12.5 or newer
- Cocoapod
- Onboarded on PhonePe as a Merchant (Given a MerchantID, Client Secret and version to generate the o-auth token )
iOS PG SDK setup
The PhonePePayment framework is needed for the SDK to work for both Sandbox (Testing) and Production (Deployment) environments.
- The PhonePePayment SDK is available through CocoaPods [Refer to this link ],
Latest PhonePe iOS SDK Version: 5.0.0 - To install it, simply add the following line to your Podfile:
pod 'PhonePePayment'
then run :
pod install
Import the framework in your project using “import PhonePePayment”
Remove the “DirectPaymentSDK” from your project if you have already integrated and want to migrate to CocoaPods.
import PhonePePayment
iOS PG App Side Implementation
Step 1. In your Info.plist, create or append a new Array type node LSApplicationQueriesSchemes to append the following values:
<key>LSApplicationQueriesSchemes</key>
<array>
<string>ppemerchantsakv1</string>
<string>ppemerchantsdkv2</string>
<string>ppemerchantsdkv3</string>
<string>ppemerchantsdkv4</string>
<string>ppemerchantsdkv5</string>
<string>paytmmp</string>
<string>gpay</string>
</array>

Step 2. Create DeepLink Schema
Create a URLType for your app (Deeplink), if not already present.
For example, we have used: iOSIntentIntegration. (You can create your own identifier for your app)

URLScheme should match the below conditions :
- Only Alphabets (lower and upper case) and numbers are allowed.
- We can allow special characters only like dot and Hyphen
- The name should always start with alphabets.
- The schema should be correct to redirect the app otherwise it will not redirect back to the merchant app.
To Enable Debug Logs
Update the PPPayment.enableDebugLogs = true or enableLogging flag to true in PPPayment class initialisation.
Step 4. Initialize the PG SDK
let ppPayment = PPPayment(environment: .production,
flowId: "FLOW_ID",
merchantId: "MERCHANT_ID")
Parameter Name | Type | Description |
---|---|---|
environment | Enum | .production for Production.sandbox for PreProd |
flowId | String | Pass the merchant user Id or the unique string (UUID().uuidString) for every init for analytics purposes. |
merchantId | String | The merchant Id provided by PhonePe |
enableLogging | Boolean | [Optional Parameter] – True (To enable the SDK logs) – False (To disable the SDK logs) Note: In Prod, make sure to set as False. |
Step 5. In your AppDelegate, check for a callback from the PhonePe app and if found, pass it to the SDK.
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
let handled = PPPayment.checkDeeplink(url, options: options)
if handled {
// Phonepe is handling this, no need for any processing
return true
}
//Process your own deeplinks here
return true
}