In my iOS application, I need to accept payments from the user. I am using UPI for the same. I have followed the following document provided by UPI
http://www.npci.org.in/documents/UPI-Linking-Specs-ver-1.1_draft.pdf
I have created a deeplink as stated in the document. UIApplication.shared.open
is used to open the deeplink url so that it opens any installed PSP(Payment Service Provider) application in my phone(like PhonePe, BHIM etc)
func payButtonClicked() {
guard let urlString = "upi://pay?pa=samplevpa@ybl&pn=Sample Name&am=1&cu=INR".addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)
else {
return
}
guard let url = URL(string: urlString) else {
return
}
if !UIApplication.shared.canOpenURL(url) {
print("url cannot be opened")
return
}
UIApplication.shared.open(url, options: [:], completionHandler: { (success) in
print(success)
})
}
I have registered my application with custom URL schemes and have added the scheme upi for ApplicationQueriesScheme in plist file
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>SampleApp</string>
</array>
<key>CFBundleURLName</key>
<string>com.company.SampleApp</string>
</dict>
</array>
<key>LSApplicationQueriesSchemes</key>
<array>
<string>upi</string>
</array>
It is opening the PSP application and I'm able to make the transaction. The problem is I'm not able to get the response back from the PSP application. There is no callback method to UIApplication.shared.open
method. I need to get the status of the transaction back from the PSP application and show the status to the user. Any help appreciated
Steps to Create a UPI Payment LinkGo to the PayU India website and click on the Payment Gateway tab on the dashboard. Select Payment Links on the payment gateway tab and select the Create Payment link.
In the "Business Profile" page, submit required information and wait for approval. In the “Integrations” page, enter and verify your UPI ID. Integrate the In-App payment flow. To make sure that the transaction is successful, refer to the document provided by your bank or payment service provider.
1 Answer. Show activity on this post. And on a button click event bind this function. It will open up the Apps tray with all the UPI installed in the corresponding mobile.
the NPCI UPI Linking Specification states that the URL parameter used in the payment link is for information purpose which the payment apps may use to provide additional information to the payer upon clicking the link.
The link is only expected to show transaction details by the merchant or party that invoked the transaction.
It is not meant as a callback URL or a web hook for completion of transaction.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With