Home > other >  How to integrate google pay in xamarin for application for iOS?
How to integrate google pay in xamarin for application for iOS?

Time:03-03

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.

CodePudding user response:

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/

  • Related