veritrans / Veritrans-ios-sdk

The new iOS SDK
MIT License
14 stars 33 forks source link

Missing Payment Details implementation of GopayQRIS & ShopeePayQRIS #577

Closed ghani-ma closed 1 year ago

ghani-ma commented 1 year ago

Environment

SDK Installation : Swift Package Manager SPM Branch: Master MacOS Version: 13.0.1 (22A400) XCode Version: 14.1 (14B47b) iOS Version: iOS 16.1

Introduction: Hi, I'm developing an App that using Midtrans as its Payment Gateway. I'm using the MidtransCoreKit to handle each payment method that app will supports.

The app has a flow where, if the user doesn't have Gojek / Shopee App installed, then the app need to continue the transaction using QRIS method. However, it seems the SDK doesn't have any QRISGopay or QRISShopeePay support.

As for my investigation into the SDK, I found that the SDK has qrisshopeepay (reference) payment-type key but no MidtransPaymentDetails object using this key. (This is an example of ShopeePay PaymentDetails that using shopeepay key)

What I have tried so far:

  1. Created a class that conform to MidtransPaymentDetails Protocol
    final class MidtransPaymentShopeePayQRIS: NSObject, MidtransPaymentDetails {
    func dictionaryValue() -> [AnyHashable : Any]? {
        return ["payment_type": "qrisshopeepay"]
    }
    }
  2. Since the payment-type qrisshopeepay exists, I set the payment_type's value to qrisshopeepay
  3. Using it like let transaction = try MidtransTransaction(paymentDetails: MidtransPaymentShopeePayQRIS(), token: token)

Unfortunately, using above workaround and no matter of any payment-type variations value such as qris_shopeepay, qris_shopee_pay or QRIS_shopeepay the response still returns as Invalid payment type like below:

body : {"payment_type":"qrisshopeepay"}
response : {"error_messages":["Invalid payment type"]}

I can confirm if I change the payment_type to shopeepay, which will be the same as MidtransPaymentShopeePay implementation it will behaving identical with MidtransPaymentShopeePay() that will return below response:

body : {"payment_type":"shopeepay"}
response : {"status_code":"201","status_message":"Transaksi sedang

Moreover, when I looked into Midtrans Android SDK, there are already two of these and its works well when using it:

May I know how to implement paymentUsingShopeePayQris and paymentUsingGoPayQris using iOS SDK? Or, do I need to use MidtransPaymentQRIS(acquirer: "gopay" / "shopeepay") to handle QRIS transaction? Or, does iOS SDK have not updated yet for GopayQRIS and ShopeePayQRIS implementation? Any further information or guidances would be helpful.

Thank you!

uziwuzzy commented 1 year ago

@ghani-ma for UIKit AndroidSDK has been updated to have qris gopay, but ios sdk unfortunately is not updated yet, will do it soon.

However, since you're using corekit, I think you can use gopay as qris. To create qris the payment type should be qris, then you also need to set the acquirer eg: gopay, shopeepay. So to create the MidtransPaymentDetails, you can use something like this:

        let qrisPaymentDetails = MidtransPaymentQRIS(acquirer: "gopay")
        let qrisTransaction = MidtransTransaction(paymentDetails: qrisPaymentDetails, token: snapToken)

        MidtransMerchantClient.shared().perform(qrisTransaction!) { result, error in
            if let result = result {

            }
        }

If you want to use shopeepay qris, you can just change the acquirer value to shopeepay.

ghani-ma commented 1 year ago

Hi @uziwuzzy. Really appreciate your guidance. Thank you for the information regarding current iOS SDK that's not updated yet. We'll look forward to the updated iOS SDK.