From 52d6689eac9e82a78c3b3c62f8955d4425ae471c Mon Sep 17 00:00:00 2001 From: Charles Cruzan Date: Thu, 23 Jun 2022 17:34:44 -0400 Subject: [PATCH] [skip actions] resolve with an error if merchantDisplayName isn't provided --- .../java/com/reactnativestripesdk/PaymentSheetFragment.kt | 4 ++++ src/types/PaymentSheet.ts | 3 ++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt b/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt index e2f6329a7..82f209bd1 100644 --- a/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +++ b/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt @@ -49,6 +49,10 @@ class PaymentSheetFragment( override fun onViewCreated(view: View, savedInstanceState: Bundle?) { super.onViewCreated(view, savedInstanceState) val merchantDisplayName = arguments?.getString("merchantDisplayName").orEmpty() + if (merchantDisplayName.isEmpty()) { + initPromise.resolve(createError(ErrorType.Failed.toString(), "merchantDisplayName cannot be empty or null.")) + return + } val customerId = arguments?.getString("customerId").orEmpty() val customerEphemeralKeySecret = arguments?.getString("customerEphemeralKeySecret").orEmpty() val countryCode = arguments?.getString("merchantCountryCode").orEmpty() diff --git a/src/types/PaymentSheet.ts b/src/types/PaymentSheet.ts index b4e4db9b4..c51d68936 100644 --- a/src/types/PaymentSheet.ts +++ b/src/types/PaymentSheet.ts @@ -3,10 +3,11 @@ import type { BillingDetails } from './Common'; export type SetupParams = ClientSecretParams & GooglePayParams & ApplePayParams & { + /** Your customer-facing business name. On Android, this is required and cannot be an empty string. */ + merchantDisplayName: string; customerId?: string; customerEphemeralKeySecret?: string; customFlow?: boolean; - merchantDisplayName?: string; style?: 'alwaysLight' | 'alwaysDark' | 'automatic'; returnURL?: string; defaultBillingDetails?: BillingDetails;