1

I am creating a demo project in Xamarin and in that, I want to use google pay(gPay) as a payment option. I have checked many sites/videos on the internet and it is providing solutions for android implementation but none of them have iOS implementation. From android, I have got that this payment with google-pay will be done with the deep-linking and it needs to be implemented in the native structure of the project for making it work or open other applications and get a response from the payment app after the payment process completion. Can you please help me with this?

Thanks.

Mayank Balar
  • 201
  • 2
  • 8

1 Answers1

1
var urlString : String
            if selectedItem == "GPay" {
                urlString = responseObj.url.replacingOccurrences(of: "upiapp://", with: "gpay://upi/")
            }
            else if selectedItem == "PhonePe" {
                urlString = responseObj.url.replacingOccurrences(of: "upiapp://", with: "phonepe://")
            }
            else if selectedItem == "Paytm" {
                urlString = responseObj.url.replacingOccurrences(of: "upiapp://pay", with: "paytmmp://upi/pay")
            }
            else{
                urlString = responseObj.url
            }
            let url = URL(string: urlString)!
            if UIApplication.shared.canOpenURL(url) {
                UIApplication.shared.open(url, options: [:], completionHandler: nil)

 }else{
                let alert = UIAlertController(title: "Alert", message: "The app is not installed, please install and try again", preferredStyle: .alert)
                alert.addAction(UIAlertAction(title: "Ok", style: .default) { action in
                })
                self.present(alert, animated: true, completion: nil)
            }

//note : responseObj.url give backend.
 example url
"upiapp://pay?pa=xxx&pn=xxx&tr=xxx&am=3000&cu=xxx&mc=xxx";

pa = id.
pn = name
tr = translation id
am = amount
cu = “INR”     — india
mc = user id 

or use that payment integration pod

https://razorpay.com/docs/payments/payment-methods/upi-intent/ios/

Akila M
  • 42
  • 7
  • Gpay , Phonepe,paytm image displayed tableview cell – Akila M Mar 02 '22 at 09:12
  • Can you please let me know where and how can I put this code as I am not very much aware of the xamarin? – Mayank Balar Mar 02 '22 at 09:29
  • I placed that code table did selected row because my project access totally based backend . so refer that url https://stackoverflow.com/questions/61529370/how-to-integrate-google-pay-in-ios-swift (Answer 3). – Akila M Mar 02 '22 at 09:36
  • add LSApplicationQueriesSchemes In plist (gpay) – Akila M Mar 02 '22 at 09:57