Closed thorsten-stripe closed 3 years ago
Hi, thanks for investigating,
I looked into it and I know where these differences came from.
iOS sdk has little bit different PaymentIntent
interface than android for example:
android:
override val id: String?,
iOS:
/// The Stripe ID of the PaymentIntent. @objc public let stripeId: String
We will try to unify these differences but I have one point regarding response interface,
our tenet about responses in whole SDK is that we returns either Success data
or Error data
not like you suggested,
so we would have to make this change in every response to keep consistency, so the choice is up to you.
@bg-stripe can I get you to chime in here? Seems like there are quite some differences between Stripe.js, iOS, and Android, and we need to make a decision which DX we want to model after.
Same with naming:
handleCardAction
(https://stripe.com/docs/payments/accept-a-payment-synchronously#web-handle-next-actions)handleNextAction
(https://stripe.com/docs/payments/accept-a-payment-synchronously#ios-handle-next-actions)handleNextActionForPayment
(https://stripe.com/docs/payments/accept-a-payment-synchronously#android-handle-next-actions)handleNextPaymentAction
(https://github.com/stripe/stripe-react-native/blob/master/docs/api-reference.md#L19)While I do think that handleNextPaymentAction
is very descriptive, I don't like the idea of each SDK having a different name. I think we should make a decision which SDK we want RN to be closest to @bg-stripe @auchenberg-stripe
Hm, yeah the iOS & Android responses should be the same. On iOS, we use stripeId
because id
is a reserved symbol. For React Native, we should just use id
for both platforms.
I don't think we need to change the responses drastically here. It looks like the iOS response includes a "id":"pm_1I96wnG7gfqYEkPOFrjhO6SK",
– I think we should exclude this payment method ID from the iOS response if it isn't included on Android.
For handle action naming – I think we should align on handleCardAction
, since that would let us use the diagram in the web tab of the docs (cc @davidme-stripe )
Do you have an example of the iOS SDK having a property/field that the Android SDK doesn't?
@mshafrir-stripe yeah – based on https://github.com/stripe/stripe-react-native/issues/11#issue-785004477 – looks like there's a pm_ID
in the iOS response, but not on Android...
This might be because the Android SDK is expanding the payment_method
field, so that it is in the shape of a PaymentMethod
object, not a payment method id.
See https://stripe.com/docs/api/payment_intents/object#payment_intent_object-payment_method
Yes, looks like the id
is the only difference between both platforms but I've noticed also that setupFutureUsage
on android is a private field while on iOS is public so I assume that we should omit this info?
btw. what is the decision about handleNextPaymentAction
method name?
After #41 the responses are:
iOS
{
"amount":1400,
"captureMethod":"Automatic",
"clientSecret":"pi_1IB09zG7gfqYEkPO9gIOdVkR_secret_dL92dVo4w74p6ctWVEz5EqPmX",
"confirmationMethod":"Manual",
"created":1610985655,
"currency":"usd",
"description":"<Stripe.STPPaymentIntent: 0x6000000c8c30; stripeId = pi_1IB09zG7gfqYEkPO9gIOdVkR; amount = 1400; canceledAt = nil; captureMethod = Optional(\"automatic\"); clientSecret = <redacted>; confirmationMethod = Optional(\"manual\"); created = 2021-01-18 16:00:55 +0000; currency = usd; description = nil; lastPaymentError = nil; livemode = false; nextAction = nil; paymentMethodId = Optional(\"pm_1IB09xG7gfqYEkPOGhVBwBKw\"); paymentMethod = Optional(<Stripe.STPPaymentMethod: 0x6000006d71e0; stripeId = pm_1IB09xG7gfqYEkPOGhVBwBKw; alipay = nil; auBECSDebit = nil; bacsDebit = nil; bancontact = nil; billingDetails = Optional(<Stripe.STPPaymentMethodBillingDetails: 0x600001c88140; name = ; phone = ; email = ; address = Optional(<Stripe.STPPaymentMethodAddress: 0x60000118b980; line1 = ; line2 = ; city = ; state = ; postalCode = ; country = >)>); card = Optional(<Stripe.STPPaymentMethodCard: 0x600000dd57a0; brand = Visa; checks = <Stripe.STPPaymentMethodCardChecks: 0x60000313d1d0; addressLine1Check: ; addressPostalCodeCheck: ; cvcCheck: >; country = DE; expMonth = 3; expYear = 2022; funding = credit; last4 = 3184; fingerprint = ; networks = <Stripe.STPPaymentMethodCardNetworks: 0x60000313c4b0; available: [\"visa\"]; preferred: >; threeDSecureUsage = <Stripe.STPPaymentMethodThreeDSecureUsage: 0x6000038e0b00; supported: YES>; wallet = >); cardPresent = nil; created = Optional(2021-01-18 16:00:53 +0000); customerId = ; ideal = nil; eps = nil; fpx = nil; giropay = nil; oxxo = nil; grabPay = nil; payPal = nil; przelewy24 = nil; sepaDebit = nil; sofort = nil; upi = nil; liveMode = NO; type = card>); paymentMethodTypes = Optional([\"card\"]); receiptEmail = nil; setupFutureUsage = nil; shipping = nil; sourceId = nil; status = Optional(\"requires_confirmation\")>",
"id":"pi_1IB09zG7gfqYEkPO9gIOdVkR",
"isLiveMode":false,
"paymentMethodId":"pm_1IB09xG7gfqYEkPOGhVBwBKw",
"receiptEmail":"",
"status":"RequiresConfirmation"
}
Android
{
"amount":1400,
"canceledAt":0,
"captureMethod":"Automatic",
"clientSecret":"pi_1IB0K6G7gfqYEkPOur6tzOeH_secret_2vQdogsDXNlm0LRH0m7bpVQyA",
"confirmationMethod":"Manual",
"created":1610986282,
"currency":"usd",
"description":null,
"id":"pi_1IB0K6G7gfqYEkPOur6tzOeH",
"isLiveMode":false,
"paymentMethodId":"pm_1IB0K4G7gfqYEkPOO4m13a9x",
"receiptEmail":null,
"status":"RequiresConfirmation"
}
I'm not entirely sure about the long description string on iOS that seems to be representing the whole object, @bg-stripe is this expected? Otherwise, this LGTM 👍
Regarding naming, we decided to go with handleCardAction
as this is a method that doesn't exist for other payment methods: https://stripe.com/docs/js/payment_intents/handle_card_action, and we'll be able to reuse the graphic in the docs. Would you be able to incorporate the naming change into #41 ?
@arekkubaczkowski quick question regarding
I have one point regarding response interface, our tenet about responses in whole SDK is that we returns either Success data or Error data
You're saying that you're either resolving with success data or rejecting with error data, correct? In Stripe.js we don't reject but rather return the error, see: https://github.com/stripe/stripe-js/blob/master/types/stripe-js/index.d.ts#L265-L267
I'll discuss with the team how we want to go about this in RN.
You're saying that you're either resolving with success data or rejecting with error data, correct?
yes, this is exactly what I meant
I'll discuss with the team how we want to go about this in RN.
ok cool
Describe the bug The NoWebhookPayment example is working fine on iOS but on Android after the 3D Secure keeps spinning endlessly.
This is due to
handleNextPaymentAction
having different return values on iOS vs Android.Also,
stripeId
is not a good name for the PaymentIntent ID. As per https://stripe.com/docs/js/payment_intents/handle_card_action it would be better to returnTo Reproduce Steps to reproduce the behavior:
yarn example start
yarn example android
Expected behavior Same response shape across platforms.