framepayments-react-native 2.1.0 → 2.1.2
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 +101 -74
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameGooglePayActivity.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity.dex +0 -0
- package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameSDKModule.dex +0 -0
- package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
- package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameGooglePayActivity.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity.class +0 -0
- package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameSDKModule.class +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
- package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
- package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameGooglePayActivity.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity.class +0 -0
- package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameSDKModule.class +0 -0
- package/android/build.gradle +3 -3
- package/android/src/main/java/com/framepayments/reactnativeframe/FrameCheckoutActivity.kt +17 -13
- package/android/src/main/java/com/framepayments/reactnativeframe/FrameFlowActivity.kt +18 -11
- package/android/src/main/java/com/framepayments/reactnativeframe/FrameGooglePayActivity.kt +31 -8
- package/android/src/main/java/com/framepayments/reactnativeframe/FrameSDKModule.kt +37 -36
- package/ios/ApplePayPresenter.swift +53 -28
- package/ios/FrameRNTheme.swift +3 -24
- package/ios/FrameSDKBridge.m +10 -17
- package/ios/FrameSDKBridge.swift +89 -64
- package/lib/errors.d.ts +9 -1
- package/lib/errors.d.ts.map +1 -1
- package/lib/errors.js +9 -1
- package/lib/index.d.ts +4 -5
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +3 -4
- package/lib/native.d.ts +41 -13
- package/lib/native.d.ts.map +1 -1
- package/lib/native.js +64 -23
- package/lib/types.d.ts +18 -45
- package/lib/types.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/__tests__/native.test.ts +179 -25
- package/src/errors.ts +9 -1
- package/src/index.ts +2 -7
- package/src/native.ts +83 -32
- package/src/types.ts +19 -58
- /package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/{FrameSDKModule$$InternalSyntheticLambda$2$984ab30558bc904ed37602fa6e3ebf28f1ed69df6712b31b00c4f26fc26d3b70$0.globals → FrameSDKModule$$InternalSyntheticLambda$2$7347ff5b95d03cf5be9ee5177309c1bf4be5faabda2bbedb79f5f4c91917c2b1$0.globals} +0 -0
- /package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/{FrameSDKModule$$InternalSyntheticLambda$2$f8d46f7169c404d37a1d505f19439b83090fbed62b5bdaf1e86717fdddebf622$0.globals → FrameSDKModule$$InternalSyntheticLambda$2$7347ff5b95d03cf5be9ee5177309c1bf4be5faabda2bbedb79f5f4c91917c2b1$1.globals} +0 -0
- /package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_global-synthetics/com/framepayments/reactnativeframe/{FrameSDKModule$$InternalSyntheticLambda$2$f8d46f7169c404d37a1d505f19439b83090fbed62b5bdaf1e86717fdddebf622$1.globals → FrameSDKModule$$InternalSyntheticLambda$2$9816d2cb3db63bf5efb3411b62dbb57847dd7ef82f88bae5f375baced7880f11$0.globals} +0 -0
package/src/native.ts
CHANGED
|
@@ -4,7 +4,6 @@
|
|
|
4
4
|
|
|
5
5
|
import { NativeModules, Platform } from 'react-native';
|
|
6
6
|
import type {
|
|
7
|
-
ChargeIntent,
|
|
8
7
|
FrameCartItem,
|
|
9
8
|
FrameTheme,
|
|
10
9
|
OnboardingCapability,
|
|
@@ -14,6 +13,20 @@ import type {
|
|
|
14
13
|
} from './types';
|
|
15
14
|
import { ErrorCodes } from './errors';
|
|
16
15
|
|
|
16
|
+
/**
|
|
17
|
+
* Throw a coded error from synchronous JS validation. Mirrors the `code`/`message`
|
|
18
|
+
* shape that native rejections produce so consumers can catch `e.code === 'INVALID_*'`
|
|
19
|
+
* uniformly.
|
|
20
|
+
*/
|
|
21
|
+
function throwCoded(code: string, message: string): never {
|
|
22
|
+
const err = new Error(message) as Error & { code: string };
|
|
23
|
+
err.code = code;
|
|
24
|
+
throw err;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// theme is iOS-only today: frame-android does not yet have a matching theme API,
|
|
28
|
+
// so the field is accepted on both platforms but ignored on Android until it does.
|
|
29
|
+
|
|
17
30
|
const LINKING_ERROR =
|
|
18
31
|
`The package 'framepayments-react-native' doesn't seem to be linked. Make sure you have run 'pod install' (iOS) or rebuilt the app (Android).`;
|
|
19
32
|
|
|
@@ -34,18 +47,29 @@ export function initialize(options: {
|
|
|
34
47
|
secretKey: string;
|
|
35
48
|
publishableKey: string;
|
|
36
49
|
debugMode?: boolean;
|
|
50
|
+
/**
|
|
51
|
+
* Optional theme applied SDK-wide to Frame's reusable iOS components
|
|
52
|
+
* (checkout, cart, onboarding). Pass any subset — unspecified tokens fall
|
|
53
|
+
* back to SDK defaults. No-op on Android until frame-android ships a
|
|
54
|
+
* matching theme API.
|
|
55
|
+
*/
|
|
56
|
+
theme?: FrameTheme;
|
|
37
57
|
}): Promise<void> {
|
|
38
58
|
if (!options?.secretKey) {
|
|
39
|
-
|
|
59
|
+
throwCoded(ErrorCodes.INIT_FAILED, 'Frame.initialize requires secretKey');
|
|
40
60
|
}
|
|
41
61
|
if (!options?.publishableKey) {
|
|
42
|
-
|
|
62
|
+
throwCoded(ErrorCodes.INIT_FAILED, 'Frame.initialize requires publishableKey');
|
|
63
|
+
}
|
|
64
|
+
if (options.theme !== undefined && (typeof options.theme !== 'object' || Array.isArray(options.theme))) {
|
|
65
|
+
throwCoded(ErrorCodes.INIT_FAILED, 'Frame.initialize: theme must be an object');
|
|
43
66
|
}
|
|
44
67
|
return wrapPromise(
|
|
45
68
|
FrameSDK.initialize(
|
|
46
69
|
options.secretKey,
|
|
47
70
|
options.publishableKey,
|
|
48
|
-
options.debugMode ?? false
|
|
71
|
+
options.debugMode ?? false,
|
|
72
|
+
options.theme ?? null
|
|
49
73
|
)
|
|
50
74
|
).then(() => {
|
|
51
75
|
isInitialized = true;
|
|
@@ -74,25 +98,46 @@ function wrapPromise<T>(p: Promise<T>): Promise<T> {
|
|
|
74
98
|
});
|
|
75
99
|
}
|
|
76
100
|
|
|
101
|
+
/**
|
|
102
|
+
* Presents the Frame checkout sheet for the given account. Resolves with the
|
|
103
|
+
* created Transfer's id string on success, or rejects with `USER_CANCELED` if
|
|
104
|
+
* the user dismisses the sheet.
|
|
105
|
+
*
|
|
106
|
+
* `accountId` is required: the bundled checkout creates a `Transfer`, which is
|
|
107
|
+
* account-scoped. Callers needing a customer/ChargeIntent flow should use
|
|
108
|
+
* `presentApplePay` / `presentGooglePay` directly with a customer owner.
|
|
109
|
+
*/
|
|
77
110
|
export function presentCheckout(options: {
|
|
78
|
-
|
|
111
|
+
accountId: string;
|
|
79
112
|
amount: number;
|
|
80
|
-
}): Promise<
|
|
113
|
+
}): Promise<string> {
|
|
81
114
|
guardInitialized();
|
|
115
|
+
if (!options?.accountId) {
|
|
116
|
+
throwCoded(ErrorCodes.INVALID_ACCOUNT, 'Frame.presentCheckout requires accountId');
|
|
117
|
+
}
|
|
82
118
|
return wrapPromise(
|
|
83
|
-
FrameSDK.presentCheckout(options.
|
|
119
|
+
FrameSDK.presentCheckout(options.accountId, options.amount)
|
|
84
120
|
);
|
|
85
121
|
}
|
|
86
122
|
|
|
123
|
+
/**
|
|
124
|
+
* Presents the Frame cart UI; tapping checkout routes through the same flow
|
|
125
|
+
* as `presentCheckout` and resolves with the created Transfer's id string.
|
|
126
|
+
*
|
|
127
|
+
* `accountId` is required for the same reason as `presentCheckout`.
|
|
128
|
+
*/
|
|
87
129
|
export function presentCart(options: {
|
|
88
|
-
|
|
130
|
+
accountId: string;
|
|
89
131
|
items: FrameCartItem[];
|
|
90
132
|
shippingAmountInCents: number;
|
|
91
|
-
}): Promise<
|
|
133
|
+
}): Promise<string> {
|
|
92
134
|
guardInitialized();
|
|
135
|
+
if (!options?.accountId) {
|
|
136
|
+
throwCoded(ErrorCodes.INVALID_ACCOUNT, 'Frame.presentCart requires accountId');
|
|
137
|
+
}
|
|
93
138
|
return wrapPromise(
|
|
94
139
|
FrameSDK.presentCart(
|
|
95
|
-
options.
|
|
140
|
+
options.accountId,
|
|
96
141
|
options.items,
|
|
97
142
|
options.shippingAmountInCents
|
|
98
143
|
)
|
|
@@ -124,16 +169,24 @@ export function presentOnboarding(options: {
|
|
|
124
169
|
);
|
|
125
170
|
}
|
|
126
171
|
|
|
127
|
-
|
|
172
|
+
/**
|
|
173
|
+
* Presents the Apple Pay sheet and creates a charge from the resulting wallet
|
|
174
|
+
* payment method. Resolves with the created resource's id string on success,
|
|
175
|
+
* or rejects with `USER_CANCELED` if the sheet is dismissed.
|
|
176
|
+
*
|
|
177
|
+
* - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
|
|
178
|
+
* - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
|
|
179
|
+
*/
|
|
180
|
+
export function presentApplePay(options: PresentApplePayOptions): Promise<string> {
|
|
128
181
|
guardInitialized();
|
|
129
182
|
if (!options?.owner || (options.owner.type !== 'customer' && options.owner.type !== 'account')) {
|
|
130
|
-
|
|
183
|
+
throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentApplePay requires owner: { type: "customer" | "account", id: string }');
|
|
131
184
|
}
|
|
132
185
|
if (!options.owner.id) {
|
|
133
|
-
|
|
186
|
+
throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentApplePay requires owner.id');
|
|
134
187
|
}
|
|
135
188
|
if (!options.merchantId) {
|
|
136
|
-
|
|
189
|
+
throwCoded(ErrorCodes.INVALID_MERCHANT_ID, 'Frame.presentApplePay requires merchantId');
|
|
137
190
|
}
|
|
138
191
|
return wrapPromise(
|
|
139
192
|
FrameSDK.presentApplePay(
|
|
@@ -146,30 +199,28 @@ export function presentApplePay(options: PresentApplePayOptions): Promise<Charge
|
|
|
146
199
|
);
|
|
147
200
|
}
|
|
148
201
|
|
|
149
|
-
|
|
202
|
+
/**
|
|
203
|
+
* Presents Google Pay and creates a charge from the resulting wallet payment method.
|
|
204
|
+
* Resolves with the created resource's id string on success.
|
|
205
|
+
*
|
|
206
|
+
* - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
|
|
207
|
+
* - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
|
|
208
|
+
*/
|
|
209
|
+
export function presentGooglePay(options: PresentGooglePayOptions): Promise<string> {
|
|
150
210
|
guardInitialized();
|
|
211
|
+
if (!options?.owner || (options.owner.type !== 'customer' && options.owner.type !== 'account')) {
|
|
212
|
+
throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentGooglePay requires owner: { type: "customer" | "account", id: string }');
|
|
213
|
+
}
|
|
214
|
+
if (!options.owner.id) {
|
|
215
|
+
throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentGooglePay requires owner.id');
|
|
216
|
+
}
|
|
151
217
|
return wrapPromise(
|
|
152
218
|
FrameSDK.presentGooglePay(
|
|
153
219
|
options.amountCents,
|
|
154
|
-
options.
|
|
220
|
+
options.owner.type,
|
|
221
|
+
options.owner.id,
|
|
155
222
|
options.currencyCode ?? 'USD',
|
|
156
223
|
options.googlePayMerchantId ?? null
|
|
157
224
|
)
|
|
158
225
|
);
|
|
159
226
|
}
|
|
160
|
-
|
|
161
|
-
/**
|
|
162
|
-
* Configure colors, fonts, and corner radii for Frame's reusable iOS
|
|
163
|
-
* components. Applied to every subsequent `present*` call; an in-flight modal
|
|
164
|
-
* is not re-themed mid-flow.
|
|
165
|
-
*
|
|
166
|
-
* Pass `null` or `{}` to reset to SDK defaults. Android is a no-op until
|
|
167
|
-
* frame-android ships a matching theme API.
|
|
168
|
-
*/
|
|
169
|
-
export function setTheme(theme: FrameTheme | null): Promise<void> {
|
|
170
|
-
if (theme !== null && (typeof theme !== 'object' || Array.isArray(theme))) {
|
|
171
|
-
throw new Error('Frame.setTheme requires a theme object or null');
|
|
172
|
-
}
|
|
173
|
-
if (Platform.OS !== 'ios') return Promise.resolve();
|
|
174
|
-
return wrapPromise(FrameSDK.setTheme(theme ?? {}));
|
|
175
|
-
}
|
package/src/types.ts
CHANGED
|
@@ -11,18 +11,6 @@ export interface FrameCartItem {
|
|
|
11
11
|
imageUrl: string;
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export type ChargeIntentStatus =
|
|
15
|
-
| 'canceled'
|
|
16
|
-
| 'disputed'
|
|
17
|
-
| 'failed'
|
|
18
|
-
| 'incomplete'
|
|
19
|
-
| 'pending'
|
|
20
|
-
| 'refunded'
|
|
21
|
-
| 'reversed'
|
|
22
|
-
| 'succeeded';
|
|
23
|
-
|
|
24
|
-
export type AuthorizationMode = 'automatic' | 'manual';
|
|
25
|
-
|
|
26
14
|
export interface BillingAddress {
|
|
27
15
|
city?: string;
|
|
28
16
|
country?: string;
|
|
@@ -62,46 +50,6 @@ export interface PaymentMethod {
|
|
|
62
50
|
billing?: BillingAddress;
|
|
63
51
|
}
|
|
64
52
|
|
|
65
|
-
export interface Customer {
|
|
66
|
-
id: string;
|
|
67
|
-
object: string;
|
|
68
|
-
created: number;
|
|
69
|
-
updated: number;
|
|
70
|
-
livemode: boolean;
|
|
71
|
-
name?: string;
|
|
72
|
-
email?: string;
|
|
73
|
-
phone?: string;
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export interface Charge {
|
|
77
|
-
id: string;
|
|
78
|
-
object: string;
|
|
79
|
-
amount: number;
|
|
80
|
-
currency: string;
|
|
81
|
-
status: string;
|
|
82
|
-
created: number;
|
|
83
|
-
livemode: boolean;
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/** Charge intent returned from presentCheckout / presentCart */
|
|
87
|
-
export interface ChargeIntent {
|
|
88
|
-
id: string;
|
|
89
|
-
currency: string;
|
|
90
|
-
amount: number;
|
|
91
|
-
status: ChargeIntentStatus;
|
|
92
|
-
created: number;
|
|
93
|
-
updated: number;
|
|
94
|
-
livemode: boolean;
|
|
95
|
-
object: string;
|
|
96
|
-
description?: string;
|
|
97
|
-
authorizationMode?: AuthorizationMode;
|
|
98
|
-
failureDescription?: string;
|
|
99
|
-
customer?: Customer;
|
|
100
|
-
paymentMethod?: PaymentMethod;
|
|
101
|
-
latestCharge?: Charge;
|
|
102
|
-
shipping?: BillingAddress;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
53
|
/** Error shape when native module rejects (same as FrameErrorShape from errors.ts) */
|
|
106
54
|
export interface FrameError {
|
|
107
55
|
code: string;
|
|
@@ -134,19 +82,32 @@ export interface OnboardingResult {
|
|
|
134
82
|
paymentMethodId?: string;
|
|
135
83
|
}
|
|
136
84
|
|
|
137
|
-
/**
|
|
138
|
-
|
|
85
|
+
/**
|
|
86
|
+
* Identifies who the wallet payment method belongs to and which downstream
|
|
87
|
+
* resource is created when the user authorizes payment. Used by both
|
|
88
|
+
* `presentApplePay` and `presentGooglePay`.
|
|
89
|
+
*
|
|
90
|
+
* - `{ type: 'customer', id }` → creates a `ChargeIntent`; promise resolves with the ChargeIntent id.
|
|
91
|
+
* - `{ type: 'account', id }` → creates a `Transfer`; promise resolves with the Transfer id.
|
|
92
|
+
*
|
|
93
|
+
* The promise always resolves with a string id; the caller knows which resource
|
|
94
|
+
* it refers to based on the owner type they passed in.
|
|
95
|
+
*/
|
|
96
|
+
export type WalletOwner =
|
|
139
97
|
| { type: 'customer'; id: string }
|
|
140
98
|
| { type: 'account'; id: string };
|
|
141
99
|
|
|
100
|
+
/** @deprecated Use {@link WalletOwner}. Retained as an alias for source compatibility. */
|
|
101
|
+
export type ApplePayOwner = WalletOwner;
|
|
102
|
+
|
|
142
103
|
/** Options for Frame.presentApplePay. */
|
|
143
104
|
export interface PresentApplePayOptions {
|
|
144
105
|
/** Payment amount in cents. */
|
|
145
106
|
amount: number;
|
|
146
107
|
/** ISO 4217 currency code. Defaults to 'usd'. */
|
|
147
108
|
currency?: string;
|
|
148
|
-
/** Customer or account that owns the resulting payment method. */
|
|
149
|
-
owner:
|
|
109
|
+
/** Customer or account that owns the resulting payment method and charge. */
|
|
110
|
+
owner: WalletOwner;
|
|
150
111
|
/** Apple Pay merchant ID configured in your Apple Developer account. */
|
|
151
112
|
merchantId: string;
|
|
152
113
|
}
|
|
@@ -155,8 +116,8 @@ export interface PresentApplePayOptions {
|
|
|
155
116
|
export interface PresentGooglePayOptions {
|
|
156
117
|
/** Payment amount in cents. */
|
|
157
118
|
amountCents: number;
|
|
158
|
-
/**
|
|
159
|
-
|
|
119
|
+
/** Customer or account that owns the resulting payment method and charge. */
|
|
120
|
+
owner: WalletOwner;
|
|
160
121
|
/** ISO 4217 currency code. Defaults to 'USD'. */
|
|
161
122
|
currencyCode?: string;
|
|
162
123
|
/** Optional override for the Google Pay merchant ID. */
|