@stripe/stripe-react-native 0.65.0 → 0.65.1
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 -66
- package/android/gradle.properties +3 -3
- 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 +5 -1
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +42 -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/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 +110 -29
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +190 -24
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -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 +6 -2
- 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 +101 -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/NativeStripeSdkModuleSpec.java +8 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/MappersTest.kt +60 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/OnrampMappersTest.kt +38 -0
- package/android/src/test/java/com/reactnativestripesdk/mappers/PaymentOptionDisplayDataMapperTest.kt +9 -4
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +89 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +49 -0
- package/ios/ConnectAccountOnboarding/ConnectAccountOnboardingViewController.swift +6 -8
- package/ios/CurrencySelectorElementManager.m +9 -0
- package/ios/CurrencySelectorElementManager.swift +12 -0
- package/ios/CurrencySelectorElementView.swift +24 -0
- package/ios/Mappers+Checkout.swift +193 -0
- package/ios/NewArch/EmbeddedPaymentElementViewComponentView.mm +16 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.h +10 -0
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +75 -0
- package/ios/StripeSdk.mm +123 -0
- package/ios/StripeSdkImpl+Checkout.swift +308 -0
- package/ios/StripeSdkImpl+Embedded.swift +108 -27
- package/ios/StripeSdkImpl+PaymentSheet.swift +18 -2
- package/ios/StripeSdkImpl.swift +3 -1
- 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/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/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/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/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/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/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/NativeStripeSdkModule.d.ts +3 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +2 -2
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts +36 -1
- package/lib/typescript/src/types/EmbeddedPaymentElement.d.ts.map +1 -1
- package/package.json +14 -3
- package/src/components/CurrencySelectorElement.tsx +95 -0
- package/src/events.ts +11 -0
- package/src/functions.ts +30 -1
- package/src/hooks/useCheckout.tsx +114 -75
- package/src/specs/NativeCurrencySelectorElement.ts +35 -0
- package/src/specs/NativeEmbeddedPaymentElement.ts +12 -2
- package/src/specs/NativeStripeSdkModule.ts +8 -1
- package/src/types/Checkout.ts +2 -2
- package/src/types/EmbeddedPaymentElement.tsx +117 -26
- 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
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { BillingDetails, AddressDetails, UserInterfaceStyle, CardBrand } from './Common';
|
|
2
|
+
import type { Checkout } from './Checkout';
|
|
2
3
|
import * as PaymentSheetTypes from './PaymentSheet';
|
|
3
4
|
import { ReactElement } from 'react';
|
|
4
5
|
/**
|
|
@@ -201,7 +202,16 @@ export interface UseEmbeddedPaymentElementResult {
|
|
|
201
202
|
* @note Upon completion, `paymentOption` may become null if it's no longer available.
|
|
202
203
|
* @note If you call `update` while a previous call to `update` is still in progress, the previous call is canceled.
|
|
203
204
|
*/
|
|
204
|
-
update:
|
|
205
|
+
update: {
|
|
206
|
+
(intentConfig: PaymentSheetTypes.IntentConfiguration): void;
|
|
207
|
+
/**
|
|
208
|
+
* Call this method when the Checkout Session values you used to initialize
|
|
209
|
+
* `EmbeddedPaymentElement` change.
|
|
210
|
+
* @checkoutSessionsPreview
|
|
211
|
+
* @internal
|
|
212
|
+
*/
|
|
213
|
+
(checkout: Checkout): void;
|
|
214
|
+
};
|
|
205
215
|
clearPaymentOption: () => void;
|
|
206
216
|
loadingError: Error | null;
|
|
207
217
|
isLoaded: boolean;
|
|
@@ -215,4 +225,29 @@ export interface UseEmbeddedPaymentElementResult {
|
|
|
215
225
|
* @description If loading fails, this function sets the loadingError state variable instead of throwing an error.
|
|
216
226
|
*/
|
|
217
227
|
export declare function useEmbeddedPaymentElement(intentConfig: PaymentSheetTypes.IntentConfiguration, configuration: EmbeddedPaymentElementConfiguration): UseEmbeddedPaymentElementResult;
|
|
228
|
+
/**
|
|
229
|
+
* Initializes an `EmbeddedPaymentElement` from a Stripe Checkout Session.
|
|
230
|
+
*
|
|
231
|
+
* Pass a loaded handle from `useCheckout`. Render the consumer in a child
|
|
232
|
+
* component so the hook only runs once `state.status === 'loaded'`.
|
|
233
|
+
*
|
|
234
|
+
* @example
|
|
235
|
+
* function Cart() {
|
|
236
|
+
* const { checkout, state } = useCheckout(clientSecret);
|
|
237
|
+
* if (state?.status !== 'loaded') return null;
|
|
238
|
+
* return <EmbeddedCheckout checkout={checkout} />;
|
|
239
|
+
* }
|
|
240
|
+
*
|
|
241
|
+
* function EmbeddedCheckout({ checkout }: { checkout: Checkout }) {
|
|
242
|
+
* const { embeddedPaymentElementView } =
|
|
243
|
+
* useEmbeddedPaymentElement(checkout, configuration);
|
|
244
|
+
* return embeddedPaymentElementView;
|
|
245
|
+
* }
|
|
246
|
+
*
|
|
247
|
+
* @param checkout - A loaded `Checkout` handle from `useCheckout`.
|
|
248
|
+
* @param configuration - Configuration for the embedded element.
|
|
249
|
+
* @checkoutSessionsPreview
|
|
250
|
+
* @internal
|
|
251
|
+
*/
|
|
252
|
+
export declare function useEmbeddedPaymentElement(checkout: Checkout, configuration: EmbeddedPaymentElementConfiguration): UseEmbeddedPaymentElementResult;
|
|
218
253
|
//# sourceMappingURL=EmbeddedPaymentElement.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EmbeddedPaymentElement.d.ts","sourceRoot":"","sources":["../../../../src/types/EmbeddedPaymentElement.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EACV,cAAc,EACd,cAAc,EACd,kBAAkB,EAClB,SAAS,EACV,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"EmbeddedPaymentElement.d.ts","sourceRoot":"","sources":["../../../../src/types/EmbeddedPaymentElement.tsx"],"names":[],"mappings":"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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stripe/stripe-react-native",
|
|
3
|
-
"version": "0.65.
|
|
3
|
+
"version": "0.65.1",
|
|
4
4
|
"author": "Stripe",
|
|
5
5
|
"description": "Stripe SDK for React Native",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
"update-pods": "cd example/ios && pod update Stripe StripeApplePay StripeFinancialConnections StripePayments StripePaymentSheet StripePaymentsUI StripeCore StripeUICore StripeCryptoOnramp",
|
|
20
20
|
"bootstrap": "yarn example && yarn && yarn pods",
|
|
21
21
|
"bootstrap-no-pods": "yarn example && yarn",
|
|
22
|
-
"docs": "yarn typedoc ./src/index.tsx --out ./docs/api-reference --tsconfig ./tsconfig.json --readme none --sort source-order",
|
|
22
|
+
"docs": "yarn typedoc ./src/index.tsx --out ./docs/api-reference --tsconfig ./tsconfig.json --readme none --sort source-order --excludeInternal",
|
|
23
23
|
"run-example-ios": "cd example && yarn ios --simulator \"iPhone 16 Pro Max\"",
|
|
24
24
|
"run-example-ios:release": "cd example && yarn build:ios && yarn ios --mode Release --simulator \"iPhone 16 Pro Max\" --no-packager",
|
|
25
25
|
"run-example-android": "cd example && yarn android",
|
|
@@ -35,6 +35,8 @@
|
|
|
35
35
|
"lint:android": "cd android && ./gradlew detekt",
|
|
36
36
|
"format:ios:check": "swiftlint ios --config .swiftlint.yml --strict",
|
|
37
37
|
"format:ios:write": "./scripts/format-changed-ios",
|
|
38
|
+
"test:package-types": "attw --pack .",
|
|
39
|
+
"prepublishOnly": "echo \"\\nPlease use ./scripts/publish instead\\n\" && exit 1",
|
|
38
40
|
"api-extractor:update": "bob build && api-extractor run --local --verbose",
|
|
39
41
|
"api-extractor:check": "bob build && api-extractor run --verbose"
|
|
40
42
|
},
|
|
@@ -70,6 +72,7 @@
|
|
|
70
72
|
},
|
|
71
73
|
"homepage": "https://github.com/stripe/stripe-react-native/#readme",
|
|
72
74
|
"devDependencies": {
|
|
75
|
+
"@arethetypeswrong/cli": "^0.17.0",
|
|
73
76
|
"@expo/config-plugins": "^9.0.16",
|
|
74
77
|
"@microsoft/api-extractor": "^7.58.7",
|
|
75
78
|
"@react-native/babel-preset": "^0.81.0",
|
|
@@ -83,6 +86,7 @@
|
|
|
83
86
|
"eslint-plugin-prettier": "^5.1.3",
|
|
84
87
|
"husky": "^9.1.7",
|
|
85
88
|
"jest": "^29.2.1",
|
|
89
|
+
"lint-staged": "^16.4.0",
|
|
86
90
|
"prettier": "^3.5.2",
|
|
87
91
|
"react": "19.1.0",
|
|
88
92
|
"react-native": "^0.81.0",
|
|
@@ -175,6 +179,12 @@
|
|
|
175
179
|
"typescript"
|
|
176
180
|
]
|
|
177
181
|
},
|
|
182
|
+
"lint-staged": {
|
|
183
|
+
"*.{js,ts,tsx}": "eslint --ignore-path .gitignore",
|
|
184
|
+
"*.{ts,tsx}": "bash -c 'yarn typescript'",
|
|
185
|
+
"*.kt": "bash -c 'yarn format:android:write'",
|
|
186
|
+
"*.swift": "bash -c 'yarn format:ios:write'"
|
|
187
|
+
},
|
|
178
188
|
"resolutions": {
|
|
179
189
|
"simple-plist": "1.3.1"
|
|
180
190
|
},
|
|
@@ -192,7 +202,8 @@
|
|
|
192
202
|
"CardForm": "CardFormComponentView",
|
|
193
203
|
"EmbeddedPaymentElementView": "EmbeddedPaymentElementViewComponentView",
|
|
194
204
|
"NavigationBar": "NavigationBarComponentView",
|
|
195
|
-
"StripeContainer": "StripeContainerComponentView"
|
|
205
|
+
"StripeContainer": "StripeContainerComponentView",
|
|
206
|
+
"StripeCurrencySelectorElement": "StripeCurrencySelectorElementComponentView"
|
|
196
207
|
}
|
|
197
208
|
},
|
|
198
209
|
"name": "rnstripe",
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AccessibilityProps,
|
|
4
|
+
LayoutAnimation,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import type { Checkout } from '../types/Checkout';
|
|
8
|
+
import NativeCurrencySelectorElement, {
|
|
9
|
+
type HeightChangeEvent,
|
|
10
|
+
} from '../specs/NativeCurrencySelectorElement';
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Props for {@link CurrencySelectorElement}.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
16
|
+
export interface CurrencySelectorElementProps extends AccessibilityProps {
|
|
17
|
+
/**
|
|
18
|
+
* The `Checkout` handle returned by `useCheckout`.
|
|
19
|
+
*
|
|
20
|
+
* The element reads currency options from this session and calls
|
|
21
|
+
* `selectCurrency` internally — you never call it yourself.
|
|
22
|
+
*/
|
|
23
|
+
checkout: Checkout;
|
|
24
|
+
|
|
25
|
+
/**
|
|
26
|
+
* When `true`, the toggle is visible but does not respond to taps.
|
|
27
|
+
*
|
|
28
|
+
* Tip: pass `disabled={state?.status === 'loading'}` to freeze the
|
|
29
|
+
* selector while an unrelated mutation (e.g. applying a promo code)
|
|
30
|
+
* is in flight. The element also disables itself automatically
|
|
31
|
+
* during its own currency-selection network call.
|
|
32
|
+
*
|
|
33
|
+
* @default false
|
|
34
|
+
*/
|
|
35
|
+
disabled?: boolean;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* A self-contained currency selector for Adaptive Pricing.
|
|
40
|
+
*
|
|
41
|
+
* Place this element on your cart or checkout page **near the total price**,
|
|
42
|
+
* above the Payment Element. It automatically:
|
|
43
|
+
*
|
|
44
|
+
* - Reads currency options from the `Checkout` session
|
|
45
|
+
* - Renders a two-option toggle with exchange rate disclosure
|
|
46
|
+
* - Calls `selectCurrency` when the customer taps an option
|
|
47
|
+
* - Collapses to zero height when Adaptive Pricing is unavailable
|
|
48
|
+
* - Displays inline errors on failed selections
|
|
49
|
+
*
|
|
50
|
+
* Session state updates automatically through `useCheckout` — no extra
|
|
51
|
+
* wiring needed to keep your cart totals in sync.
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* ```tsx
|
|
55
|
+
* const { state, checkout } = useCheckout(clientSecret, {
|
|
56
|
+
* adaptivePricing: { allowed: true },
|
|
57
|
+
* });
|
|
58
|
+
*
|
|
59
|
+
* return (
|
|
60
|
+
* <ScrollView>
|
|
61
|
+
* <CurrencySelectorElement checkout={checkout} />
|
|
62
|
+
* <Text>{formatTotal(state?.session.totals?.total, state?.session.currency)}</Text>
|
|
63
|
+
* </ScrollView>
|
|
64
|
+
* );
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* @param props {@link CurrencySelectorElementProps}
|
|
68
|
+
* @category ReactComponents
|
|
69
|
+
* @internal
|
|
70
|
+
*/
|
|
71
|
+
export function CurrencySelectorElement({
|
|
72
|
+
checkout,
|
|
73
|
+
disabled = false,
|
|
74
|
+
...a11yProps
|
|
75
|
+
}: CurrencySelectorElementProps) {
|
|
76
|
+
const [height, setHeight] = useState<number>(0);
|
|
77
|
+
|
|
78
|
+
const handleHeightChange = useCallback(
|
|
79
|
+
(e: NativeSyntheticEvent<HeightChangeEvent>) => {
|
|
80
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
81
|
+
setHeight(e.nativeEvent.height);
|
|
82
|
+
},
|
|
83
|
+
[]
|
|
84
|
+
);
|
|
85
|
+
|
|
86
|
+
return (
|
|
87
|
+
<NativeCurrencySelectorElement
|
|
88
|
+
sessionKey={checkout.sessionKey}
|
|
89
|
+
disabled={disabled}
|
|
90
|
+
style={{ width: '100%', height }}
|
|
91
|
+
onHeightChange={handleHeightChange}
|
|
92
|
+
{...a11yProps}
|
|
93
|
+
/>
|
|
94
|
+
);
|
|
95
|
+
}
|
package/src/events.ts
CHANGED
|
@@ -66,6 +66,17 @@ type Events = {
|
|
|
66
66
|
onCustomPaymentMethodConfirmHandlerCallback: EventEmitter<UnsafeObject<any>>;
|
|
67
67
|
paymentMethodMessagingElementDidUpdateHeight: EventEmitter<UnsafeObject<any>>;
|
|
68
68
|
paymentMethodMessagingElementConfigureResult: EventEmitter<UnsafeObject<any>>;
|
|
69
|
+
/**
|
|
70
|
+
* Fired by native every time a `Checkout` instance's state transitions —
|
|
71
|
+
* regardless of whether the mutation was JS-driven (e.g. `applyPromotionCode`
|
|
72
|
+
* via `useCheckout`) or native-driven (e.g. `CurrencySelectorElement`).
|
|
73
|
+
* `useCheckout` mirrors this into its `state` so the entire React tree
|
|
74
|
+
* stays in sync with the underlying native session.
|
|
75
|
+
*/
|
|
76
|
+
checkoutSessionDidChangeState: EventEmitter<{
|
|
77
|
+
sessionKey: string;
|
|
78
|
+
state: UnsafeObject<any>;
|
|
79
|
+
}>;
|
|
69
80
|
};
|
|
70
81
|
|
|
71
82
|
export function addListener<EventT extends keyof Events>(
|
package/src/functions.ts
CHANGED
|
@@ -350,6 +350,33 @@ let financialConnectionsEventListener: EventSubscription | null = null;
|
|
|
350
350
|
let paymentSheetCustomPaymentMethodConfirmCallback: EventSubscription | null =
|
|
351
351
|
null;
|
|
352
352
|
|
|
353
|
+
type NativeCheckoutSetupParams = Omit<
|
|
354
|
+
PaymentSheet.CheckoutSetupParams,
|
|
355
|
+
'checkout'
|
|
356
|
+
> & {
|
|
357
|
+
checkout: {
|
|
358
|
+
sessionKey: string;
|
|
359
|
+
};
|
|
360
|
+
};
|
|
361
|
+
|
|
362
|
+
const toNativePaymentSheetSetupParams = (
|
|
363
|
+
params: PaymentSheet.SetupParams
|
|
364
|
+
): PaymentSheet.SetupParams => {
|
|
365
|
+
if (!('checkout' in params)) {
|
|
366
|
+
return params;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
const nativeCheckoutParams: NativeCheckoutSetupParams = {
|
|
370
|
+
...params,
|
|
371
|
+
// The native side already owns the Checkout instance, so only pass its opaque session key.
|
|
372
|
+
checkout: {
|
|
373
|
+
sessionKey: params.checkout.sessionKey,
|
|
374
|
+
},
|
|
375
|
+
};
|
|
376
|
+
|
|
377
|
+
return nativeCheckoutParams as PaymentSheet.SetupParams;
|
|
378
|
+
};
|
|
379
|
+
|
|
353
380
|
export const initPaymentSheet = async (
|
|
354
381
|
params: PaymentSheet.SetupParams
|
|
355
382
|
): Promise<InitPaymentSheetResult> => {
|
|
@@ -431,7 +458,9 @@ export const initPaymentSheet = async (
|
|
|
431
458
|
`[@stripe/stripe-react-native] You have not provided the 'returnURL' field to 'initPaymentSheet', so payment methods that require redirects will not be shown in your iOS Payment Sheet. Visit https://stripe.com/docs/payments/accept-a-payment?platform=react-native&ui=payment-sheet#react-native-set-up-return-url to learn more.`
|
|
432
459
|
);
|
|
433
460
|
}
|
|
434
|
-
result = await NativeStripeSdk.initPaymentSheet(
|
|
461
|
+
result = await NativeStripeSdk.initPaymentSheet(
|
|
462
|
+
toNativePaymentSheetSetupParams(params)
|
|
463
|
+
);
|
|
435
464
|
|
|
436
465
|
if (result.error) {
|
|
437
466
|
return {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import { useState, useEffect, useCallback, useRef } from 'react';
|
|
1
|
+
import { useState, useEffect, useCallback, useMemo, useRef } from 'react';
|
|
2
2
|
import NativeStripeSdk from '../specs/NativeStripeSdkModule';
|
|
3
3
|
import type { Checkout } from '../types/Checkout';
|
|
4
|
+
import { addListener } from '../events';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Initializes a Stripe Checkout Session and returns a reactive handle.
|
|
@@ -55,9 +56,20 @@ export function useCheckout(
|
|
|
55
56
|
}
|
|
56
57
|
})();
|
|
57
58
|
|
|
59
|
+
// Listen for state changes from native (e.g. currency selector taps)
|
|
60
|
+
// so we stay in sync even when mutations don't originate from JS.
|
|
61
|
+
const sub = addListener(
|
|
62
|
+
'checkoutSessionDidChangeState',
|
|
63
|
+
({ sessionKey, state: nextState }) => {
|
|
64
|
+
if (sessionKey !== sessionKeyRef.current) return;
|
|
65
|
+
setState(nextState as Checkout.State);
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
58
69
|
// Ignore in-flight init if unmounted or clientSecret changed.
|
|
59
70
|
return () => {
|
|
60
71
|
cancelled = true;
|
|
72
|
+
sub.remove();
|
|
61
73
|
};
|
|
62
74
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
63
75
|
}, [clientSecret]);
|
|
@@ -89,80 +101,107 @@ export function useCheckout(
|
|
|
89
101
|
[]
|
|
90
102
|
);
|
|
91
103
|
|
|
92
|
-
// Mutation methods
|
|
93
|
-
const
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
104
|
+
// Mutation methods. Each is memoized so `checkout` has a stable identity.
|
|
105
|
+
const updateShippingAddress = useCallback<Checkout['updateShippingAddress']>(
|
|
106
|
+
(address, name, phone) =>
|
|
107
|
+
withLoading((key) =>
|
|
108
|
+
NativeStripeSdk.checkoutUpdateShippingAddress(
|
|
109
|
+
key,
|
|
110
|
+
address,
|
|
111
|
+
name ?? null,
|
|
112
|
+
phone ?? null
|
|
113
|
+
)
|
|
114
|
+
),
|
|
115
|
+
[withLoading]
|
|
116
|
+
);
|
|
117
|
+
const updateBillingAddress = useCallback<Checkout['updateBillingAddress']>(
|
|
118
|
+
(address, name, phone) =>
|
|
119
|
+
withLoading((key) =>
|
|
120
|
+
NativeStripeSdk.checkoutUpdateBillingAddress(
|
|
121
|
+
key,
|
|
122
|
+
address,
|
|
123
|
+
name ?? null,
|
|
124
|
+
phone ?? null
|
|
125
|
+
)
|
|
126
|
+
),
|
|
127
|
+
[withLoading]
|
|
128
|
+
);
|
|
129
|
+
const applyPromotionCode = useCallback<Checkout['applyPromotionCode']>(
|
|
130
|
+
(code) =>
|
|
131
|
+
withLoading((key) =>
|
|
132
|
+
NativeStripeSdk.checkoutApplyPromotionCode(key, code)
|
|
133
|
+
),
|
|
134
|
+
[withLoading]
|
|
135
|
+
);
|
|
136
|
+
const removePromotionCode = useCallback<Checkout['removePromotionCode']>(
|
|
137
|
+
() =>
|
|
138
|
+
withLoading((key) => NativeStripeSdk.checkoutRemovePromotionCode(key)),
|
|
139
|
+
[withLoading]
|
|
140
|
+
);
|
|
141
|
+
const updateLineItemQuantity = useCallback<
|
|
142
|
+
Checkout['updateLineItemQuantity']
|
|
143
|
+
>(
|
|
144
|
+
(lineItemId, quantity) =>
|
|
145
|
+
withLoading((key) =>
|
|
146
|
+
NativeStripeSdk.checkoutUpdateLineItemQuantity(
|
|
147
|
+
key,
|
|
148
|
+
lineItemId,
|
|
149
|
+
quantity
|
|
150
|
+
)
|
|
151
|
+
),
|
|
152
|
+
[withLoading]
|
|
153
|
+
);
|
|
154
|
+
const selectShippingOption = useCallback<Checkout['selectShippingOption']>(
|
|
155
|
+
(id) =>
|
|
156
|
+
withLoading((key) =>
|
|
157
|
+
NativeStripeSdk.checkoutSelectShippingOption(key, id)
|
|
158
|
+
),
|
|
159
|
+
[withLoading]
|
|
160
|
+
);
|
|
161
|
+
const updateTaxId = useCallback<Checkout['updateTaxId']>(
|
|
162
|
+
(type, value) =>
|
|
163
|
+
withLoading((key) =>
|
|
164
|
+
NativeStripeSdk.checkoutUpdateTaxId(key, type, value)
|
|
165
|
+
),
|
|
166
|
+
[withLoading]
|
|
167
|
+
);
|
|
168
|
+
const refresh = useCallback<Checkout['refresh']>(
|
|
169
|
+
() => withLoading((key) => NativeStripeSdk.checkoutRefresh(key)),
|
|
170
|
+
[withLoading]
|
|
171
|
+
);
|
|
172
|
+
|
|
173
|
+
const checkout = useMemo<Checkout>(
|
|
174
|
+
() => ({
|
|
175
|
+
get sessionKey(): string {
|
|
176
|
+
if (!sessionKeyRef.current) {
|
|
177
|
+
throw new Error(
|
|
178
|
+
'Checkout session not initialized. Wait for `state.status === "loaded"` ' +
|
|
179
|
+
'before passing `checkout` to `useEmbeddedPaymentElement` or calling a ' +
|
|
180
|
+
'mutation method (e.g. `applyPromotionCode`).'
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
return sessionKeyRef.current;
|
|
184
|
+
},
|
|
185
|
+
updateShippingAddress,
|
|
186
|
+
updateBillingAddress,
|
|
187
|
+
applyPromotionCode,
|
|
188
|
+
removePromotionCode,
|
|
189
|
+
updateLineItemQuantity,
|
|
190
|
+
selectShippingOption,
|
|
191
|
+
updateTaxId,
|
|
192
|
+
refresh,
|
|
193
|
+
}),
|
|
194
|
+
[
|
|
195
|
+
updateShippingAddress,
|
|
196
|
+
updateBillingAddress,
|
|
197
|
+
applyPromotionCode,
|
|
198
|
+
removePromotionCode,
|
|
199
|
+
updateLineItemQuantity,
|
|
200
|
+
selectShippingOption,
|
|
201
|
+
updateTaxId,
|
|
202
|
+
refresh,
|
|
203
|
+
]
|
|
204
|
+
);
|
|
166
205
|
|
|
167
206
|
return { state, checkout, error };
|
|
168
207
|
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { HostComponent, ViewProps } from 'react-native';
|
|
2
|
+
import codegenNativeComponent from 'react-native/Libraries/Utilities/codegenNativeComponent';
|
|
3
|
+
import type {
|
|
4
|
+
DirectEventHandler,
|
|
5
|
+
Double,
|
|
6
|
+
WithDefault,
|
|
7
|
+
} from 'react-native/Libraries/Types/CodegenTypes';
|
|
8
|
+
|
|
9
|
+
export interface HeightChangeEvent {
|
|
10
|
+
height: Double;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface NativeProps extends ViewProps {
|
|
14
|
+
/**
|
|
15
|
+
* Opaque key returned by `useCheckout`. The native side uses this to look
|
|
16
|
+
* up the matching `Checkout` instance and observe its state — there's no
|
|
17
|
+
* separate session-update event from this view, since `useCheckout`
|
|
18
|
+
* already subscribes to a single `checkoutSessionDidChangeState` channel
|
|
19
|
+
* that mirrors every native-driven mutation back into JS.
|
|
20
|
+
*/
|
|
21
|
+
sessionKey: string;
|
|
22
|
+
|
|
23
|
+
/** When true, the toggle is visible but ignores user interaction. */
|
|
24
|
+
disabled?: WithDefault<boolean, false>;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Fired whenever the element's intrinsic height changes so the RN
|
|
28
|
+
* layout system can update the containing view.
|
|
29
|
+
*/
|
|
30
|
+
onHeightChange?: DirectEventHandler<HeightChangeEvent>;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default codegenNativeComponent<NativeProps>(
|
|
34
|
+
'StripeCurrencySelectorElement'
|
|
35
|
+
) as HostComponent<NativeProps>;
|
|
@@ -7,7 +7,8 @@ import type { UnsafeMixed } from './utils';
|
|
|
7
7
|
|
|
8
8
|
export interface NativeProps extends ViewProps {
|
|
9
9
|
configuration: UnsafeMixed<EmbeddedPaymentElementConfiguration>;
|
|
10
|
-
intentConfiguration
|
|
10
|
+
intentConfiguration?: UnsafeMixed<IntentConfiguration>;
|
|
11
|
+
checkout?: UnsafeMixed<{ sessionKey: string }>;
|
|
11
12
|
}
|
|
12
13
|
|
|
13
14
|
export interface NativeCommands {
|
|
@@ -19,10 +20,19 @@ export interface NativeCommands {
|
|
|
19
20
|
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
20
21
|
intentConfigurationJson: string
|
|
21
22
|
) => void;
|
|
23
|
+
updateWithCheckout: (
|
|
24
|
+
viewRef: React.ElementRef<HostComponent<NativeProps>>,
|
|
25
|
+
sessionKey: string
|
|
26
|
+
) => void;
|
|
22
27
|
}
|
|
23
28
|
|
|
24
29
|
export const Commands: NativeCommands = codegenNativeCommands<NativeCommands>({
|
|
25
|
-
supportedCommands: [
|
|
30
|
+
supportedCommands: [
|
|
31
|
+
'confirm',
|
|
32
|
+
'clearPaymentOption',
|
|
33
|
+
'update',
|
|
34
|
+
'updateWithCheckout',
|
|
35
|
+
],
|
|
26
36
|
});
|
|
27
37
|
|
|
28
38
|
type ComponentType = HostComponent<NativeProps>;
|
|
@@ -199,12 +199,19 @@ export interface Spec extends TurboModule {
|
|
|
199
199
|
intentConfig: UnsafeObject<IntentConfiguration>,
|
|
200
200
|
configuration: UnsafeObject<EmbeddedPaymentElementConfiguration>
|
|
201
201
|
): Promise<void>;
|
|
202
|
+
createEmbeddedPaymentElementWithCheckout(
|
|
203
|
+
sessionKey: string,
|
|
204
|
+
configuration: UnsafeObject<EmbeddedPaymentElementConfiguration>
|
|
205
|
+
): Promise<void>;
|
|
202
206
|
confirmEmbeddedPaymentElement(
|
|
203
207
|
viewTag: Int32
|
|
204
208
|
): Promise<EmbeddedPaymentElementResult>;
|
|
205
209
|
updateEmbeddedPaymentElement(
|
|
206
210
|
intentConfig: UnsafeObject<IntentConfiguration>
|
|
207
|
-
): Promise<
|
|
211
|
+
): Promise<UnsafeObject<any> | null>;
|
|
212
|
+
updateEmbeddedPaymentElementWithCheckout(
|
|
213
|
+
sessionKey: string
|
|
214
|
+
): Promise<UnsafeObject<any> | null>;
|
|
208
215
|
clearEmbeddedPaymentOption(viewTag: Int32): Promise<void>;
|
|
209
216
|
createRadarSession(): Promise<CreateRadarSessionResult>;
|
|
210
217
|
|
package/src/types/Checkout.ts
CHANGED
|
@@ -14,7 +14,7 @@ export namespace Checkout {
|
|
|
14
14
|
* When allowed, Stripe may present prices in the customer's local
|
|
15
15
|
* currency alongside the merchant's settlement currency.
|
|
16
16
|
*
|
|
17
|
-
* Default: `{ allowed:
|
|
17
|
+
* Default: `{ allowed: false }`.
|
|
18
18
|
*/
|
|
19
19
|
adaptivePricing?: AdaptivePricing;
|
|
20
20
|
}
|
|
@@ -30,7 +30,7 @@ export namespace Checkout {
|
|
|
30
30
|
* Set to `false` to prevent Stripe from activating adaptive pricing even
|
|
31
31
|
* if the Checkout Session is configured for it on the server.
|
|
32
32
|
*
|
|
33
|
-
* Default: `
|
|
33
|
+
* Default: `false`.
|
|
34
34
|
*/
|
|
35
35
|
allowed: boolean;
|
|
36
36
|
}
|