14

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

Arun
  • 1,391
  • 1
  • 10
  • 29
  • hello Arun, is your transaction successful? I am trying to do transaction from my android app but the transaction is always failing – Srikanth B Sep 15 '17 at 09:05
  • The transaction was successful for me. My issue is I'm not able to get the response back. I won't know whether the user actually paid or not – Arun Sep 15 '17 at 13:57
  • I am using cordova and I am getting response in my android app, but not able to invoke PSP app from iOS – Srikanth B Sep 15 '17 at 14:11
  • did you find any solution? I cannot invoke BHIM from iOS, any help is greatly appreciated. – Srikanth B Mar 08 '18 at 04:08
  • hello Arun, did you get response from UPI app.I am also stuck in same problem like you have commented above. I am getting response back in Android successfully but no luck in IOS. if yes than guide me. Thanks – Sumit Kumar Apr 20 '18 at 07:33
  • Not yet. I have started using other payment gateway for my app – Arun Apr 23 '18 at 05:17
  • @codeHunter any updates here? are you opening the BHIM app or doing a collect request call? – Ranjit Aug 30 '18 at 05:59
  • @Ranjit for IOS, there is no update. I have working code for Android platform. In IOS, upi app starts but they don't complete transaction or return response. – Sumit Kumar Aug 30 '18 at 07:15
  • @SrikanthB, Can you please let me know how to deep link this for IOS in cordova. I'm actually using ionic. I'm able to get response in android (for Paytm, Google Pay). – sanjay Kumar Nov 14 '18 at 14:01
  • @sanjay iOS is not working for me – Srikanth B Nov 15 '18 at 15:32
  • Any updates on how to do the transaction in iOS using googlepay, paytm, etc. and getting the transaction details. I could do the transaction using phonepe but not others and even with phonepe i don't get the callback and so no transaction status. – Sagar Patil Feb 02 '20 at 19:31
  • Is anyone getting callback in iOS after successful transactions? – Muzammil Dec 17 '20 at 10:15

4 Answers4

2

Based on the below workflow, you need to have a tie up with Payer/Payee PSP to get notified for your payments. In your scenario, you are required to check with your bank PSP for getting notified on the payment receipt to your accoutns.

I could not see a way for individual Initiator to get notified.

Feel free to correct me.

Workflow by UPI

Venkateswara Rao
  • 5,242
  • 1
  • 18
  • 13
1

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.

Alpesh Patil
  • 1,672
  • 12
  • 15
-1

Have not tried it but it was mentioned in the document about a url parameter on clicking of which we should show the transaction details to the user.

This should be a URL when clicked provides customer with further transaction details like complete bill details, bill copy, order copy, ticket details, etc. This can also be used to deliver digital goods such as mp3 files etc. after payment.

We could send a url with a url scheme that redirects to the app or an universal link that our app can handle.

Again I have not tried this so I do not know if this works as I think it should or whether it would exactly solve your issue.

https://www.npci.org.in/sites/all/themes/npcl/images/PDF/UPI_Linking_Specs_ver_1.5.1.pdf

Swasidhant
  • 1,231
  • 1
  • 12
  • 13
-1

You can use the url parameter to pass your website url with the get method with order id or payment id as parameter. Once the payment is successful, it is mandate the UPI provider to hit the URL. The purpose of the URL should be keep updating the transaction status and trigger then end user an email or SMS with the transaction status.