question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

confirmPayment/SetupIntent will fail if some billingDetails key is not given (Android)

See original GitHub issue

Describe 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):

  1. confirm a PI/SI, like so:
const { error, setupIntent } = await confirmSetupIntent(
    stripe_client_secret,
    {
        type: 'Card',
        billingDetails: {},
    },
);
  1. 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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:8

github_iconTop GitHub Comments

1reaction
bill-pairaktaridiscommented, Nov 10, 2021
0reactions
charliecruzan-stripecommented, Mar 4, 2022

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

No results found

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found