@stripe/stripe-react-native 0.2.4 → 0.3.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 +8 -0
- package/README.md +5 -18
- package/android/build.gradle +1 -1
- package/android/src/main/java/com/reactnativestripesdk/GooglePayPaymentMethodLauncherFragment.kt +44 -0
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkCardView.kt +30 -23
- package/android/src/main/java/com/reactnativestripesdk/StripeSdkModule.kt +33 -20
- package/ios/StripeSdk.swift +1 -0
- package/lib/commonjs/NativeStripeSdk.js.map +1 -1
- package/lib/commonjs/functions.js +1 -1
- package/lib/commonjs/functions.js.map +1 -1
- package/lib/commonjs/hooks/useGooglePay.js +1 -1
- package/lib/commonjs/hooks/useGooglePay.js.map +1 -1
- package/lib/commonjs/hooks/useStripe.js +1 -1
- package/lib/commonjs/hooks/useStripe.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/GooglePay.js.map +1 -1
- package/lib/module/NativeStripeSdk.js.map +1 -1
- package/lib/module/functions.js +1 -1
- package/lib/module/functions.js.map +1 -1
- package/lib/module/hooks/useGooglePay.js +1 -1
- package/lib/module/hooks/useGooglePay.js.map +1 -1
- package/lib/module/hooks/useStripe.js +1 -1
- package/lib/module/hooks/useStripe.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/GooglePay.js.map +1 -1
- package/lib/typescript/e2e/screenObject/HomeScreen.d.ts +1 -1
- package/lib/typescript/example/src/App.d.ts +1 -0
- package/lib/typescript/example/src/screens/CreateTokenScreen.d.ts +1 -0
- package/lib/typescript/src/NativeStripeSdk.d.ts +1 -0
- package/lib/typescript/src/functions.d.ts +1 -0
- package/lib/typescript/src/hooks/useGooglePay.d.ts +1 -0
- package/lib/typescript/src/hooks/useStripe.d.ts +1 -0
- package/lib/typescript/src/types/Errors.d.ts +4 -0
- package/lib/typescript/src/types/GooglePay.d.ts +6 -6
- package/package.json +2 -9
- package/src/NativeStripeSdk.tsx +3 -0
- package/src/functions.ts +20 -1
- package/src/hooks/useGooglePay.tsx +19 -2
- package/src/hooks/useStripe.tsx +9 -0
- package/src/types/Errors.ts +6 -0
- package/src/types/GooglePay.ts +7 -6
- package/stripe-react-native.podspec +1 -1
|
@@ -11,8 +11,7 @@ export declare namespace GooglePay {
|
|
|
11
11
|
interface SetupIntentParams {
|
|
12
12
|
clientSecret: string;
|
|
13
13
|
}
|
|
14
|
-
|
|
15
|
-
testEnv: boolean;
|
|
14
|
+
type InitParams = {
|
|
16
15
|
merchantName: string;
|
|
17
16
|
countryCode: string;
|
|
18
17
|
/**
|
|
@@ -25,14 +24,15 @@ export declare namespace GooglePay {
|
|
|
25
24
|
* Default to `false`.
|
|
26
25
|
*/
|
|
27
26
|
isEmailRequired?: boolean;
|
|
27
|
+
} & IsGooglePaySupportedParams;
|
|
28
|
+
type IsGooglePaySupportedParams = {
|
|
29
|
+
testEnv?: boolean;
|
|
28
30
|
/**
|
|
29
31
|
* If `true`, Google Pay is considered ready if the customer's Google Pay wallet
|
|
30
|
-
* has existing payment
|
|
31
|
-
*
|
|
32
|
-
* Default to `false`.
|
|
32
|
+
* has an existing payment method.
|
|
33
33
|
*/
|
|
34
34
|
existingPaymentMethodRequired?: boolean;
|
|
35
|
-
}
|
|
35
|
+
};
|
|
36
36
|
interface BillingAddressConfig {
|
|
37
37
|
isRequired?: boolean;
|
|
38
38
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stripe/stripe-react-native",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"author": "Stripe",
|
|
5
5
|
"description": "Stripe SDK for React Native",
|
|
6
6
|
"main": "lib/commonjs/index",
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
"example": "yarn --cwd example",
|
|
28
28
|
"pods": "cd example && pod-install --quiet",
|
|
29
29
|
"bootstrap": "yarn example && yarn && yarn pods",
|
|
30
|
+
"bootstrap-no-pods": "yarn example && yarn",
|
|
30
31
|
"docs": "yarn typedoc ./src/index.tsx --out ./docs/api-reference --tsconfig ./tsconfig.json --theme minimal --theme ./docs/stripe-theme",
|
|
31
32
|
"run-example-ios": "cd example;ENVFILE=.env.ci react-native run-ios --configuration Release --simulator \"iPhone 12\"",
|
|
32
33
|
"run-example-android": "cd example;ENVFILE=.env.ci react-native run-android --variant=release",
|
|
@@ -46,7 +47,6 @@
|
|
|
46
47
|
"homepage": "https://github.com/stripe/stripe-react-native/#readme",
|
|
47
48
|
"devDependencies": {
|
|
48
49
|
"@babel/plugin-transform-typescript": "^7.13.0",
|
|
49
|
-
"@commitlint/config-conventional": "^8.3.4",
|
|
50
50
|
"@react-native-community/bob": "^0.16.2",
|
|
51
51
|
"@react-native-community/eslint-config": "^2.0.0",
|
|
52
52
|
"@release-it/conventional-changelog": "^1.1.4",
|
|
@@ -63,7 +63,6 @@
|
|
|
63
63
|
"appium": "^1.22.1",
|
|
64
64
|
"appium-chromedriver": "4.26.2",
|
|
65
65
|
"appium-doctor": "^1.16.0",
|
|
66
|
-
"commitlint": "^8.3.5",
|
|
67
66
|
"eslint": "^7.14.0",
|
|
68
67
|
"eslint-config-prettier": "^6.11.0",
|
|
69
68
|
"eslint-plugin-prettier": "^3.1.3",
|
|
@@ -98,15 +97,9 @@
|
|
|
98
97
|
},
|
|
99
98
|
"husky": {
|
|
100
99
|
"hooks": {
|
|
101
|
-
"commit-msg": "commitlint -E HUSKY_GIT_PARAMS",
|
|
102
100
|
"pre-commit": "yarn lint && yarn typescript"
|
|
103
101
|
}
|
|
104
102
|
},
|
|
105
|
-
"commitlint": {
|
|
106
|
-
"extends": [
|
|
107
|
-
"@commitlint/config-conventional"
|
|
108
|
-
]
|
|
109
|
-
},
|
|
110
103
|
"eslintConfig": {
|
|
111
104
|
"extends": [
|
|
112
105
|
"@react-native-community",
|
package/src/NativeStripeSdk.tsx
CHANGED
|
@@ -66,6 +66,9 @@ type NativeStripeSdkType = {
|
|
|
66
66
|
createTokenForCVCUpdate(cvc: string): Promise<CreateTokenForCVCUpdateResult>;
|
|
67
67
|
handleURLCallback(url: string): Promise<boolean>;
|
|
68
68
|
createToken(params: CreateTokenParams): Promise<CreateTokenResult>;
|
|
69
|
+
isGooglePaySupported(
|
|
70
|
+
params: GooglePay.IsGooglePaySupportedParams
|
|
71
|
+
): Promise<boolean>;
|
|
69
72
|
initGooglePay(params: GooglePay.InitParams): Promise<GooglePayInitResult>;
|
|
70
73
|
presentGooglePay(
|
|
71
74
|
params: GooglePay.PresentGooglePayParams
|
package/src/functions.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { createError, isiOS } from './helpers';
|
|
1
|
+
import { createError, isAndroid, isiOS } from './helpers';
|
|
2
|
+
import { MissingRoutingNumber } from './types/Errors';
|
|
2
3
|
import NativeStripeSdk from './NativeStripeSdk';
|
|
3
4
|
import {
|
|
4
5
|
ApplePay,
|
|
@@ -57,6 +58,16 @@ export const createPaymentMethod = async (
|
|
|
57
58
|
export const createToken = async (
|
|
58
59
|
params: CreateTokenParams
|
|
59
60
|
): Promise<CreateTokenResult> => {
|
|
61
|
+
if (
|
|
62
|
+
params.type === 'BankAccount' &&
|
|
63
|
+
params.country?.toLowerCase() === 'us' &&
|
|
64
|
+
!params.routingNumber
|
|
65
|
+
) {
|
|
66
|
+
return {
|
|
67
|
+
error: MissingRoutingNumber,
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
|
|
60
71
|
try {
|
|
61
72
|
const { token, error } = await NativeStripeSdk.createToken(params);
|
|
62
73
|
|
|
@@ -362,6 +373,14 @@ export const confirmPaymentSheetPayment =
|
|
|
362
373
|
}
|
|
363
374
|
};
|
|
364
375
|
|
|
376
|
+
export const isGooglePaySupported = async (
|
|
377
|
+
params?: GooglePay.IsGooglePaySupportedParams
|
|
378
|
+
): Promise<boolean> => {
|
|
379
|
+
return (
|
|
380
|
+
isAndroid && (await NativeStripeSdk.isGooglePaySupported(params ?? {}))
|
|
381
|
+
);
|
|
382
|
+
};
|
|
383
|
+
|
|
365
384
|
export const initGooglePay = async (
|
|
366
385
|
params: GooglePay.InitParams
|
|
367
386
|
): Promise<GooglePayInitResult> => {
|
|
@@ -6,10 +6,26 @@ import { useStripe } from './useStripe';
|
|
|
6
6
|
* useGooglePay hook
|
|
7
7
|
*/
|
|
8
8
|
export function useGooglePay() {
|
|
9
|
-
const {
|
|
10
|
-
|
|
9
|
+
const {
|
|
10
|
+
isGooglePaySupported,
|
|
11
|
+
initGooglePay,
|
|
12
|
+
presentGooglePay,
|
|
13
|
+
createGooglePayPaymentMethod,
|
|
14
|
+
} = useStripe();
|
|
11
15
|
const [loading, setLoading] = useState(false);
|
|
12
16
|
|
|
17
|
+
const _isGooglePaySupported = useCallback(
|
|
18
|
+
async (params?: GooglePay.IsGooglePaySupportedParams) => {
|
|
19
|
+
setLoading(true);
|
|
20
|
+
|
|
21
|
+
const result = await isGooglePaySupported(params);
|
|
22
|
+
setLoading(false);
|
|
23
|
+
|
|
24
|
+
return result;
|
|
25
|
+
},
|
|
26
|
+
[isGooglePaySupported]
|
|
27
|
+
);
|
|
28
|
+
|
|
13
29
|
const _initGooglePay = useCallback(
|
|
14
30
|
async (params: GooglePay.InitParams) => {
|
|
15
31
|
setLoading(true);
|
|
@@ -48,6 +64,7 @@ export function useGooglePay() {
|
|
|
48
64
|
|
|
49
65
|
return {
|
|
50
66
|
loading,
|
|
67
|
+
isGooglePaySupported: _isGooglePaySupported,
|
|
51
68
|
initGooglePay: _initGooglePay,
|
|
52
69
|
presentGooglePay: _presentGooglePay,
|
|
53
70
|
createGooglePayPaymentMethod: _createGooglePayPaymentMethod,
|
package/src/hooks/useStripe.tsx
CHANGED
|
@@ -43,6 +43,7 @@ import {
|
|
|
43
43
|
presentPaymentSheet,
|
|
44
44
|
confirmPaymentSheetPayment,
|
|
45
45
|
createToken,
|
|
46
|
+
isGooglePaySupported,
|
|
46
47
|
initGooglePay,
|
|
47
48
|
createGooglePayPaymentMethod,
|
|
48
49
|
presentGooglePay,
|
|
@@ -191,6 +192,13 @@ export function useStripe() {
|
|
|
191
192
|
[]
|
|
192
193
|
);
|
|
193
194
|
|
|
195
|
+
const _isGooglePaySupported = useCallback(
|
|
196
|
+
async (params?: GooglePay.IsGooglePaySupportedParams): Promise<boolean> => {
|
|
197
|
+
return isGooglePaySupported(params);
|
|
198
|
+
},
|
|
199
|
+
[]
|
|
200
|
+
);
|
|
201
|
+
|
|
194
202
|
const _initGooglePay = useCallback(
|
|
195
203
|
async (params: GooglePay.InitParams): Promise<GooglePayInitResult> => {
|
|
196
204
|
return initGooglePay(params);
|
|
@@ -238,6 +246,7 @@ export function useStripe() {
|
|
|
238
246
|
presentPaymentSheet: _presentPaymentSheet,
|
|
239
247
|
initPaymentSheet: _initPaymentSheet,
|
|
240
248
|
createToken: _createToken,
|
|
249
|
+
isGooglePaySupported: _isGooglePaySupported,
|
|
241
250
|
initGooglePay: _initGooglePay,
|
|
242
251
|
presentGooglePay: _presentGooglePay,
|
|
243
252
|
createGooglePayPaymentMethod: _createGooglePayPaymentMethod,
|
package/src/types/Errors.ts
CHANGED
|
@@ -66,3 +66,9 @@ export enum GooglePayError {
|
|
|
66
66
|
Canceled = 'Canceled',
|
|
67
67
|
Unknown = 'Unknown',
|
|
68
68
|
}
|
|
69
|
+
|
|
70
|
+
export const MissingRoutingNumber = {
|
|
71
|
+
code: CreateTokenError.Failed,
|
|
72
|
+
message:
|
|
73
|
+
'You must provide a routing number for US bank accounts. This should be the ACH routing number.',
|
|
74
|
+
};
|
package/src/types/GooglePay.ts
CHANGED
|
@@ -28,8 +28,7 @@ export namespace GooglePay {
|
|
|
28
28
|
clientSecret: string;
|
|
29
29
|
}
|
|
30
30
|
|
|
31
|
-
export
|
|
32
|
-
testEnv: boolean;
|
|
31
|
+
export type InitParams = {
|
|
33
32
|
merchantName: string;
|
|
34
33
|
countryCode: string;
|
|
35
34
|
/**
|
|
@@ -42,14 +41,16 @@ export namespace GooglePay {
|
|
|
42
41
|
* Default to `false`.
|
|
43
42
|
*/
|
|
44
43
|
isEmailRequired?: boolean;
|
|
44
|
+
} & IsGooglePaySupportedParams;
|
|
45
|
+
|
|
46
|
+
export type IsGooglePaySupportedParams = {
|
|
47
|
+
testEnv?: boolean;
|
|
45
48
|
/**
|
|
46
49
|
* If `true`, Google Pay is considered ready if the customer's Google Pay wallet
|
|
47
|
-
* has existing payment
|
|
48
|
-
*
|
|
49
|
-
* Default to `false`.
|
|
50
|
+
* has an existing payment method.
|
|
50
51
|
*/
|
|
51
52
|
existingPaymentMethodRequired?: boolean;
|
|
52
|
-
}
|
|
53
|
+
};
|
|
53
54
|
|
|
54
55
|
export interface BillingAddressConfig {
|
|
55
56
|
isRequired?: boolean;
|