paypal / android-checkout-sdk

Apache License 2.0
77 stars 37 forks source link

Shipping addresses with lettered currencies are not mapped to enum #294

Open MiltosKaripidisPoq opened 6 months ago

MiltosKaripidisPoq commented 6 months ago

Describe the bug The PayPal SDK fails to map the currency from the shipping method when the country's currency contains letters rather than symbols. For example, Norway's kr compared to German's .

The failure is happening on the Repository class (1079 line) and specifically in this function:

fun getShippingAndPickUpOptions(selectedShippingMethod: ShippingMethodType): List<Options> {
        val currencyCode: CurrencyCode = when {
            debugConfigManager.currencyCode != null -> debugConfigManager.currencyCode!!
            shippingMethodsList.isNotEmpty() -> CurrencyCode.valueOf(shippingMethodsList.first().amount?.currencyFormatSymbolISOCurrency?.filter { it.isLetter() }.orEmpty())
            pickUpMethodsList.isNotEmpty() -> CurrencyCode.valueOf(pickUpMethodsList.first().amount?.currencyFormatSymbolISOCurrency?.filter { it.isLetter() }.orEmpty())
            else -> CurrencyCode.USD
        }
        ...

In our example, the following line gets the value of currencyFormatSymbolISOCurrency which is zł290PLN. The following line filters it and gets the result złPLN, which of course cannot be mapped to the CurrencyCode enum that expects just PLN.

CurrencyCode.valueOf(shippingMethodsList.first().amount?.currencyFormatSymbolISOCurrency?.filter { it.isLetter() }.orEmpty())

To Reproduce Steps to reproduce the behavior:

  1. Have a shipping method of a country with lettered currency like Poland, Norway, etc.
  2. Click PayPal button to initialise it.

Expected behavior Currency to be mapped correctly so the flow can proceed.

Additional context I am using 1.1.0 version.

The API that is made by PayPal is /graphql and field path from the response is data.checkoutSession.cart.shippingMethods[0].amount.currencyFormatSymbolISOCurrency.

github-actions[bot] commented 6 months ago

Thank you for reaching out to the Native Checkout SDK team. This integration path is now inactive for new merchants. If you are an existing merchant, please contact us here for further assistance.

New merchants can integrate the Native Checkout experience via the Braintree Android SDK or PayPal Android SDK. For more information please see their respective developer documentation linked below.

MiltosKaripidisPoq commented 6 months ago

@chpypl Could you please review it and point me to the right direction? Is it a misconfiguration from my side or an SDK issue? Thanks in advance.

balapoq commented 5 months ago

@MaxHastingsPP / @chpypl can we get some help with this issue please? We have an existing Paypal integration based on this SDK. We are planning to move to the new Braintree/Paypal SDK in the coming months but are currently in the process of launching apps with the existing integration in countries where the currency codes are alphanumeric. This issue is blocking the release of the apps. Any help will be much appreciated 🙏