@stripe/stripe-react-native 0.65.1 → 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/android/detekt/detekt-baseline.xml +0 -10
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CardFieldView.kt +51 -57
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementEvent.kt +26 -0
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementView.kt +129 -16
- package/android/src/main/java/com/reactnativestripesdk/CurrencySelectorElementViewManager.kt +17 -0
- package/android/src/main/java/com/reactnativestripesdk/EventEmitterCompat.kt +4 -0
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetManager.kt +8 -19
- package/android/src/main/java/com/reactnativestripesdk/StripeAbstractComposeView.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +95 -26
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +1 -0
- package/android/src/main/java/com/reactnativestripesdk/customersheet/CustomerSheetManager.kt +2 -16
- package/android/src/main/java/com/reactnativestripesdk/utils/CheckoutMappers.kt +59 -33
- package/android/src/main/java/com/reactnativestripesdk/utils/DefaultActivityLifecycleCallbacks.kt +41 -0
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeOnrampSdkModuleSpec.java +17 -3
- package/android/src/oldarch/java/com/reactnativestripesdk/NativeStripeSdkModuleSpec.java +5 -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/OnrampMappersTest.kt +107 -0
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutMappersTest.kt +39 -30
- package/android/src/test/java/com/reactnativestripesdk/utils/CheckoutTestFixtures.java +8 -0
- package/ios/CurrencySelectorElementManager.m +7 -0
- package/ios/CurrencySelectorElementView.swift +142 -7
- package/ios/EmbeddedPaymentElementView.swift +1 -1
- package/ios/Mappers+Checkout.swift +251 -107
- package/ios/Mappers.swift +90 -2
- package/ios/NewArch/StripeCurrencySelectorElementComponentView.mm +14 -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 +17 -4
- package/ios/StripeSdkEmitter.swift +1 -0
- package/ios/StripeSdkImpl+Checkout.swift +75 -23
- package/ios/StripeSdkImpl+CustomerSheet.swift +1 -1
- package/ios/StripeSdkImpl+Embedded.swift +1 -1
- package/ios/StripeSdkImpl+PaymentSheet.swift +1 -1
- package/ios/StripeSdkImpl.swift +88 -8
- package/lib/commonjs/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/commonjs/components/PaymentMethodMessagingElement.js.map +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/NativeOnrampSdkModule.js.map +1 -1
- package/lib/commonjs/specs/NativeStripeSdkModule.js.map +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.js +1 -1
- package/lib/module/components/PaymentMethodMessagingElement.js.map +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/NativeOnrampSdkModule.js.map +1 -1
- package/lib/module/specs/NativeStripeSdkModule.js.map +1 -1
- 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/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/NativeOnrampSdkModule.d.ts +3 -0
- package/lib/typescript/src/specs/NativeOnrampSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts +2 -1
- package/lib/typescript/src/specs/NativeStripeSdkModule.d.ts.map +1 -1
- package/lib/typescript/src/types/Checkout.d.ts +266 -84
- package/lib/typescript/src/types/Checkout.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 +3 -2
- package/src/components/PaymentMethodMessagingElement.tsx +54 -52
- package/src/hooks/useCheckout.tsx +20 -4
- package/src/hooks/useOnramp.tsx +44 -0
- package/src/specs/NativeOnrampSdkModule.ts +5 -0
- package/src/specs/NativeStripeSdkModule.ts +8 -1
- package/src/types/Checkout.ts +289 -84
- package/src/types/Onramp.ts +109 -0
- package/stripe-react-native.podspec +1 -1
- package/ios/CurrencySelectorElementManager.swift +0 -12
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, {
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
AccessibilityProps,
|
|
4
4
|
HostComponent,
|
|
@@ -50,60 +50,62 @@ export interface Props extends AccessibilityProps {
|
|
|
50
50
|
* @returns JSX.Element
|
|
51
51
|
* @category ReactComponents
|
|
52
52
|
*/
|
|
53
|
-
export const PaymentMethodMessagingElement =
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
53
|
+
export const PaymentMethodMessagingElement = ({
|
|
54
|
+
appearance,
|
|
55
|
+
configuration,
|
|
56
|
+
onStateChange,
|
|
57
|
+
...props
|
|
58
|
+
}: Props) => {
|
|
59
|
+
const viewRef = useRef<React.ComponentRef<HostComponent<NativeProps>>>(null);
|
|
57
60
|
|
|
58
|
-
|
|
61
|
+
const [height, setHeight] = useState<number | undefined>();
|
|
59
62
|
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
63
|
+
useEffect(() => {
|
|
64
|
+
// listen for height changes
|
|
65
|
+
const sub = addListener(
|
|
66
|
+
'paymentMethodMessagingElementDidUpdateHeight',
|
|
67
|
+
({ height: h }) => {
|
|
68
|
+
LayoutAnimation.configureNext(LayoutAnimation.Presets.easeInEaseOut);
|
|
69
|
+
setHeight(h);
|
|
70
|
+
}
|
|
71
|
+
);
|
|
72
|
+
return () => sub.remove();
|
|
73
|
+
});
|
|
71
74
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
75
|
+
useEffect(() => {
|
|
76
|
+
// listen for load complete
|
|
77
|
+
const sub = addListener(
|
|
78
|
+
'paymentMethodMessagingElementConfigureResult',
|
|
79
|
+
({ status: s }) => {
|
|
80
|
+
let state: PaymentMethodMessagingElementState;
|
|
78
81
|
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
}
|
|
93
|
-
onStateChange?.(state);
|
|
82
|
+
if (s === 'loaded') {
|
|
83
|
+
state = { status: 'loaded' };
|
|
84
|
+
} else if (s === 'loading') {
|
|
85
|
+
state = { status: 'loading' };
|
|
86
|
+
} else if (s === 'no_content') {
|
|
87
|
+
state = { status: 'no_content' };
|
|
88
|
+
} else {
|
|
89
|
+
state = {
|
|
90
|
+
status: 'failed',
|
|
91
|
+
error: new Error(
|
|
92
|
+
'Failed to configure payment method messaging element'
|
|
93
|
+
),
|
|
94
|
+
};
|
|
94
95
|
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
}, [onStateChange]);
|
|
98
|
-
|
|
99
|
-
return (
|
|
100
|
-
<NativePaymentMethodMessagingElement
|
|
101
|
-
appearance={appearance}
|
|
102
|
-
style={[{ width: '100%', height: height }]}
|
|
103
|
-
configuration={configuration}
|
|
104
|
-
{...props}
|
|
105
|
-
ref={viewRef}
|
|
106
|
-
/>
|
|
96
|
+
onStateChange?.(state);
|
|
97
|
+
}
|
|
107
98
|
);
|
|
108
|
-
|
|
109
|
-
);
|
|
99
|
+
return () => sub.remove();
|
|
100
|
+
}, [onStateChange]);
|
|
101
|
+
|
|
102
|
+
return (
|
|
103
|
+
<NativePaymentMethodMessagingElement
|
|
104
|
+
appearance={appearance}
|
|
105
|
+
style={[{ width: '100%', height: height }]}
|
|
106
|
+
configuration={configuration}
|
|
107
|
+
{...props}
|
|
108
|
+
ref={viewRef}
|
|
109
|
+
/>
|
|
110
|
+
);
|
|
111
|
+
};
|
|
@@ -165,8 +165,24 @@ export function useCheckout(
|
|
|
165
165
|
),
|
|
166
166
|
[withLoading]
|
|
167
167
|
);
|
|
168
|
-
const
|
|
169
|
-
() =>
|
|
168
|
+
const runServerUpdate = useCallback<Checkout['runServerUpdate']>(
|
|
169
|
+
(serverUpdate) =>
|
|
170
|
+
withLoading(async (key) => {
|
|
171
|
+
const startPromise = NativeStripeSdk.checkoutRunServerUpdateStart(key);
|
|
172
|
+
|
|
173
|
+
try {
|
|
174
|
+
await serverUpdate();
|
|
175
|
+
await NativeStripeSdk.checkoutRunServerUpdateComplete(key, null);
|
|
176
|
+
} catch (e: any) {
|
|
177
|
+
await NativeStripeSdk.checkoutRunServerUpdateComplete(
|
|
178
|
+
key,
|
|
179
|
+
e.message ?? 'Server update failed'
|
|
180
|
+
);
|
|
181
|
+
throw e;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
return await startPromise;
|
|
185
|
+
}),
|
|
170
186
|
[withLoading]
|
|
171
187
|
);
|
|
172
188
|
|
|
@@ -189,7 +205,7 @@ export function useCheckout(
|
|
|
189
205
|
updateLineItemQuantity,
|
|
190
206
|
selectShippingOption,
|
|
191
207
|
updateTaxId,
|
|
192
|
-
|
|
208
|
+
runServerUpdate,
|
|
193
209
|
}),
|
|
194
210
|
[
|
|
195
211
|
updateShippingAddress,
|
|
@@ -199,7 +215,7 @@ export function useCheckout(
|
|
|
199
215
|
updateLineItemQuantity,
|
|
200
216
|
selectShippingOption,
|
|
201
217
|
updateTaxId,
|
|
202
|
-
|
|
218
|
+
runServerUpdate,
|
|
203
219
|
]
|
|
204
220
|
);
|
|
205
221
|
|
package/src/hooks/useOnramp.tsx
CHANGED
|
@@ -75,6 +75,25 @@ export function useOnramp() {
|
|
|
75
75
|
[]
|
|
76
76
|
);
|
|
77
77
|
|
|
78
|
+
const _retrieveMissingIdentifiers =
|
|
79
|
+
useCallback(async (): Promise<Onramp.RetrieveMissingIdentifiersResult> => {
|
|
80
|
+
return requireOnrampModule().retrieveMissingIdentifiers();
|
|
81
|
+
}, []);
|
|
82
|
+
|
|
83
|
+
const _submitIdentifiers = useCallback(
|
|
84
|
+
async (
|
|
85
|
+
identifiers: Onramp.ComplianceIdentifier[]
|
|
86
|
+
): Promise<Onramp.SubmitIdentifiersResult> => {
|
|
87
|
+
return requireOnrampModule().submitIdentifiers(identifiers);
|
|
88
|
+
},
|
|
89
|
+
[]
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
const _presentCRSCARFDeclaration =
|
|
93
|
+
useCallback(async (): Promise<Onramp.CRSCARFDeclarationResult> => {
|
|
94
|
+
return requireOnrampModule().presentCRSCARFDeclaration();
|
|
95
|
+
}, []);
|
|
96
|
+
|
|
78
97
|
const _presentKycInfoVerification = useCallback(
|
|
79
98
|
async (updatedAddress: Address | null): Promise<Onramp.VerifyKycResult> => {
|
|
80
99
|
return requireOnrampModule().presentKycInfoVerification(updatedAddress);
|
|
@@ -244,6 +263,31 @@ export function useOnramp() {
|
|
|
244
263
|
*/
|
|
245
264
|
attachKycInfo: _attachKycInfo,
|
|
246
265
|
|
|
266
|
+
/**
|
|
267
|
+
* Retrieves any missing MiCA or CRS/CARF compliance identifiers for the current Link user.
|
|
268
|
+
* Requires an authenticated Link user.
|
|
269
|
+
*
|
|
270
|
+
* @returns Promise that resolves to identifier requirements and alternatives, or error
|
|
271
|
+
*/
|
|
272
|
+
retrieveMissingIdentifiers: _retrieveMissingIdentifiers,
|
|
273
|
+
|
|
274
|
+
/**
|
|
275
|
+
* Submits MiCA or CRS/CARF compliance identifiers for the current Link user.
|
|
276
|
+
* Requires an authenticated Link user.
|
|
277
|
+
*
|
|
278
|
+
* @param identifiers The compliance identifiers to submit
|
|
279
|
+
* @returns Promise that resolves to whether the submission was valid, any remaining requirements, invalid identifiers, or error
|
|
280
|
+
*/
|
|
281
|
+
submitIdentifiers: _submitIdentifiers,
|
|
282
|
+
|
|
283
|
+
/**
|
|
284
|
+
* Presents UI for the current Link user to accept the CRS/CARF declaration.
|
|
285
|
+
* Requires an authenticated Link user.
|
|
286
|
+
*
|
|
287
|
+
* @returns Promise that resolves to `Confirmed` when accepted, or error
|
|
288
|
+
*/
|
|
289
|
+
presentCRSCARFDeclaration: _presentCRSCARFDeclaration,
|
|
290
|
+
|
|
247
291
|
/**
|
|
248
292
|
* Presents UI to verify KYC information for the current Link user.
|
|
249
293
|
* Requires the user to be authenticated with prior calls to either `authenticateUserWithToken` or `authorize`,
|
|
@@ -19,6 +19,11 @@ export interface Spec extends TurboModule {
|
|
|
19
19
|
attachKycInfo(
|
|
20
20
|
kycInfo: UnsafeObject<Onramp.KycInfo>
|
|
21
21
|
): Promise<Onramp.VoidResult>;
|
|
22
|
+
retrieveMissingIdentifiers(): Promise<Onramp.RetrieveMissingIdentifiersResult>;
|
|
23
|
+
submitIdentifiers(
|
|
24
|
+
identifiers: ReadonlyArray<UnsafeObject<Onramp.ComplianceIdentifier>>
|
|
25
|
+
): Promise<Onramp.SubmitIdentifiersResult>;
|
|
26
|
+
presentCRSCARFDeclaration(): Promise<Onramp.CRSCARFDeclarationResult>;
|
|
22
27
|
presentKycInfoVerification: (
|
|
23
28
|
updatedAddress: UnsafeObject<Address> | null
|
|
24
29
|
) => Promise<Onramp.VerifyKycResult>;
|
|
@@ -262,7 +262,14 @@ export interface Spec extends TurboModule {
|
|
|
262
262
|
value: string
|
|
263
263
|
): Promise<UnsafeObject<Checkout.State>>;
|
|
264
264
|
|
|
265
|
-
|
|
265
|
+
checkoutRunServerUpdateStart(
|
|
266
|
+
sessionKey: string
|
|
267
|
+
): Promise<UnsafeObject<Checkout.State>>;
|
|
268
|
+
|
|
269
|
+
checkoutRunServerUpdateComplete(
|
|
270
|
+
sessionKey: string,
|
|
271
|
+
error: string | null
|
|
272
|
+
): Promise<void>;
|
|
266
273
|
|
|
267
274
|
setFinancialConnectionsForceNativeFlow(enabled: boolean): Promise<void>;
|
|
268
275
|
|