Nets-mobile-acceptance / Netaxept-Android-SDK

PiA Netaxept Android SDK is a library that provides the native In-App interaction to perform Netaxept payments directly from an app on Android devices while minimizing PCI DSS requirements for you.
31 stars 15 forks source link

SDK always triggers an AUTH operation #60

Closed kalina559 closed 2 years ago

kalina559 commented 2 years ago

Hi, I'm trying to use a card registration flow in my app developed in Kotlin. My backend is creating a VERIFY operation like this:

https://epayment.nets.eu/Netaxept/Register.aspx?token=...&serviceType=M&orderNumber=...&currencyCode=DKK&updateStoredPaymentInfo=true&autoAuth=false(tried both)&customerNumber=...&recurringType=S&redirectUrl=http%3A%2F%2Flocalhost%2Fdummy.htm(dummy url)&force3DSecure=true&amount=0&operation=VERIFY&merchantId=...

I call the endpoint that initializes the Netaxept transaction in CardTokenizationRegistration.registerPayment() and I pass the transactionId to the TransactionCallback. However, I always get asked to complete an AUTH operation, that fails on one specific card. How can I specify that I don't want to actually make a payment? I just want to initialize a payment in my backend, supply the card information to Netaxept, and later run Process(VERIFY) in my backend.

This is my code:

    try {
        val cardPaymentActivityLauncher: ActivityResultLauncher<CardProcessActivityLauncherInput> =
            registerForActivityResult(
                CardProcessActivityResultContract.invoke(),
                this::transactionCompleteResult
            )

        val cardTokenizationRegistration = object: CardTokenizationRegistration{
            override fun registerPayment(callbackWithTransaction: TransactionCallback) {
                val paymentData = presenter.onSynchronousCardRegistration() // by calling this I create a new 'Verify' transaction with paymentData.netaxeptsTicket == transaction id
                callbackWithTransaction.successWithTransactionIDAndRedirectURL(paymentData.netaxeptsTicket, Uri.parse(Constant.Uri.URI_NETAXEPT_ROLLBACK)) // after this, I'm always prompted with AUTH operation
            }
        }

        val cardProcess = PaymentProcess.cardTokenization(
            android.util.Pair(createMerchantInfo().id, PiaSDK.Environment.PROD),
            setOf(),
            cardTokenizationRegistration
        )

        PiaSDK.startCardProcessActivity(
            cardPaymentActivityLauncher,
            cardProcess,
            true)

    } catch (cause: IllegalStateException) {
        exitScreenWithError(null)
    }
Miss-PiA commented 2 years ago

Hi

Please refer this code snippet for registering a card https://github.com/Nets-mobile-acceptance/Netaxept-Android-SDK/blob/master/PiaSample/app/src/main/java/eu/nets/pia/sample/ui/activity/LoginActivity.java#L459

Alsorefer this documentation of card registration flow https://htmlpreview.github.io/?https://github.com/Nets-mobile-acceptance/Netaxept-Android-SDK/blob/master/documentation/START%20-%20Overview%20of%20Netaxept%20Android%20SDK.html#Register_flow_description

Let us know if you need more help Thanks

kalina559 commented 2 years ago

Hey, thanks for responding. I'm not sure what I should change though - I see the setStoreCard() method implemented in PaymentRegisterRequest and I suspect that 'storeCard' field is used by backend when creating the Register call. However, in our backend we just use always use force3DSecure=true&amount=0&operation=VERIFY&updateStoredPaymentInfo=true when user calls the 'add payment method endpoint'

My issue is that when I'm calling callbackWithTransaction.successWithTransactionIDAndRedirectURL() I always see the AUTH screen, asking me to complete a 0 DKK payment.

Miss-PiA commented 2 years ago

Hi Kalina,

Please follow save card flow as below -

  1. Please check backend tips for proper register call, https://htmlpreview.github.io/?https://github.com/Nets-mobile-acceptance/Netaxept-Android-SDK/blob/master/documentation/START%20-%20Overview%20of%20Netaxept%20Android%20SDK.html#Backend_Tips
  2. Provide transactionId and redirectUrl to SDK.
  3. You will see AUTH screen, please authenticate the user with proper details. No matter amount is 0.
  4. In order to store the card, make a verify API call to Netaxept with the given transaction ID. API: /process.aspx Body: { "merchantId" : "string", "token" : "string", "transactionId" : "string", "operation" : "VERIFY" }

For more information, please refer this document https://developers.nets.eu/netaxept/en-EU/docs/sca-requirements-according-to-use-cases/

Thanks

kalina559 commented 2 years ago

Hi, thanks for your help. I've made it work eventually, but in a slightly different way. Turned out that part of the problem was that in our backend we only saved the panHash when after the Query.aspx call the Summary.Authorized field was set to TRUE. Now we also do it if panHash != null.

I just added force3DSecure=true, amount=0 and operation=VERIFY to the Register call. It also turned out the autoAuth==true was causing problems with the Verify flow so I changed it to false. It looks like Pia-SDK is performing the Process(Verify) call by itself, because I didn't need to do it explicitly in our backend, we just use Query to check if Summary.Authorized == true or panHash != null

Miss-PiA commented 2 years ago

Glad to know that your issue has been resolved. Is it okay to close this issue now?

Thanks