@stripe/stripe-react-native 0.65.0 → 0.66.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/android/detekt/detekt-baseline.xml +1 -76
- package/android/gradle.properties +4 -4
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormView.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/AuBECSDebitFormViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +56 -58
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementEvent.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +139 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +59 -0
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementView.kt +105 -49
- package/android/src/main/java/com/reactnativestripesdk/EmbeddedPaymentElementViewManager.kt +72 -12
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetManager.kt +8 -4
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayButtonView.kt +26 -11
- package/android/src/main/java/com/reactnativestripesdk/GooglePayLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/NavigationBarView.kt +14 -5
- package/android/src/main/java/com/reactnativestripesdk/PaymentElementConfig.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodCreateParamsFactory.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementConfig.kt +6 -2
- package/android/src/main/java/com/reactnativestripesdk/PaymentMethodMessagingElementViewManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentOptionDisplayDataMapper.kt +8 -4
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +9 -3
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +118 -48
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +281 -46
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +2 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +8 -18
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerAdapter.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/customersheet/ReactNativeCustomerSessionProvider.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/pushprovisioning/AddToWalletButtonManager.kt +2 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutAddressUpdate.kt +45 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +127 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt +41 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Errors.kt +4 -2
- package/android/src/main/java/com/reactnativestripesdk/utils/Extensions.kt +5 -1
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +29 -13
- package/android/src/main/java/com/reactnativestripesdk/utils/PostalCodeUtilities.kt +2 -1
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerDelegate.java +6 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/EmbeddedPaymentElementViewManagerInterface.java +2 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerDelegate.java +35 -0
- package/android/src/oldarch/java/com/facebook/react/viewmanagers/StripeCurrencySelectorElementManagerInterface.java +18 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +17 -3
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +13 -1
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampMappers.kt +116 -0
- package/android/src/onramp/java/com/reactnativestripesdk/OnrampSdkModule.kt +109 -1
- package/android/src/test/java/com/reactnativestripesdk/DrawableLoadingTest.kt +6 -2
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +60 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +145 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +9 -4
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +98 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +57 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +6 -8
- package/ios/CurrencySelectorElementManager.m +16 -0
- package/ios/CurrencySelectorElementView.swift +159 -0
- package/ios/EmbeddedPaymentElementView.swift +1 -1
- package/ios/Mappers+Checkout.swift +337 -0
- package/ios/Mappers.swift +90 -2
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +16 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.h +10 -0
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +89 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.h +1 -0
- package/ios/OldArch/StripeSdkEventEmitterCompat.m +6 -0
- package/ios/PaymentOptionDisplayData+ReactNative.swift +1 -1
- package/ios/PaymentSheetAppearance.swift +1 -1
- package/ios/StripeOnrampSdk.mm +19 -0
- package/ios/StripeSdk.mm +136 -0
- package/ios/StripeSdkEmitter.swift +1 -0
- package/ios/StripeSdkImpl+Checkout.swift +360 -0
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+Embedded.swift +108 -27
- package/ios/StripeSdkImpl+PaymentSheet.swift +18 -2
- package/ios/StripeSdkImpl.swift +89 -7
- package/jest/mock.js +13 -1
- package/lib/commonjs/components/AddToWalletButton.js +1 -1
- package/lib/commonjs/components/AddToWalletButton.js.map +1 -1
- package/lib/commonjs/components/AddressSheet.js +1 -1
- package/lib/commonjs/components/AddressSheet.js.map +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js +1 -1
- package/lib/commonjs/components/AuBECSDebitForm.js.map +1 -1
- package/lib/commonjs/components/CardField.js +1 -1
- package/lib/commonjs/components/CardField.js.map +1 -1
- package/lib/commonjs/components/CardForm.js +1 -1
- package/lib/commonjs/components/CardForm.js.map +1 -1
- package/lib/commonjs/components/CurrencySelectorElement.js +2 -0
- package/lib/commonjs/components/CurrencySelectorElement.js.map +1 -0
- package/lib/commonjs/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +1 -1
- package/lib/commonjs/components/PlatformPayButton.js +1 -1
- package/lib/commonjs/components/PlatformPayButton.js.map +1 -1
- package/lib/commonjs/components/StripeContainer.js +1 -1
- package/lib/commonjs/components/StripeContainer.js.map +1 -1
- package/lib/commonjs/connect/Components.js +1 -1
- package/lib/commonjs/connect/Components.js.map +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js +1 -1
- package/lib/commonjs/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js +1 -1
- package/lib/commonjs/connect/EmbeddedComponent.js.map +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js +1 -1
- package/lib/commonjs/connect/ModalCloseButton.js.map +1 -1
- package/lib/commonjs/connect/NavigationBar.js +1 -1
- package/lib/commonjs/connect/NavigationBar.js.map +1 -1
- package/lib/commonjs/events.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/helpers.js +1 -1
- package/lib/commonjs/hooks/useCheckout.js +1 -1
- package/lib/commonjs/hooks/useCheckout.js.map +1 -1
- package/lib/commonjs/hooks/useOnramp.js +1 -1
- package/lib/commonjs/hooks/useOnramp.js.map +1 -1
- package/lib/commonjs/specs/NativeAddToWalletButton.js +1 -1
- package/lib/commonjs/specs/NativeAddressSheet.js +1 -1
- package/lib/commonjs/specs/NativeApplePayButton.js +1 -1
- package/lib/commonjs/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js +1 -1
- package/lib/commonjs/specs/NativeCardField.js.map +1 -1
- package/lib/commonjs/specs/NativeCardForm.js +1 -1
- package/lib/commonjs/specs/NativeCardForm.js.map +1 -1
- package/lib/commonjs/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/commonjs/specs/NativeCurrencySelectorElement.js +2 -0
- package/lib/commonjs/specs/NativeCurrencySelectorElement.js.map +1 -0
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/commonjs/specs/NativeGooglePayButton.js +1 -1
- package/lib/commonjs/specs/NativeNavigationBar.js +1 -1
- package/lib/commonjs/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/commonjs/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/specs/NativeStripeContainer.js +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js +1 -1
- package/lib/commonjs/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/module/components/AddToWalletButton.js +1 -1
- package/lib/module/components/AddToWalletButton.js.map +1 -1
- package/lib/module/components/AddressSheet.js +1 -1
- package/lib/module/components/AddressSheet.js.map +1 -1
- package/lib/module/components/AuBECSDebitForm.js +1 -1
- package/lib/module/components/AuBECSDebitForm.js.map +1 -1
- package/lib/module/components/CardField.js +1 -1
- package/lib/module/components/CardField.js.map +1 -1
- package/lib/module/components/CardForm.js +1 -1
- package/lib/module/components/CardForm.js.map +1 -1
- package/lib/module/components/CurrencySelectorElement.js +2 -0
- package/lib/module/components/CurrencySelectorElement.js.map +1 -0
- package/lib/module/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.js.map +1 -1
- package/lib/module/components/PlatformPayButton.js +1 -1
- package/lib/module/components/PlatformPayButton.js.map +1 -1
- package/lib/module/components/StripeContainer.js +1 -1
- package/lib/module/components/StripeContainer.js.map +1 -1
- package/lib/module/connect/Components.js +1 -1
- package/lib/module/connect/Components.js.map +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js +1 -1
- package/lib/module/connect/ConnectComponentsProvider.js.map +1 -1
- package/lib/module/connect/EmbeddedComponent.js +1 -1
- package/lib/module/connect/EmbeddedComponent.js.map +1 -1
- package/lib/module/connect/ModalCloseButton.js +1 -1
- package/lib/module/connect/ModalCloseButton.js.map +1 -1
- package/lib/module/connect/NavigationBar.js +1 -1
- package/lib/module/connect/NavigationBar.js.map +1 -1
- package/lib/module/events.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/helpers.js +1 -1
- package/lib/module/hooks/useCheckout.js +1 -1
- package/lib/module/hooks/useCheckout.js.map +1 -1
- package/lib/module/hooks/useOnramp.js +1 -1
- package/lib/module/hooks/useOnramp.js.map +1 -1
- package/lib/module/specs/NativeAddToWalletButton.js +1 -1
- package/lib/module/specs/NativeAddressSheet.js +1 -1
- package/lib/module/specs/NativeApplePayButton.js +1 -1
- package/lib/module/specs/NativeAuBECSDebitForm.js +1 -1
- package/lib/module/specs/NativeCardField.js +1 -1
- package/lib/module/specs/NativeCardField.js.map +1 -1
- package/lib/module/specs/NativeCardForm.js +1 -1
- package/lib/module/specs/NativeCardForm.js.map +1 -1
- package/lib/module/specs/NativeConnectAccountOnboardingView.js +1 -1
- package/lib/module/specs/NativeCurrencySelectorElement.js +2 -0
- package/lib/module/specs/NativeCurrencySelectorElement.js.map +1 -0
- package/lib/module/specs/NativeEmbeddedPaymentElement.js +1 -1
- package/lib/module/specs/NativeEmbeddedPaymentElement.js.map +1 -1
- package/lib/module/specs/NativeGooglePayButton.js +1 -1
- package/lib/module/specs/NativeNavigationBar.js +1 -1
- package/lib/module/specs/NativeOnrampSdkModule.js.map +1 -1
- package/lib/module/specs/NativePaymentMethodMessagingElement.js +1 -1
- package/lib/module/specs/NativeStripeContainer.js +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js +1 -1
- package/lib/module/types/EmbeddedPaymentElement.js.map +1 -1
- package/lib/typescript/src/components/CurrencySelectorElement.d.ts +62 -0
- package/lib/typescript/src/components/CurrencySelectorElement.d.ts.map +1 -0
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts +1 -1
- package/lib/typescript/src/components/PaymentMethodMessagingElement.d.ts.map +1 -1
- package/lib/typescript/src/events.d.ts +11 -0
- package/lib/typescript/src/events.d.ts.map +1 -1
- package/lib/typescript/src/functions.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useCheckout.d.ts.map +1 -1
- package/lib/typescript/src/hooks/useOnramp.d.ts +22 -0
- package/lib/typescript/src/hooks/useOnramp.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts +25 -0
- package/lib/typescript/src/specs/NativeCurrencySelectorElement.d.ts.map +1 -0
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts +5 -1
- package/lib/typescript/src/specs/NativeEmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +5 -2
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +268 -86
- package/lib/typescript/src/types/Checkout.d.ts.map +1 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +36 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/lib/typescript/src/types/Onramp.d.ts +94 -0
- package/lib/typescript/src/types/Onramp.d.ts.map +1 -1
- package/package.json +16 -4
- package/src/components/CurrencySelectorElement.tsx +95 -0
- package/src/components/PaymentMethodMessagingElement.tsx +54 -52
- package/src/events.ts +11 -0
- package/src/functions.ts +30 -1
- package/src/hooks/useCheckout.tsx +129 -74
- package/src/hooks/useOnramp.tsx +44 -0
- package/src/specs/NativeCurrencySelectorElement.ts +35 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +12 -2
- package/src/specs/NativeOnrampSdkModule.ts +5 -0
- package/src/specs/NativeStripeSdkModule.ts +16 -2
- package/src/types/Checkout.ts +291 -86
- package/src/types/EmbeddedPaymentElement.tsx +117 -26
- package/src/types/Onramp.ts +109 -0
- package/stripe-react-native.podspec +1 -1
- package/android/.idea/AndroidProjectSystem.xml +0 -6
- package/android/.idea/caches/deviceStreaming.xml +0 -835
- package/android/.idea/compiler.xml +0 -6
- package/android/.idea/gradle.xml +0 -17
- package/android/.idea/migrations.xml +0 -10
- package/android/.idea/misc.xml +0 -10
- package/android/.idea/runConfigurations.xml +0 -17
- package/android/.idea/vcs.xml +0 -6
- package/android/local.properties +0 -8
|
@@ -13,6 +13,7 @@ import type {
|
|
|
13
13
|
CardBrand,
|
|
14
14
|
} from './Common';
|
|
15
15
|
import type { PaymentMethod } from '.';
|
|
16
|
+
import type { Checkout } from './Checkout';
|
|
16
17
|
import type * as ConfirmationToken from './ConfirmationToken';
|
|
17
18
|
import * as PaymentSheetTypes from './PaymentSheet';
|
|
18
19
|
import NativeStripeSdkModule from '../specs/NativeStripeSdkModule';
|
|
@@ -222,21 +223,38 @@ export interface EmbeddedPaymentElementConfiguration {
|
|
|
222
223
|
opensCardScannerAutomatically?: boolean;
|
|
223
224
|
}
|
|
224
225
|
|
|
226
|
+
// Narrows a value to `Checkout` vs. `IntentConfiguration`.
|
|
227
|
+
const isCheckoutSession = (
|
|
228
|
+
value: PaymentSheetTypes.IntentConfiguration | Checkout
|
|
229
|
+
): value is Checkout =>
|
|
230
|
+
typeof value === 'object' &&
|
|
231
|
+
value !== null &&
|
|
232
|
+
'sessionKey' in value &&
|
|
233
|
+
!('mode' in value);
|
|
234
|
+
|
|
225
235
|
// -----------------------------------------------------------------------------
|
|
226
236
|
// Embedded API
|
|
227
237
|
// -----------------------------------------------------------------------------
|
|
228
238
|
|
|
229
239
|
class EmbeddedPaymentElement {
|
|
230
240
|
/**
|
|
231
|
-
* Call this when the intent configuration
|
|
241
|
+
* Call this when the intent configuration or Checkout Session changes.
|
|
232
242
|
* Cancels any in-progress update. Ensures the correct payment methods are shown and fields are collected.
|
|
233
243
|
* If the selected payment option becomes invalid, it may be cleared.
|
|
234
244
|
* Returns the final result of the update; earlier in-flight updates will return `{ status: 'canceled' }`.
|
|
235
245
|
*/
|
|
236
|
-
async
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
return
|
|
246
|
+
async updateIntent(
|
|
247
|
+
intentConfig: PaymentSheetTypes.IntentConfiguration
|
|
248
|
+
): Promise<unknown> {
|
|
249
|
+
return await NativeStripeSdkModule.updateEmbeddedPaymentElement(
|
|
250
|
+
intentConfig
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
async updateCheckout(checkout: Checkout): Promise<unknown> {
|
|
255
|
+
return await NativeStripeSdkModule.updateEmbeddedPaymentElementWithCheckout(
|
|
256
|
+
checkout.sessionKey
|
|
257
|
+
);
|
|
240
258
|
}
|
|
241
259
|
|
|
242
260
|
/**
|
|
@@ -268,21 +286,28 @@ let customPaymentMethodConfirmCallback: EventSubscription | null = null;
|
|
|
268
286
|
let rowSelectionCallback: EventSubscription | null = null;
|
|
269
287
|
|
|
270
288
|
async function createEmbeddedPaymentElement(
|
|
271
|
-
|
|
289
|
+
intent: PaymentSheetTypes.IntentConfiguration | Checkout,
|
|
272
290
|
configuration: EmbeddedPaymentElementConfiguration
|
|
273
291
|
): Promise<EmbeddedPaymentElement> {
|
|
274
|
-
|
|
292
|
+
setupConfigurationHandlers(configuration);
|
|
275
293
|
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
294
|
+
if (isCheckoutSession(intent)) {
|
|
295
|
+
await NativeStripeSdkModule.createEmbeddedPaymentElementWithCheckout(
|
|
296
|
+
intent.sessionKey,
|
|
297
|
+
configuration
|
|
298
|
+
);
|
|
299
|
+
} else {
|
|
300
|
+
setupIntentConfirmHandlers(intent);
|
|
301
|
+
await NativeStripeSdkModule.createEmbeddedPaymentElement(
|
|
302
|
+
intent,
|
|
303
|
+
configuration
|
|
304
|
+
);
|
|
305
|
+
}
|
|
280
306
|
return new EmbeddedPaymentElement();
|
|
281
307
|
}
|
|
282
308
|
|
|
283
|
-
function
|
|
284
|
-
intentConfig: PaymentSheetTypes.IntentConfiguration
|
|
285
|
-
configuration: EmbeddedPaymentElementConfiguration
|
|
309
|
+
function setupIntentConfirmHandlers(
|
|
310
|
+
intentConfig: PaymentSheetTypes.IntentConfiguration
|
|
286
311
|
) {
|
|
287
312
|
const confirmHandler = intentConfig.confirmHandler;
|
|
288
313
|
if (confirmHandler) {
|
|
@@ -323,7 +348,11 @@ function setupConfirmAndSelectionHandlers(
|
|
|
323
348
|
}
|
|
324
349
|
);
|
|
325
350
|
}
|
|
351
|
+
}
|
|
326
352
|
|
|
353
|
+
function setupConfigurationHandlers(
|
|
354
|
+
configuration: EmbeddedPaymentElementConfiguration
|
|
355
|
+
) {
|
|
327
356
|
if (configuration.formSheetAction?.type === 'confirm') {
|
|
328
357
|
const confirmFormSheetHandler =
|
|
329
358
|
configuration.formSheetAction.onFormSheetConfirmComplete;
|
|
@@ -409,7 +438,16 @@ export interface UseEmbeddedPaymentElementResult {
|
|
|
409
438
|
* @note Upon completion, `paymentOption` may become null if it's no longer available.
|
|
410
439
|
* @note If you call `update` while a previous call to `update` is still in progress, the previous call is canceled.
|
|
411
440
|
*/
|
|
412
|
-
update:
|
|
441
|
+
update: {
|
|
442
|
+
(intentConfig: PaymentSheetTypes.IntentConfiguration): void;
|
|
443
|
+
/**
|
|
444
|
+
* Call this method when the Checkout Session values you used to initialize
|
|
445
|
+
* `EmbeddedPaymentElement` change.
|
|
446
|
+
* @checkoutSessionsPreview
|
|
447
|
+
* @internal
|
|
448
|
+
*/
|
|
449
|
+
(checkout: Checkout): void;
|
|
450
|
+
};
|
|
413
451
|
// Sets the currently selected payment option to null
|
|
414
452
|
clearPaymentOption: () => void;
|
|
415
453
|
// Any error encountered during creation/update, or null
|
|
@@ -429,6 +467,38 @@ export interface UseEmbeddedPaymentElementResult {
|
|
|
429
467
|
export function useEmbeddedPaymentElement(
|
|
430
468
|
intentConfig: PaymentSheetTypes.IntentConfiguration,
|
|
431
469
|
configuration: EmbeddedPaymentElementConfiguration
|
|
470
|
+
): UseEmbeddedPaymentElementResult;
|
|
471
|
+
/**
|
|
472
|
+
* Initializes an `EmbeddedPaymentElement` from a Stripe Checkout Session.
|
|
473
|
+
*
|
|
474
|
+
* Pass a loaded handle from `useCheckout`. Render the consumer in a child
|
|
475
|
+
* component so the hook only runs once `state.status === 'loaded'`.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* function Cart() {
|
|
479
|
+
* const { checkout, state } = useCheckout(clientSecret);
|
|
480
|
+
* if (state?.status !== 'loaded') return null;
|
|
481
|
+
* return <EmbeddedCheckout checkout={checkout} />;
|
|
482
|
+
* }
|
|
483
|
+
*
|
|
484
|
+
* function EmbeddedCheckout({ checkout }: { checkout: Checkout }) {
|
|
485
|
+
* const { embeddedPaymentElementView } =
|
|
486
|
+
* useEmbeddedPaymentElement(checkout, configuration);
|
|
487
|
+
* return embeddedPaymentElementView;
|
|
488
|
+
* }
|
|
489
|
+
*
|
|
490
|
+
* @param checkout - A loaded `Checkout` handle from `useCheckout`.
|
|
491
|
+
* @param configuration - Configuration for the embedded element.
|
|
492
|
+
* @checkoutSessionsPreview
|
|
493
|
+
* @internal
|
|
494
|
+
*/
|
|
495
|
+
export function useEmbeddedPaymentElement(
|
|
496
|
+
checkout: Checkout,
|
|
497
|
+
configuration: EmbeddedPaymentElementConfiguration
|
|
498
|
+
): UseEmbeddedPaymentElementResult;
|
|
499
|
+
export function useEmbeddedPaymentElement(
|
|
500
|
+
intent: PaymentSheetTypes.IntentConfiguration | Checkout,
|
|
501
|
+
configuration: EmbeddedPaymentElementConfiguration
|
|
432
502
|
): UseEmbeddedPaymentElementResult {
|
|
433
503
|
const isAndroid = Platform.OS === 'android';
|
|
434
504
|
const elementRef = useRef<EmbeddedPaymentElement | null>(null);
|
|
@@ -454,12 +524,18 @@ export function useEmbeddedPaymentElement(
|
|
|
454
524
|
return ref.current;
|
|
455
525
|
}
|
|
456
526
|
|
|
527
|
+
// Re-key on the session key (Checkout) or intent object so we only
|
|
528
|
+
// recreate the element when the source actually changes.
|
|
529
|
+
const intentKey = isCheckoutSession(intent) ? intent.sessionKey : intent;
|
|
530
|
+
const intentRef = useRef(intent);
|
|
531
|
+
intentRef.current = intent;
|
|
532
|
+
|
|
457
533
|
// Create embedded payment element
|
|
458
534
|
useEffect(() => {
|
|
459
535
|
let active = true;
|
|
460
536
|
(async () => {
|
|
461
537
|
const el = await createEmbeddedPaymentElement(
|
|
462
|
-
|
|
538
|
+
intentRef.current,
|
|
463
539
|
configuration
|
|
464
540
|
);
|
|
465
541
|
if (!active) return;
|
|
@@ -471,7 +547,7 @@ export function useEmbeddedPaymentElement(
|
|
|
471
547
|
elementRef.current = null;
|
|
472
548
|
setElement(null);
|
|
473
549
|
};
|
|
474
|
-
}, [
|
|
550
|
+
}, [intentKey, configuration, viewRef, isAndroid]);
|
|
475
551
|
|
|
476
552
|
useEffect(() => {
|
|
477
553
|
const sub = addListener(
|
|
@@ -509,13 +585,19 @@ export function useEmbeddedPaymentElement(
|
|
|
509
585
|
|
|
510
586
|
// Render the embedded view
|
|
511
587
|
const embeddedPaymentElementView = useMemo(() => {
|
|
512
|
-
|
|
588
|
+
// `intentKey` is the session key string for Checkout, the IntentConfiguration object otherwise.
|
|
589
|
+
const intentProps =
|
|
590
|
+
typeof intentKey === 'string'
|
|
591
|
+
? { checkout: { sessionKey: intentKey } }
|
|
592
|
+
: { intentConfiguration: intentKey };
|
|
593
|
+
|
|
594
|
+
if (isAndroid && configuration && intentKey) {
|
|
513
595
|
return (
|
|
514
596
|
<NativeEmbeddedPaymentElement
|
|
515
597
|
ref={viewRef}
|
|
516
598
|
style={[{ width: '100%', height: height }]}
|
|
517
599
|
configuration={configuration}
|
|
518
|
-
|
|
600
|
+
{...intentProps}
|
|
519
601
|
/>
|
|
520
602
|
);
|
|
521
603
|
}
|
|
@@ -525,10 +607,10 @@ export function useEmbeddedPaymentElement(
|
|
|
525
607
|
ref={viewRef}
|
|
526
608
|
style={{ width: '100%', height }}
|
|
527
609
|
configuration={configuration}
|
|
528
|
-
|
|
610
|
+
{...intentProps}
|
|
529
611
|
/>
|
|
530
612
|
);
|
|
531
|
-
}, [configuration, element, height,
|
|
613
|
+
}, [configuration, element, height, intentKey, isAndroid]);
|
|
532
614
|
|
|
533
615
|
// Other APIs
|
|
534
616
|
const confirm = useCallback((): Promise<EmbeddedPaymentElementResult> => {
|
|
@@ -560,19 +642,25 @@ export function useEmbeddedPaymentElement(
|
|
|
560
642
|
return getElementOrThrow(elementRef).confirm();
|
|
561
643
|
}, [isAndroid]);
|
|
562
644
|
const update = useCallback(
|
|
563
|
-
(
|
|
645
|
+
(
|
|
646
|
+
updateSource: PaymentSheetTypes.IntentConfiguration | Checkout
|
|
647
|
+
): Promise<unknown> => {
|
|
564
648
|
if (isAndroid) {
|
|
565
649
|
const currentRef = viewRef.current;
|
|
566
650
|
if (currentRef) {
|
|
567
|
-
return new Promise
|
|
651
|
+
return new Promise((resolve) => {
|
|
568
652
|
const sub = addListener(
|
|
569
653
|
'embeddedPaymentElementUpdateComplete',
|
|
570
|
-
(result
|
|
654
|
+
(result) => {
|
|
571
655
|
sub.remove();
|
|
572
656
|
resolve(result);
|
|
573
657
|
}
|
|
574
658
|
);
|
|
575
|
-
|
|
659
|
+
if (isCheckoutSession(updateSource)) {
|
|
660
|
+
Commands.updateWithCheckout(currentRef, updateSource.sessionKey);
|
|
661
|
+
} else {
|
|
662
|
+
Commands.update(currentRef, JSON.stringify(updateSource));
|
|
663
|
+
}
|
|
576
664
|
});
|
|
577
665
|
}
|
|
578
666
|
return Promise.reject(
|
|
@@ -581,7 +669,10 @@ export function useEmbeddedPaymentElement(
|
|
|
581
669
|
}
|
|
582
670
|
|
|
583
671
|
// iOS: use native module directly
|
|
584
|
-
|
|
672
|
+
const embeddedElement = getElementOrThrow(elementRef);
|
|
673
|
+
return isCheckoutSession(updateSource)
|
|
674
|
+
? embeddedElement.updateCheckout(updateSource)
|
|
675
|
+
: embeddedElement.updateIntent(updateSource);
|
|
585
676
|
},
|
|
586
677
|
[isAndroid]
|
|
587
678
|
);
|
package/src/types/Onramp.ts
CHANGED
|
@@ -199,8 +199,117 @@ export type KycInfo = {
|
|
|
199
199
|
dateOfBirth?: DateOfBirth;
|
|
200
200
|
/** Customer’s address, if collected. */
|
|
201
201
|
address?: Address;
|
|
202
|
+
/** Two-letter ISO 3166-1 alpha-2 code for the country where the customer was born. */
|
|
203
|
+
birthCountry?: string;
|
|
204
|
+
/** City where the customer was born. */
|
|
205
|
+
birthCity?: string;
|
|
206
|
+
/** Two-letter ISO 3166-1 alpha-2 codes for the customer's nationalities. */
|
|
207
|
+
nationalities?: string[];
|
|
202
208
|
};
|
|
203
209
|
|
|
210
|
+
/**
|
|
211
|
+
* The type of compliance identifier required or submitted for regulatory compliance.
|
|
212
|
+
*/
|
|
213
|
+
export type ComplianceIdentifierType = string;
|
|
214
|
+
|
|
215
|
+
/**
|
|
216
|
+
* The regulation requiring a compliance identifier.
|
|
217
|
+
*/
|
|
218
|
+
export type ComplianceRegulation = 'eu_carf' | 'eu_mica';
|
|
219
|
+
|
|
220
|
+
/**
|
|
221
|
+
* A compliance identifier collected for MiCA or CRS/CARF compliance.
|
|
222
|
+
*/
|
|
223
|
+
export type ComplianceIdentifier = {
|
|
224
|
+
/** The type of identifier provided. */
|
|
225
|
+
type: ComplianceIdentifierType;
|
|
226
|
+
/** The identifier value. */
|
|
227
|
+
value: string;
|
|
228
|
+
};
|
|
229
|
+
|
|
230
|
+
/**
|
|
231
|
+
* A compliance identifier the customer still needs to provide.
|
|
232
|
+
*/
|
|
233
|
+
export type ComplianceIdentifierRequirement = {
|
|
234
|
+
/** The type of identifier required. */
|
|
235
|
+
type: ComplianceIdentifierType;
|
|
236
|
+
/** The regulation requiring this identifier. */
|
|
237
|
+
regulation: ComplianceRegulation;
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/**
|
|
241
|
+
* A group describing alternative identifier types that may satisfy a requirement.
|
|
242
|
+
*/
|
|
243
|
+
export type ComplianceIdentifierAlternativeGroup = {
|
|
244
|
+
/** The original identifier types required. */
|
|
245
|
+
originalMissingIdentifiers: ComplianceIdentifierType[];
|
|
246
|
+
/** Alternative identifier types that may satisfy the original requirement. */
|
|
247
|
+
alternativeMissingIdentifiers: ComplianceIdentifierType[];
|
|
248
|
+
};
|
|
249
|
+
|
|
250
|
+
/**
|
|
251
|
+
* The compliance identifiers a customer still needs to provide.
|
|
252
|
+
*/
|
|
253
|
+
export type ComplianceIdentifierRequirements = {
|
|
254
|
+
/** Required identifier types and the regulations requiring them. */
|
|
255
|
+
identifiers: ComplianceIdentifierRequirement[];
|
|
256
|
+
/** Alternative identifier groups that may satisfy one or more requirements. */
|
|
257
|
+
alternatives: ComplianceIdentifierAlternativeGroup[];
|
|
258
|
+
};
|
|
259
|
+
|
|
260
|
+
/**
|
|
261
|
+
* Result of retrieving missing compliance identifiers.
|
|
262
|
+
*/
|
|
263
|
+
export type RetrieveMissingIdentifiersResult =
|
|
264
|
+
| (ComplianceIdentifierRequirements & {
|
|
265
|
+
error?: undefined;
|
|
266
|
+
})
|
|
267
|
+
| {
|
|
268
|
+
identifiers?: undefined;
|
|
269
|
+
alternatives?: undefined;
|
|
270
|
+
/** Present if retrieval failed with an error. */
|
|
271
|
+
error: StripeError<OnrampError>;
|
|
272
|
+
};
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Result of submitting compliance identifiers for MiCA and CRS/CARF compliance.
|
|
276
|
+
*/
|
|
277
|
+
export type SubmitIdentifiersResult =
|
|
278
|
+
| {
|
|
279
|
+
/** Whether all required identifiers were accepted. */
|
|
280
|
+
valid: boolean;
|
|
281
|
+
/** Any identifiers that still need to be collected. */
|
|
282
|
+
identifiers: ComplianceIdentifierRequirement[];
|
|
283
|
+
/** Alternative identifier groups that may satisfy one or more requirements. */
|
|
284
|
+
alternatives: ComplianceIdentifierAlternativeGroup[];
|
|
285
|
+
/** Submitted identifier types whose values were invalid. */
|
|
286
|
+
invalidIdentifiers: ComplianceIdentifierType[];
|
|
287
|
+
error?: undefined;
|
|
288
|
+
}
|
|
289
|
+
| {
|
|
290
|
+
valid?: undefined;
|
|
291
|
+
identifiers?: undefined;
|
|
292
|
+
alternatives?: undefined;
|
|
293
|
+
invalidIdentifiers?: undefined;
|
|
294
|
+
/** Present if submission failed with an error. */
|
|
295
|
+
error: StripeError<OnrampError>;
|
|
296
|
+
};
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Result of presenting the CRS/CARF declaration.
|
|
300
|
+
*/
|
|
301
|
+
export type CRSCARFDeclarationResult =
|
|
302
|
+
| {
|
|
303
|
+
/** The customer accepted the declaration. */
|
|
304
|
+
status: 'Confirmed';
|
|
305
|
+
error?: undefined;
|
|
306
|
+
}
|
|
307
|
+
| {
|
|
308
|
+
status?: undefined;
|
|
309
|
+
/** Present if the declaration failed or was cancelled. */
|
|
310
|
+
error: StripeError<OnrampError>;
|
|
311
|
+
};
|
|
312
|
+
|
|
204
313
|
/**
|
|
205
314
|
* Result of KYC verification.
|
|
206
315
|
*/
|
|
@@ -2,7 +2,7 @@ require 'json'
|
|
|
2
2
|
|
|
3
3
|
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
4
|
# Keep stripe_version in sync with https://github.com/stripe/stripe-identity-react-native/blob/main/stripe-identity-react-native.podspec
|
|
5
|
-
stripe_version = '~> 25.
|
|
5
|
+
stripe_version = '~> 25.15.0'
|
|
6
6
|
|
|
7
7
|
fabric_enabled = ENV['RCT_NEW_ARCH_ENABLED'] == '1'
|
|
8
8
|
|