@stripe/stripe-react-native 0.20.0 → 0.21.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/CHANGELOG.md +13 -0
- package/android/gradle.properties +1 -1
- package/android/src/main/java/com/reactnativestripesdk/CollectBankAccountLauncherFragment.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/FinancialConnectionsSheetFragment.kt +4 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayFragment.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentLauncherFragment.kt +1 -1
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetAppearance.kt +10 -9
- package/android/src/main/java/com/reactnativestripesdk/PaymentSheetFragment.kt +8 -3
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +20 -14
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkPackage.kt +3 -1
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressLauncherFragment.kt +111 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetEvent.kt +28 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetView.kt +178 -0
- package/android/src/main/java/com/reactnativestripesdk/addresssheet/AddressSheetViewManager.kt +67 -0
- package/android/src/main/java/com/reactnativestripesdk/utils/Mappers.kt +1 -1
- package/ios/AddressSheet/AddressSheetUtils.swift +98 -0
- package/ios/AddressSheet/AddressSheetView.swift +131 -0
- package/ios/AddressSheet/AddressSheetViewManager.m +25 -0
- package/ios/AddressSheet/AddressSheetViewManager.swift +19 -0
- package/ios/PaymentSheetAppearance.swift +24 -23
- package/ios/{pushprovisioning → PushProvisioning}/AddToWalletButtonManager.m +0 -0
- package/ios/{pushprovisioning → PushProvisioning}/AddToWalletButtonManager.swift +0 -0
- package/ios/{pushprovisioning → PushProvisioning}/AddToWalletButtonView.swift +0 -0
- package/ios/{pushprovisioning → PushProvisioning}/PushProvisioningUtils.swift +0 -0
- package/ios/StripeSdk.swift +7 -1
- package/ios/Tests/AddressSheetUtilsTests.swift +279 -0
- package/lib/commonjs/components/AddressSheet.js +2 -0
- package/lib/commonjs/components/AddressSheet.js.map +1 -0
- package/lib/commonjs/index.js +1 -1
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/types/Errors.js +1 -1
- package/lib/commonjs/types/Errors.js.map +1 -1
- package/lib/commonjs/types/index.js +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/components/AddressSheet.js +2 -0
- package/lib/module/components/AddressSheet.js.map +1 -0
- package/lib/module/index.js +1 -1
- package/lib/module/index.js.map +1 -1
- package/lib/module/types/Errors.js +1 -1
- package/lib/module/types/Errors.js.map +1 -1
- package/lib/module/types/index.js +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/src/components/AddressSheet.d.ts +53 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/types/Common.d.ts +12 -0
- package/lib/typescript/src/types/Errors.d.ts +4 -0
- package/lib/typescript/src/types/PaymentSheet.d.ts +7 -1
- package/lib/typescript/src/types/index.d.ts +3 -6
- package/package.json +1 -1
- package/src/components/AddressSheet.tsx +82 -0
- package/src/index.tsx +4 -1
- package/src/types/Common.ts +13 -0
- package/src/types/Errors.ts +5 -0
- package/src/types/PaymentSheet.ts +7 -1
- package/src/types/index.ts +5 -10
- package/stripe-react-native.podspec +1 -1
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { AccessibilityProps } from 'react-native';
|
|
2
|
+
import type { PaymentSheet, AddressDetails, StripeError, AddressSheetError } from '../types';
|
|
3
|
+
/**
|
|
4
|
+
* Props
|
|
5
|
+
*/
|
|
6
|
+
export interface Props extends AccessibilityProps {
|
|
7
|
+
/** Whether the sheet is visible. Defaults to false. */
|
|
8
|
+
visible: boolean;
|
|
9
|
+
/** Controls how the modal is presented (after animation). iOS only. Defaults to `popover`. */
|
|
10
|
+
presentationStyle?: 'fullscreen' | 'popover';
|
|
11
|
+
/** Controls how the modal animates. iOS only. */
|
|
12
|
+
animationStyle?: 'flip' | 'curl' | 'slide' | 'dissolve';
|
|
13
|
+
/** Configuration for the look and feel of the UI. */
|
|
14
|
+
appearance?: PaymentSheet.AppearanceParams;
|
|
15
|
+
/** The values to prepopulate the sheet's fields with. */
|
|
16
|
+
defaultValues?: AddressDetails;
|
|
17
|
+
/** Configuration for additional fields besides the physical address */
|
|
18
|
+
additionalFields?: {
|
|
19
|
+
/** Determines whether the phone number is hidden, required, or optional. Defaults to hidden. */
|
|
20
|
+
phoneNumber?: 'hidden' | 'optional' | 'required';
|
|
21
|
+
/** The label of a checkbox displayed below other fields. If null or undefined, the checkbox is not displayed. */
|
|
22
|
+
checkboxLabel?: string;
|
|
23
|
+
};
|
|
24
|
+
/** A list of two-letter country codes representing countries the customers can select. If the list is empty (the default), we display all countries. */
|
|
25
|
+
allowedCountries?: Array<string>;
|
|
26
|
+
/** A list of two-letter country codes representing countries that support address autocomplete. Defaults to a list of countries that Stripe has audited to ensure a good autocomplete experience. */
|
|
27
|
+
autocompleteCountries?: Array<string>;
|
|
28
|
+
/** The title of the primary button displayed at the bottom of the screen. Defaults to "Save Address". */
|
|
29
|
+
primaryButtonTitle?: string;
|
|
30
|
+
/** Title displayed at the top of the sheet. Defaults to "Address". */
|
|
31
|
+
sheetTitle?: string;
|
|
32
|
+
/** Android only. Google Places api key used to provide autocomplete suggestions. When null, autocomplete is disabled on Android. */
|
|
33
|
+
googlePlacesApiKey?: string;
|
|
34
|
+
/** Called when the user submits their information */
|
|
35
|
+
onSubmit: (result: CollectAddressResult) => void;
|
|
36
|
+
/** Called when the user taps the button to close the sheet before submitting their information, or when an error occurs. */
|
|
37
|
+
onError: (error: StripeError<AddressSheetError>) => void;
|
|
38
|
+
}
|
|
39
|
+
export declare type CollectAddressResult = Required<AddressDetails>;
|
|
40
|
+
/**
|
|
41
|
+
*
|
|
42
|
+
*
|
|
43
|
+
* @example
|
|
44
|
+
* ```ts
|
|
45
|
+
* <AddressSheet
|
|
46
|
+
*
|
|
47
|
+
* />
|
|
48
|
+
* ```
|
|
49
|
+
* @param __namedParameters Props
|
|
50
|
+
* @returns JSX.Element
|
|
51
|
+
* @category ReactComponents
|
|
52
|
+
*/
|
|
53
|
+
export declare function AddressSheet({ onSubmit, onError, ...props }: Props): JSX.Element;
|
|
@@ -13,5 +13,6 @@ export { AuBECSDebitForm, Props as AuBECSDebitFormProps, } from './components/Au
|
|
|
13
13
|
export { StripeContainer, Props as StripeContainerProps, } from './components/StripeContainer';
|
|
14
14
|
export { GooglePayButton, Props as GooglePayButtonProps, } from './components/GooglePayButton';
|
|
15
15
|
export { AddToWalletButton, Props as AddToWalletButtonProps, } from './components/AddToWalletButton';
|
|
16
|
+
export { AddressSheet, Props as AddressSheetProps, } from './components/AddressSheet';
|
|
16
17
|
export * from './functions';
|
|
17
18
|
export * from './types/index';
|
|
@@ -12,3 +12,15 @@ export interface Address {
|
|
|
12
12
|
postalCode?: string;
|
|
13
13
|
state?: string;
|
|
14
14
|
}
|
|
15
|
+
export declare type AddressDetails = {
|
|
16
|
+
/** The customer's full name. */
|
|
17
|
+
name?: string;
|
|
18
|
+
/** The customer's address. */
|
|
19
|
+
address?: Address;
|
|
20
|
+
/** The customer's phone number. */
|
|
21
|
+
phone?: string;
|
|
22
|
+
/** Whether or not the checkbox is initally selected. Defaults to false.
|
|
23
|
+
* Note: The checkbox is displayed below the other fields when additionalFields.checkboxLabel is set.
|
|
24
|
+
* */
|
|
25
|
+
isCheckboxSelected?: boolean;
|
|
26
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BillingDetails } from './Common';
|
|
1
|
+
import type { BillingDetails, AddressDetails } from './Common';
|
|
2
2
|
import type { CartSummaryItem } from './ApplePay';
|
|
3
3
|
export declare type SetupParams = ClientSecretParams & {
|
|
4
4
|
/** Your customer-facing business name. On Android, this is required and cannot be an empty string. */
|
|
@@ -20,6 +20,12 @@ export declare type SetupParams = ClientSecretParams & {
|
|
|
20
20
|
returnURL?: string;
|
|
21
21
|
/** PaymentSheet pre-populates the billing fields with the values provided. */
|
|
22
22
|
defaultBillingDetails?: BillingDetails;
|
|
23
|
+
/**
|
|
24
|
+
* The shipping information for the customer. If set, PaymentSheet will pre-populate the form fields with the values provided.
|
|
25
|
+
* This is used to display a "Billing address is same as shipping" checkbox if `defaultBillingDetails` is not provided.
|
|
26
|
+
* If `name` and `line1` are populated, it's also [attached to the PaymentIntent](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-shipping) during payment.
|
|
27
|
+
*/
|
|
28
|
+
defaultShippingDetails?: AddressDetails;
|
|
23
29
|
/** If true, allows payment methods that do not move money at the end of the checkout. Defaults to false.
|
|
24
30
|
*
|
|
25
31
|
* Some payment methods can’t guarantee you will receive funds from your customer at the end of the checkout
|
|
@@ -14,7 +14,7 @@ import * as Token from './Token';
|
|
|
14
14
|
import * as FinancialConnections from './FinancialConnections';
|
|
15
15
|
export { ApplePay, PaymentIntent, PaymentMethod, PaymentSheet, SetupIntent, ThreeDSecure, GooglePay, ApplePayButtonComponent, AuBECSDebitFormComponent, CardFieldInput, CardFormView, Token, FinancialConnections, };
|
|
16
16
|
export * from './Errors';
|
|
17
|
-
export { Address, BillingDetails } from './Common';
|
|
17
|
+
export { Address, BillingDetails, AddressDetails } from './Common';
|
|
18
18
|
/**
|
|
19
19
|
* @ignore
|
|
20
20
|
*/
|
|
@@ -84,11 +84,8 @@ export declare type InitPaymentSheetResult = {
|
|
|
84
84
|
error: StripeError<PaymentSheetError>;
|
|
85
85
|
};
|
|
86
86
|
export declare type PresentPaymentSheetResult = {
|
|
87
|
-
paymentOption
|
|
88
|
-
error?: undefined;
|
|
89
|
-
} | {
|
|
90
|
-
paymentOption?: undefined;
|
|
91
|
-
error: StripeError<PaymentSheetError>;
|
|
87
|
+
paymentOption?: PaymentSheet.PaymentOption | undefined;
|
|
88
|
+
error?: StripeError<PaymentSheetError> | undefined;
|
|
92
89
|
};
|
|
93
90
|
export declare type CreateTokenResult = {
|
|
94
91
|
token: Token.Result;
|
package/package.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import {
|
|
3
|
+
AccessibilityProps,
|
|
4
|
+
requireNativeComponent,
|
|
5
|
+
NativeSyntheticEvent,
|
|
6
|
+
} from 'react-native';
|
|
7
|
+
import type {
|
|
8
|
+
PaymentSheet,
|
|
9
|
+
AddressDetails,
|
|
10
|
+
StripeError,
|
|
11
|
+
AddressSheetError,
|
|
12
|
+
} from '../types';
|
|
13
|
+
|
|
14
|
+
const AddressSheetNative = requireNativeComponent<any>('AddressSheetView');
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Props
|
|
18
|
+
*/
|
|
19
|
+
export interface Props extends AccessibilityProps {
|
|
20
|
+
/** Whether the sheet is visible. Defaults to false. */
|
|
21
|
+
visible: boolean;
|
|
22
|
+
/** Controls how the modal is presented (after animation). iOS only. Defaults to `popover`. */
|
|
23
|
+
presentationStyle?: 'fullscreen' | 'popover';
|
|
24
|
+
/** Controls how the modal animates. iOS only. */
|
|
25
|
+
animationStyle?: 'flip' | 'curl' | 'slide' | 'dissolve';
|
|
26
|
+
/** Configuration for the look and feel of the UI. */
|
|
27
|
+
appearance?: PaymentSheet.AppearanceParams;
|
|
28
|
+
/** The values to prepopulate the sheet's fields with. */
|
|
29
|
+
defaultValues?: AddressDetails;
|
|
30
|
+
/** Configuration for additional fields besides the physical address */
|
|
31
|
+
additionalFields?: {
|
|
32
|
+
/** Determines whether the phone number is hidden, required, or optional. Defaults to hidden. */
|
|
33
|
+
phoneNumber?: 'hidden' | 'optional' | 'required';
|
|
34
|
+
/** The label of a checkbox displayed below other fields. If null or undefined, the checkbox is not displayed. */
|
|
35
|
+
checkboxLabel?: string;
|
|
36
|
+
};
|
|
37
|
+
/** A list of two-letter country codes representing countries the customers can select. If the list is empty (the default), we display all countries. */
|
|
38
|
+
allowedCountries?: Array<string>;
|
|
39
|
+
/** A list of two-letter country codes representing countries that support address autocomplete. Defaults to a list of countries that Stripe has audited to ensure a good autocomplete experience. */
|
|
40
|
+
autocompleteCountries?: Array<string>;
|
|
41
|
+
/** The title of the primary button displayed at the bottom of the screen. Defaults to "Save Address". */
|
|
42
|
+
primaryButtonTitle?: string;
|
|
43
|
+
/** Title displayed at the top of the sheet. Defaults to "Address". */
|
|
44
|
+
sheetTitle?: string;
|
|
45
|
+
/** Android only. Google Places api key used to provide autocomplete suggestions. When null, autocomplete is disabled on Android. */
|
|
46
|
+
googlePlacesApiKey?: string;
|
|
47
|
+
/** Called when the user submits their information */
|
|
48
|
+
onSubmit: (result: CollectAddressResult) => void;
|
|
49
|
+
/** Called when the user taps the button to close the sheet before submitting their information, or when an error occurs. */
|
|
50
|
+
onError: (error: StripeError<AddressSheetError>) => void;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export type CollectAddressResult = Required<AddressDetails>;
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
*
|
|
57
|
+
*
|
|
58
|
+
* @example
|
|
59
|
+
* ```ts
|
|
60
|
+
* <AddressSheet
|
|
61
|
+
*
|
|
62
|
+
* />
|
|
63
|
+
* ```
|
|
64
|
+
* @param __namedParameters Props
|
|
65
|
+
* @returns JSX.Element
|
|
66
|
+
* @category ReactComponents
|
|
67
|
+
*/
|
|
68
|
+
export function AddressSheet({ onSubmit, onError, ...props }: Props) {
|
|
69
|
+
return (
|
|
70
|
+
<AddressSheetNative
|
|
71
|
+
{...props}
|
|
72
|
+
onSubmitAction={(value: NativeSyntheticEvent<CollectAddressResult>) =>
|
|
73
|
+
onSubmit(value.nativeEvent)
|
|
74
|
+
}
|
|
75
|
+
onErrorAction={(
|
|
76
|
+
value: NativeSyntheticEvent<{
|
|
77
|
+
error: StripeError<AddressSheetError>;
|
|
78
|
+
}>
|
|
79
|
+
) => onError(value.nativeEvent.error)}
|
|
80
|
+
/>
|
|
81
|
+
);
|
|
82
|
+
}
|
package/src/index.tsx
CHANGED
|
@@ -35,7 +35,10 @@ export {
|
|
|
35
35
|
AddToWalletButton,
|
|
36
36
|
Props as AddToWalletButtonProps,
|
|
37
37
|
} from './components/AddToWalletButton';
|
|
38
|
-
|
|
38
|
+
export {
|
|
39
|
+
AddressSheet,
|
|
40
|
+
Props as AddressSheetProps,
|
|
41
|
+
} from './components/AddressSheet';
|
|
39
42
|
export * from './functions';
|
|
40
43
|
|
|
41
44
|
export * from './types/index';
|
package/src/types/Common.ts
CHANGED
|
@@ -13,3 +13,16 @@ export interface Address {
|
|
|
13
13
|
postalCode?: string;
|
|
14
14
|
state?: string;
|
|
15
15
|
}
|
|
16
|
+
|
|
17
|
+
export type AddressDetails = {
|
|
18
|
+
/** The customer's full name. */
|
|
19
|
+
name?: string;
|
|
20
|
+
/** The customer's address. */
|
|
21
|
+
address?: Address;
|
|
22
|
+
/** The customer's phone number. */
|
|
23
|
+
phone?: string;
|
|
24
|
+
/** Whether or not the checkbox is initally selected. Defaults to false.
|
|
25
|
+
* Note: The checkbox is displayed below the other fields when additionalFields.checkboxLabel is set.
|
|
26
|
+
* */
|
|
27
|
+
isCheckboxSelected?: boolean;
|
|
28
|
+
};
|
package/src/types/Errors.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { BillingDetails } from './Common';
|
|
1
|
+
import type { BillingDetails, AddressDetails } from './Common';
|
|
2
2
|
import type { CartSummaryItem } from './ApplePay';
|
|
3
3
|
|
|
4
4
|
export type SetupParams = ClientSecretParams & {
|
|
@@ -21,6 +21,12 @@ export type SetupParams = ClientSecretParams & {
|
|
|
21
21
|
returnURL?: string;
|
|
22
22
|
/** PaymentSheet pre-populates the billing fields with the values provided. */
|
|
23
23
|
defaultBillingDetails?: BillingDetails;
|
|
24
|
+
/**
|
|
25
|
+
* The shipping information for the customer. If set, PaymentSheet will pre-populate the form fields with the values provided.
|
|
26
|
+
* This is used to display a "Billing address is same as shipping" checkbox if `defaultBillingDetails` is not provided.
|
|
27
|
+
* If `name` and `line1` are populated, it's also [attached to the PaymentIntent](https://stripe.com/docs/api/payment_intents/object#payment_intent_object-shipping) during payment.
|
|
28
|
+
*/
|
|
29
|
+
defaultShippingDetails?: AddressDetails;
|
|
24
30
|
/** If true, allows payment methods that do not move money at the end of the checkout. Defaults to false.
|
|
25
31
|
*
|
|
26
32
|
* Some payment methods can’t guarantee you will receive funds from your customer at the end of the checkout
|
package/src/types/index.ts
CHANGED
|
@@ -44,7 +44,7 @@ export {
|
|
|
44
44
|
};
|
|
45
45
|
|
|
46
46
|
export * from './Errors';
|
|
47
|
-
export { Address, BillingDetails } from './Common';
|
|
47
|
+
export { Address, BillingDetails, AddressDetails } from './Common';
|
|
48
48
|
|
|
49
49
|
/**
|
|
50
50
|
* @ignore
|
|
@@ -140,15 +140,10 @@ export type InitPaymentSheetResult =
|
|
|
140
140
|
error: StripeError<PaymentSheetError>;
|
|
141
141
|
};
|
|
142
142
|
|
|
143
|
-
export type PresentPaymentSheetResult =
|
|
144
|
-
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
}
|
|
148
|
-
| {
|
|
149
|
-
paymentOption?: undefined;
|
|
150
|
-
error: StripeError<PaymentSheetError>;
|
|
151
|
-
};
|
|
143
|
+
export type PresentPaymentSheetResult = {
|
|
144
|
+
paymentOption?: PaymentSheet.PaymentOption | undefined;
|
|
145
|
+
error?: StripeError<PaymentSheetError> | undefined;
|
|
146
|
+
};
|
|
152
147
|
|
|
153
148
|
export type CreateTokenResult =
|
|
154
149
|
| {
|