stripe-react-native icon indicating copy to clipboard operation
stripe-react-native copied to clipboard

confirmPayment should work with an empty data (no payment method provided at that step)

Open tlvenn opened this issue 4 years ago • 10 comments

Describe the bug Right now the SDK is expecting a type along some other parameters. If when a payment method is created on the server, a payment method is already provided at that time, we should be able to simply confirm the payment without providing any payment information.

The rest api clearly shows that all parameters are optionals

https://stripe.com/docs/api/payment_intents/confirm

Expected behavior We should be able to pass no payment method info at all and leave the data object empty.

tlvenn avatar Sep 27 '21 16:09 tlvenn

Same problem, I always get an error indicating that I need to add a payment_method

OussJouh avatar Sep 28 '21 22:09 OussJouh

@tlvenn @OussJouh can you provide code snippet so I can take a look over it?

arekkubaczkowski avatar Sep 29 '21 06:09 arekkubaczkowski

Hi @arekkubaczkowski,

Not sure what a code snippet will provide...

If we agree that we should be able to confirm a payment without providing a payment method as the Stripe api doc says, then looking at the type definition of the confirmPayment, we can see that the params type is mandatory while it should be optional.

If you attempt to ignore it, the sdk emits an error as follow:

ERROR {"code": "Failed", "declineCode": null, "localizedMessage": "You must provide paymentMethodType", "message": "You must provide paymentMethodType", "stripeErrorCode": null, "type": null}

If you have a look at the android SDK for example:

https://stripe.dev/stripe-android/payments-core/com.stripe.android/confirm-payment-intent.html

The ConfirmPaymentIntentParams data class has pretty much all its properties optionals just like the rest API:

https://stripe.dev/stripe-android/payments-core/com.stripe.android.model/-confirm-payment-intent-params/index.html

tlvenn avatar Sep 29 '21 08:09 tlvenn

@tlvenn required params are dependent on payment type, so in case type=Card apart from clientSecret there is no any mandatory params. please follow our example code https://github.com/stripe/stripe-react-native/blob/master/example/src/screens/WebhookPaymentScreen.tsx#L54

arekkubaczkowski avatar Sep 29 '21 08:09 arekkubaczkowski

The thing is I don't want to have to provide a payment type at all, this has been setup on the server when the payment intent was created, I should not have to do it again and somehow pass this information to the client.

Moreover, if you do attempt to simply use type=card (we tried...), the sdk still emits an error because it expects to be able to get the card details which is kinda expected.

ERROR {"code": "Failed", "declineCode": null, "localizedMessage": "Card details not complete", "message": "Card details not complete", "stripeErrorCode": null, "type": null}

Fundamentally what the RN layer is missing is that you can totally confirm a payment method that was created on the server without passing any card / payment method info at all, the premise for this to work of course is that you have attached the desired payment method to the payment intent when you created it.

tlvenn avatar Sep 29 '21 08:09 tlvenn

I believe in such case you don't need to use this SDK for such action at all, perhaps you can just confirm the payment on the server side like here https://github.com/stripe/stripe-react-native/blob/master/example/server/index.ts#L301 But I am not 100% sure if it's exactly what you want to accomplish.

@paulasjes-stripe could you elaborate more regarding this?

arekkubaczkowski avatar Sep 29 '21 10:09 arekkubaczkowski

You do need the SDK, the whole point of confirming the payment intent on the device with the user is to handle SCA Flow if needed, this is not something you can do on the server.

tlvenn avatar Sep 29 '21 12:09 tlvenn

You do need the SDK, the whole point of confirming the payment intent on the device with the user is to handle SCA Flow if needed, this is not something you can do on the server.

Were you able to solve the problem?

alexcatmu avatar Nov 10 '21 17:11 alexcatmu

For now, as a workaround, we make sure to pass the payment id from the server to the client so that the client can provide it again to fulfill the current confirmPayment requirements.

tlvenn avatar Nov 11 '21 08:11 tlvenn

will be addressed in https://github.com/stripe/stripe-react-native/pull/1084

charliecruzan-stripe avatar Aug 10 '22 22:08 charliecruzan-stripe