stripe / stripe-terminal-android

Stripe Terminal Android SDK
https://stripe.dev/stripe-terminal-android/
Other
93 stars 46 forks source link

Sending a CardPresentRoutingOption Preference will fail in unsupported markets #490

Open pc-coholic opened 2 months ago

pc-coholic commented 2 months ago

Summary

Setting a CardPresentRoutingOption for a on-device generated PaymentIntent will cause an error-message, if the account in question tied to a non-supported country.

  "payment_method_options": {
    "card_present": {
      "routing": {
        "requested_priority": "domestic"
      }
    }
  },

will work fine for a Stripe Account in Germany, but not for one in Portugal.

After experimentation, I can say that this seems to be tied to the Stripe Account country rather then the terminal's location.

In my opinion this code path should never fail and just fall back to the international priority instead of causing a hard 400 parameter_unknown (Received unknown parameter: payment_method_options[card_present][routing])

Code to reproduce

        val params = PaymentIntentParameters.Builder(
                amount = (receipt_total * BigDecimal("100.00")).toLong(),
                currency = event_currency.lowercase(),
                captureMethod = CaptureMethod.Automatic,
                allowedPaymentMethodTypes = getPaymentMethodTypes()
        )
            .setDescription(desc)
            .setStatementDescriptor(desc.substring(0, min(desc.length, 22)))
            .setMetadata(
                mapOf(
                    "app" to "pretixPOS",
                    "appversion" to BuildConfig.VERSION_NAME,
                    "organizer" to conf.organizerSlug,
                    "event" to event_slug,
                    "posid" to conf.devicePosId.toString(),
                    "posserial" to conf.uniqueSerial!!,
                    "receipt" to receipt_id.toString()
                )
            )

                params.setPaymentMethodOptionsParameters(
                    PaymentMethodOptionsParameters.Builder()
                        .setCardPresentParameters(
                            CardPresentParameters.Builder()
                                .setRouting(
                                    CardPresentRoutingOptionParameters(RoutingPriority.DOMESTIC)
                                )
                                .build()
                        )
                        .build()
                )

Android version

Android 10 and others

Impacted devices (Android devices or readers)

No, applies to all

SDK version

3.8.0

Other information

mahirk-stripe commented 3 days ago

Hi @pc-coholic --

I wanted to note that this is expected in countries where we do not support routing priority, such as PT. The above options should only be used in countries where we have enabled domestic debit priority and can be used to change the priority of the card read based off the parameter.