Adyen / adyen-ios

Adyen iOS Drop-in and Components
https://docs.adyen.com/checkout/ios
MIT License
152 stars 122 forks source link

[NEED ASSIST] Matching ApplePayPaymentMethod brands with PKPaymentNetwork #1481

Closed miklselsoe closed 11 months ago

miklselsoe commented 12 months ago

Describe the challenge I am trying to determine whether or not to present the ApplePay payment option to my users based on whether it is supported by their device and if the card(s) they have set up in Apple Pay is supported by my Adyen configuration.

When I get the ApplePayPaymentMethod, it has the brands property, which is an array of strings. In order to ask PassKit if ApplePay is set up for any of these brands, I need to translate the brands into a list of PKPaymentNetwork but the strings does not match the raw values of the PKPaymentNetwork struct. I can't find any way to do a translation between the two.

Does this translation exist? How do I determine whether or not ApplePay is configured for the list of cards enabled in my Adyen environment?

Documentation update (optional) I would like a complete reference to the values that can be read from the brands property of ApplePayPaymentMethod. Even better, it would be nice to translate this array into an array of PKPaymentNetwork.

erenbesel commented 11 months ago

@miklselsoe I assume you are not using Dropin which should not show Apple pay as an option if user cannot make payments with it.

And for using stand alone ApplePayComponent, the init of ApplePayComponent throws an error the same way if it can't make payments. You can see the code here.

Hope this helps!

miklselsoe commented 11 months ago

@erenbesel I see. I just need to switch some logic around in order to fix it. Thanks!