adyen-ios icon indicating copy to clipboard operation
adyen-ios copied to clipboard

[NEED ASSIST] Handling redirect flow using RedirectComponent

Open Mihailo94 opened this issue 7 months ago • 12 comments

Describe the challenge Hello, I'm trying to handle redirect flow using Component approach. I open RedirectComponent using:

func present(component: Adyen.PresentableComponent) {
        present(component.viewController, animated: true)
}

So, is it proper way to handle this because it only says in documentation to call this method:

redirectComponent.handle(action)

After that nothing happens and I need to call present as I said to show RedirectComponent.

Also per documentation:

"You then need to inform the Component when shopper returns to your app. To do this, implement the following in your UIApplicationDelegate:

func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { RedirectComponent.applicationDidOpen(from: url) return true }" Is this necessary to do because in my case I can just dismiss RedirectComponent when didProvide method occurred, I pass the data to our backend and finish flow as I did for 3DS flow. I'm not sure if there is other case where it is necessary?

One more thing. When will this method be occured, and how can I test it: didOpenExternalApplication(component: Adyen.ActionComponent)

Documentation update (optional) Here is documentation that I followed: RedirectComponent

Screenshots How it behaves now: https://github.com/Adyen/adyen-ios/assets/148769359/4c44aff6-f3b5-4615-93b5-68adc0fa3c69

Mihailo94 avatar Jan 26 '24 10:01 Mihailo94

Hey @Mihailo94

After that nothing happens and I need to call present as I said to show RedirectComponent.

RedirectComponent will call presentationDelegate if/when action view is ready to be shown.

For example, in the case of app-2-app redirect SafaryVC will not appear, and didOpenExternalApplication will be called instead of presentationDelegate.

Is this necessary to do because in my case I can just dismiss RedirectComponent when didProvide method occurred

In case of redirect action didProvide will occur after RedirectComponent.applicationDidOpen(from: url) was called. Method applicationDidOpen() is the way how you provide our SDK with a URL containing query parameters from the Issuer web/app side.


didOpenExternalApplication is an optional method. You can test it with Vipps, Swish, and BCMC Payconic payment flows. Or by opening an external browser (icon on bottom panel in SafaryVC)


We always welcome your feedback. Is there anything we can do to improve our documentation?

descorp avatar Jan 26 '24 11:01 descorp

Hi @descorp,

Thank you for quick response. Everything is clear to me now.

Regarding documentation I was just confused by the fact that for the ActionComponent I didn't have to call present, but it was enough just to call the handle method and ActionComponent is shown. So, maybe you don't need to improve documentation.

Regarding testing didOpenExternalApplication. I tried with BCMC but flow is the same. Also I tried with opening an external browser as you said and I got an error when it opened.

https://github.com/Adyen/adyen-ios/assets/148769359/cbbd3db6-0d8a-406e-a508-9a9ea6609401

Mihailo94 avatar Jan 26 '24 12:01 Mihailo94

Hey @Mihailo94

Sorry, I meant BCMC Mobile

opening an external browser as you said and I got an error when it opened.

This is expected - the 3DS web-flow page is a one time thing (for security reason). When you opened real Safary - page attempted to recreate the state and failed.

For successful "Open In Browser" flow - try any redirect pm (ex. Klarna, Paypal).

descorp avatar Jan 26 '24 13:01 descorp

Hi @descorp,

We always get only Credit Card in response with different brands and we initiate CardComponent. So as I understand didOpenExternalApplication will never called in my case. Right?

Mihailo94 avatar Jan 26 '24 13:01 Mihailo94

@Mihailo94

You can add payment methods to your account via CA.

Adyen provides a great variety of payment methods. If you are looking to extend your PM offering - please reach out to Adyen Support.

descorp avatar Jan 26 '24 14:01 descorp

@descorp

Thank you. I mean we support only support Credit Card and will not add other payment methods. My question was about CardComponent. If I use only CardComponent didOpenExternalApplication will never be called and I don't need to handle this?

Mihailo94 avatar Jan 26 '24 15:01 Mihailo94

Hi @descorp,

One more thing. Now I'm getting error "Method not allowed" when I try to present RedirectComponent. I used the same data before and it was working fine. Do you know what could be a problem?

Action data that I send:

▿ RedirectAction
  ▿ url : https://checkoutshopper-test.adyen.com/checkoutshopper/threeDS/checkoutRedirect/H4sIAAAAAAAA_2WKywrCMBAAv6beLNhYwUMOQmirRautIngpMa5NfCQhuxX06-1REOY0M8YSdEGScZZLb1rZkx4ZxB7CITy4JvIYsUWUZANKg7q7nlA77yGMCZBieXmDjZV7_g-DIR0ARJPEqOn5iFjm0ddwhQBWQcTEqq6bYr-eHnOWlfksHf12_lfRdFww8bLaIktu1Wczl3JeVepUTLYlgXntztO2JZNOymux_AKy7zqA3gAAAA
    - _url : https://checkoutshopper-test.adyen.com/checkoutshopper/threeDS/checkoutRedirect/H4sIAAAAAAAA_2WKywrCMBAAv6beLNhYwUMOQmirRautIngpMa5NfCQhuxX06-1REOY0M8YSdEGScZZLb1rZkx4ZxB7CITy4JvIYsUWUZANKg7q7nlA77yGMCZBieXmDjZV7_g-DIR0ARJPEqOn5iFjm0ddwhQBWQcTEqq6bYr-eHnOWlfksHf12_lfRdFww8bLaIktu1Wczl3JeVepUTLYlgXntztO2JZNOymux_AKy7zqA3gAAAA
  - paymentData : nil
  - nativeRedirectData : nil

Here is the sc what I get: IMG_3344

Mihailo94 avatar Jan 30 '24 13:01 Mihailo94

Hey @Mihailo94

Are you using "channel": "iOS" ? Your redirected to POST redirect page

descorp avatar Jan 30 '24 14:01 descorp

Hi @descorp, yes I use "channel": "iOS" for authorize API call as you can see here

{
    "cardId": "F621EAC8-5CA5-40AF-833A-2BF29155C587",
    "returnUrl": "https://test-www.quandoo.de/api/authorise-cc",
    "paymentMethod": {
        "type": "scheme",
        "encryptedCardNumber": "eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwidmVyc2lvbiI6IjEifQ.ChuS7YQg2cXfcYKQF4A372q-90yezcDbsG6K02IzLfV5qKWb0CbT1zmQ7hyK3TJYPFnVAAKYdox0D0G4u2RNr8tqhZlPGdxZ9IgGutI9krCFtpP-Rbolsub7VDOACyVi5YxRmmoHxlpjREhiY6DrRrkwuE5Eo6QYyw6ad3qPd2FEMVRjDqZWr7g9ysMCcTiatE95LuQ3squGTed1sINcni4wdqB27QoezfC47pbcE0bObrL3bmlUPwqcnpnqGZb3pb2RrvJFqViVf8fpv5LPahRMPpFFzr0N_uYqAlUhrWOaBQdUgH-AvhKoGx6jg5vHpt01-qiJaY5cRQ7ysJDnAA.wtlZ_AEVO7xKkTOF0joJ5A.9IxSqn0m5CuOuYwEugHfiRezjtqAEERGynaDcuGvhNBselJ6SMS0b6YRLoXTT3MKgVagH1fZpe6y6vmpKARwHYwB4hhHiNv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oweeanaY_RG3s332Eg.6P0LgaVpC1i_BSaifqKk1g.AEWycZyRybqYbkUNNtjuP-zjWoTLyjlBeG6VizhUSC5i8tT0PFGba8NxwKtCaHTSXRLY1DtWgDXB5NsHo6TAOw.PNWUplP8aDsFYMQOv6P24FPtiheIQ9uzyI8trroRpQU",
        "encryptedSecurityCode": "eyJhbGciOiJSU0EtT0FFUC0yNTYiLCJlbmMiOiJBMjU2Q0JDLUhTNTEyIiwidmVyc2lvbiI6IjEifQ.fCzefZBABEaTI0I4Dj4_ersESJ01JbpqvelD_MQ3RcPs2vyStf02B0kLvrs9gRYQxrKm2bxl7G8lI_xjxzSrzuBB6UJa2BWefY8E0nLGi8hE0onGPTbMm5eAIBDXmnlAV9boPObh0bj2DoKI7gODxflZayhqm0jr1w4gbRgmFaOfbebTQsLGjwZxDPsFxNQD2nVBkiEKVk8_PX1mxXgNr16oJxKckVy1_Xw2mVFg_gqUVwsz-E_sw2ds7qr453Sb5gb0x0PVCKGdR76aeqdwpkdB1oxyGs2HDdvXMuLhmYbPgiuNjiCOVHYgVbk3dTvmj_81hEhuIuTzheGWbS_hGQ.COIcmxMH_oBHW0wNEGNcxw.-X8tIx5LA6SO77pViL7JQRKSG15xlyjgKO1gj0COEKQf3TRmI7g7LCEVt2odaQ5YxAG_P9-BzKahhKl_6xReJg.HRAJ-gY5gl-CDQ_16LRJEtsMwCXOko9dfQT45N2bsSs"
    },
    "browserInfo": {
        "userAgentId": "Mozilla/5.0 (iPhone; CPU iPhone OS 14_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148"
    },
    "origin": "https://test-9120-api.quandoo.com",
    "channel": "iOS",
    "customer": {
        "id": "4b8d44a1-9190-4b57-acde-a4c4ab77a5f6",
        "firstName": "da",
        "lastName": "da",
        "phoneNumber": "+381649266801",
        "email": "[email protected]",
        "countryCode": "GBR",
        "locale": "RS"
    }
}

Mihailo94 avatar Jan 30 '24 15:01 Mihailo94

I see, It is "returnUrl": "https://...",

You can correct this behaviour by setting redirectFromIssuerMethod and redirectToIssuerMethod to "GET"

descorp avatar Jan 30 '24 15:01 descorp

Hi @descorp, I still have the same issue. I did what you suggested and changed returnUrl value and it worked, but now I'm testing it again and get the error as on video that I provide. For example this morning I just changed returnUrl and all worked fine. Then I tried flow again and I get error. Also func didProvide(_ data: Adyen.ActionComponentData, from component: Adyen.ActionComponent) did not trigger when I press "Continue" on RedirectComponent. Could you please help me with this?

Mihailo94 avatar Feb 14 '24 13:02 Mihailo94

Hey @Mihailo94

this morning I just changed returnUrl and all worked fine. Then I tried flow again and I get error.

Could you contact Adyen Support and provide them with PSP references of both good and bad attempts?

It is not recommended to provide this information on public channels like GitHub

I just changed returnUrl

didProvide did not trigger

Is your new returnUrl registered in your Info.plist ? Did the func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool from AppDelegate get triggered?

descorp avatar Feb 15 '24 10:02 descorp