Implementing UPI Payments in Flutter: Handling Google Pay Intent in iOS

257 views Asked by At

I am currently working on a Flutter app that involves UPI (Unified Payments Interface) payments. In the Android part of the app, I've successfully implemented UPI payments using method channels. I've created native Kotlin code to handle the intent for Google Pay and check the activity result for the payment response.

Now, I'm facing a challenge with the iOS implementation. I need guidance on how to handle UPI payments in Flutter for iOS, specifically for Google Pay. I'm not sure how to create an equivalent mechanism in Swift for opening Google Pay and capturing the payment response.

Here is a simplified version of the Android code I used:

    private fun makeGooglePayTransaction(
        merchantVpa: String,
        merchantName: String,
        merchantCode: String,
        transactionRefId: String,
        transactionNote: String,
        orderAmount: String
    ) {
        val GOOGLE_PAY_PACKAGE_NAME = "com.google.android.apps.nbu.paisa.user"
        val GOOGLE_PAY_REQUEST_CODE = 123

        val uri = Uri.Builder()
            .scheme("upi")
            .authority("pay")
            .appendQueryParameter("pa", merchantVpa)
            .appendQueryParameter("pn", merchantName)
            .appendQueryParameter("mc", merchantCode)
            .appendQueryParameter("tr", transactionRefId)
            .appendQueryParameter("tn", transactionNote)
            .appendQueryParameter("am", orderAmount)
            .appendQueryParameter("cu", "INR")
            .build()

        val intent = Intent(Intent.ACTION_VIEW)
        intent.data = uri
        intent.`package` = GOOGLE_PAY_PACKAGE_NAME

        startActivityForResult(intent, GOOGLE_PAY_REQUEST_CODE)

    }

I am seeking advice on how to achieve a similar functionality in Flutter for iOS using Swift. I want to open Google Pay and handle the payment response. Any insights, code snippets, or references would be greatly appreciated

0

There are 0 answers