confirmPayment/SetupIntent will fail if some billingDetails key is not given (Android)
See original GitHub issueDescribe the bug On Android (only), confirming a Payment/SetupIntent will fail if one of name, email or phone keys are not given in the billingDetails object.
To Reproduce Steps to reproduce the behavior (Android):
- confirm a PI/SI, like so:
const { error, setupIntent } = await confirmSetupIntent(
stripe_client_secret,
{
type: 'Card',
billingDetails: {},
},
);
- You’ll get the error:
{
stripeErrorCode: "parameter_invalid_empty",
declineCode: null,
localizedMessage: "You passed an empty string for 'payment_method_data[billing_details][name]'. We assume empty values are an attempt to unset a parameter; however 'payment_method_data[billing_details][name]' cannot be unset. You should remove 'payment_method_data[billing_details][name]' from your request or supply a non-empty value.",
message: "You passed an empty string for 'payment_method_data[billing_details][name]'. We assume empty values are an attempt to unset a parameter; however 'payment_method_data[billing_details][name]' cannot be unset. You should remove 'payment_method_data[billing_details][name]' from your request or supply a non-empty value.",
type: "invalid_request_error",
code: "Failed"
}
Note: errors differ depending on which key is “missing” in billingDetails
Expected behavior I expect the PI/SI not to fail when not defining billingDetails keys.
Screenshots
If applicable, add screenshots to help explain your problem.
Desktop (please complete the following information):
- OS: MacOS
- Version: Big Sur
Smartphone (please complete the following information):
- Device: OnePlus 5T
- OS: Android
- Version: 10
Additional context I have applied this patch to fix the issue, for stripe-react-native version 0.2.3:
diff --git a/node_modules/@stripe/stripe-react-native/android/src/main/java/com/reactnativestripesdk/Mappers.kt b/node_modules/@stripe/stripe-react-native/android/src/main/java/com/reactnativestripesdk/Mappers.kt
index bc41f6e..70b22d0 100644
--- a/node_modules/@stripe/stripe-react-native/android/src/main/java/com/reactnativestripesdk/Mappers.kt
+++ b/node_modules/@stripe/stripe-react-native/android/src/main/java/com/reactnativestripesdk/Mappers.kt
@@ -441,9 +441,9 @@ internal fun mapToBillingDetails(billingDetails: ReadableMap?, cardAddress: Addr
return PaymentMethod.BillingDetails.Builder()
.setAddress(address.build())
- .setName(getValOr(billingDetails, "name"))
- .setPhone(getValOr(billingDetails, "phone"))
- .setEmail(getValOr(billingDetails, "email"))
+ .setName(getValOr(billingDetails, "name", null))
+ .setPhone(getValOr(billingDetails, "phone", null))
+ .setEmail(getValOr(billingDetails, "email", null))
.build()
}
The issue I found was that the result of getValOr()
defaults to an empty string. This empty string is then sent and taken into account by the API, which will then reject the given (empty) string.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:8
This PR seems related https://github.com/stripe/stripe-react-native/pull/687
Closing this as I think it was fixed by https://github.com/stripe/stripe-react-native/pull/751, but if not please share a reproducible demo I can use to get the same error!