framepayments-react-native 2.1.1 → 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.
Files changed (81) hide show
  1. package/README.md +81 -59
  2. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.dex +0 -0
  3. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.dex +0 -0
  4. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameCheckoutActivity.dex +0 -0
  5. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.dex +0 -0
  6. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.dex +0 -0
  7. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.dex +0 -0
  8. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameFlowActivity.dex +0 -0
  9. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.dex +0 -0
  10. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameGooglePayActivity.dex +0 -0
  11. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.dex +0 -0
  12. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.dex +0 -0
  13. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameOnboardingActivity.dex +0 -0
  14. package/android/build/.transforms/5a2061641b1fc5518a336681809507bc/transformed/bundleLibRuntimeToDirDebug/bundleLibRuntimeToDirDebug_dex/com/framepayments/reactnativeframe/FrameSDKModule.dex +0 -0
  15. package/android/build/intermediates/compile_library_classes_jar/debug/bundleLibCompileToJarDebug/classes.jar +0 -0
  16. package/android/build/intermediates/incremental/debug/packageDebugResources/compile-file-map.properties +1 -1
  17. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.class +0 -0
  18. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.class +0 -0
  19. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameCheckoutActivity.class +0 -0
  20. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.class +0 -0
  21. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.class +0 -0
  22. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.class +0 -0
  23. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameFlowActivity.class +0 -0
  24. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.class +0 -0
  25. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameGooglePayActivity.class +0 -0
  26. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.class +0 -0
  27. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.class +0 -0
  28. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameOnboardingActivity.class +0 -0
  29. package/android/build/intermediates/runtime_library_classes_dir/debug/bundleLibRuntimeToDirDebug/com/framepayments/reactnativeframe/FrameSDKModule.class +0 -0
  30. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab +0 -0
  31. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/constants.tab.values.at +0 -0
  32. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab +0 -0
  33. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/jvm/kotlin/proto.tab.values.at +0 -0
  34. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab +0 -0
  35. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream +0 -0
  36. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.keystream.len +0 -0
  37. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.len +0 -0
  38. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab.values.at +0 -0
  39. package/android/build/kotlin/compileDebugKotlin/cacheable/caches-jvm/lookups/lookups.tab_i +0 -0
  40. package/android/build/kotlin/compileDebugKotlin/cacheable/last-build.bin +0 -0
  41. package/android/build/kotlin/compileDebugKotlin/classpath-snapshot/shrunk-classpath-snapshot.bin +0 -0
  42. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity$Companion.class +0 -0
  43. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity$tryShowCheckout$1.class +0 -0
  44. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameCheckoutActivity.class +0 -0
  45. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$CartItemDto.class +0 -0
  46. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$Companion.class +0 -0
  47. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity$parseCartItems$type$1.class +0 -0
  48. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameFlowActivity.class +0 -0
  49. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameGooglePayActivity$Companion.class +0 -0
  50. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameGooglePayActivity.class +0 -0
  51. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity$Companion.class +0 -0
  52. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity$parseCapabilities$type$1.class +0 -0
  53. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameOnboardingActivity.class +0 -0
  54. package/android/build/tmp/kotlin-classes/debug/com/framepayments/reactnativeframe/FrameSDKModule.class +0 -0
  55. package/android/build.gradle +3 -3
  56. package/android/src/main/java/com/framepayments/reactnativeframe/FrameCheckoutActivity.kt +17 -13
  57. package/android/src/main/java/com/framepayments/reactnativeframe/FrameFlowActivity.kt +18 -11
  58. package/android/src/main/java/com/framepayments/reactnativeframe/FrameGooglePayActivity.kt +31 -8
  59. package/android/src/main/java/com/framepayments/reactnativeframe/FrameSDKModule.kt +28 -35
  60. package/ios/ApplePayPresenter.swift +53 -28
  61. package/ios/FrameSDKBridge.m +7 -7
  62. package/ios/FrameSDKBridge.swift +61 -27
  63. package/lib/errors.d.ts +9 -1
  64. package/lib/errors.d.ts.map +1 -1
  65. package/lib/errors.js +9 -1
  66. package/lib/index.d.ts +1 -1
  67. package/lib/index.d.ts.map +1 -1
  68. package/lib/native.d.ts +37 -7
  69. package/lib/native.d.ts.map +1 -1
  70. package/lib/native.js +61 -9
  71. package/lib/types.d.ts +18 -45
  72. package/lib/types.d.ts.map +1 -1
  73. package/package.json +1 -1
  74. package/src/__tests__/native.test.ts +179 -25
  75. package/src/errors.ts +9 -1
  76. package/src/index.ts +1 -3
  77. package/src/native.ts +69 -17
  78. package/src/types.ts +19 -58
  79. /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
  80. /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
  81. /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/lib/native.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * Native module bridge. Uses NativeModules for classic React Native bridge.
3
3
  */
4
- import type { ChargeIntent, FrameCartItem, FrameTheme, OnboardingCapability, OnboardingResult, PresentApplePayOptions, PresentGooglePayOptions } from './types';
4
+ import type { FrameCartItem, FrameTheme, OnboardingCapability, OnboardingResult, PresentApplePayOptions, PresentGooglePayOptions } from './types';
5
5
  export declare function initialize(options: {
6
6
  secretKey: string;
7
7
  publishableKey: string;
@@ -14,21 +14,51 @@ export declare function initialize(options: {
14
14
  */
15
15
  theme?: FrameTheme;
16
16
  }): Promise<void>;
17
+ /**
18
+ * Presents the Frame checkout sheet for the given account. Resolves with the
19
+ * created Transfer's id string on success, or rejects with `USER_CANCELED` if
20
+ * the user dismisses the sheet.
21
+ *
22
+ * `accountId` is required: the bundled checkout creates a `Transfer`, which is
23
+ * account-scoped. Callers needing a customer/ChargeIntent flow should use
24
+ * `presentApplePay` / `presentGooglePay` directly with a customer owner.
25
+ */
17
26
  export declare function presentCheckout(options: {
18
- customerId?: string | null;
27
+ accountId: string;
19
28
  amount: number;
20
- }): Promise<ChargeIntent>;
29
+ }): Promise<string>;
30
+ /**
31
+ * Presents the Frame cart UI; tapping checkout routes through the same flow
32
+ * as `presentCheckout` and resolves with the created Transfer's id string.
33
+ *
34
+ * `accountId` is required for the same reason as `presentCheckout`.
35
+ */
21
36
  export declare function presentCart(options: {
22
- customerId?: string | null;
37
+ accountId: string;
23
38
  items: FrameCartItem[];
24
39
  shippingAmountInCents: number;
25
- }): Promise<ChargeIntent>;
40
+ }): Promise<string>;
26
41
  export declare function presentOnboarding(options: {
27
42
  accountId?: string | null;
28
43
  capabilities?: OnboardingCapability[];
29
44
  applePayMerchantId?: string | null;
30
45
  googlePayMerchantId?: string | null;
31
46
  }): Promise<OnboardingResult>;
32
- export declare function presentApplePay(options: PresentApplePayOptions): Promise<ChargeIntent>;
33
- export declare function presentGooglePay(options: PresentGooglePayOptions): Promise<ChargeIntent>;
47
+ /**
48
+ * Presents the Apple Pay sheet and creates a charge from the resulting wallet
49
+ * payment method. Resolves with the created resource's id string on success,
50
+ * or rejects with `USER_CANCELED` if the sheet is dismissed.
51
+ *
52
+ * - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
53
+ * - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
54
+ */
55
+ export declare function presentApplePay(options: PresentApplePayOptions): Promise<string>;
56
+ /**
57
+ * Presents Google Pay and creates a charge from the resulting wallet payment method.
58
+ * Resolves with the created resource's id string on success.
59
+ *
60
+ * - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
61
+ * - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
62
+ */
63
+ export declare function presentGooglePay(options: PresentGooglePayOptions): Promise<string>;
34
64
  //# sourceMappingURL=native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"native.d.ts","sourceRoot":"","sources":["../src/native.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,aAAa,EACb,UAAU,EACV,oBAAoB,EACpB,gBA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
  import { ErrorCodes } from './errors';
6
+ /**
7
+ * Throw a coded error from synchronous JS validation. Mirrors the `code`/`message`
8
+ * shape that native rejections produce so consumers can catch `e.code === 'INVALID_*'`
9
+ * uniformly.
10
+ */
11
+ function throwCoded(code, message) {
12
+ const err = new Error(message);
13
+ err.code = code;
14
+ throw err;
15
+ }
6
16
  // theme is iOS-only today: frame-android does not yet have a matching theme API,
7
17
  // so the field is accepted on both platforms but ignored on Android until it does.
8
18
  const LINKING_ERROR = `The package 'framepayments-react-native' doesn't seem to be linked. Make sure you have run 'pod install' (iOS) or rebuilt the app (Android).`;
@@ -16,13 +26,13 @@ const FrameSDK = NativeModules.FrameSDK
16
26
  let isInitialized = false;
17
27
  export function initialize(options) {
18
28
  if (!options?.secretKey) {
19
- throw new Error('Frame.initialize requires secretKey');
29
+ throwCoded(ErrorCodes.INIT_FAILED, 'Frame.initialize requires secretKey');
20
30
  }
21
31
  if (!options?.publishableKey) {
22
- throw new Error('Frame.initialize requires publishableKey');
32
+ throwCoded(ErrorCodes.INIT_FAILED, 'Frame.initialize requires publishableKey');
23
33
  }
24
34
  if (options.theme !== undefined && (typeof options.theme !== 'object' || Array.isArray(options.theme))) {
25
- throw new Error('Frame.initialize: theme must be an object');
35
+ throwCoded(ErrorCodes.INIT_FAILED, 'Frame.initialize: theme must be an object');
26
36
  }
27
37
  return wrapPromise(FrameSDK.initialize(options.secretKey, options.publishableKey, options.debugMode ?? false, options.theme ?? null)).then(() => {
28
38
  isInitialized = true;
@@ -48,13 +58,34 @@ function wrapPromise(p) {
48
58
  throw Object.assign(new Error(message), { code, message });
49
59
  });
50
60
  }
61
+ /**
62
+ * Presents the Frame checkout sheet for the given account. Resolves with the
63
+ * created Transfer's id string on success, or rejects with `USER_CANCELED` if
64
+ * the user dismisses the sheet.
65
+ *
66
+ * `accountId` is required: the bundled checkout creates a `Transfer`, which is
67
+ * account-scoped. Callers needing a customer/ChargeIntent flow should use
68
+ * `presentApplePay` / `presentGooglePay` directly with a customer owner.
69
+ */
51
70
  export function presentCheckout(options) {
52
71
  guardInitialized();
53
- return wrapPromise(FrameSDK.presentCheckout(options.customerId ?? null, options.amount));
72
+ if (!options?.accountId) {
73
+ throwCoded(ErrorCodes.INVALID_ACCOUNT, 'Frame.presentCheckout requires accountId');
74
+ }
75
+ return wrapPromise(FrameSDK.presentCheckout(options.accountId, options.amount));
54
76
  }
77
+ /**
78
+ * Presents the Frame cart UI; tapping checkout routes through the same flow
79
+ * as `presentCheckout` and resolves with the created Transfer's id string.
80
+ *
81
+ * `accountId` is required for the same reason as `presentCheckout`.
82
+ */
55
83
  export function presentCart(options) {
56
84
  guardInitialized();
57
- return wrapPromise(FrameSDK.presentCart(options.customerId ?? null, options.items, options.shippingAmountInCents));
85
+ if (!options?.accountId) {
86
+ throwCoded(ErrorCodes.INVALID_ACCOUNT, 'Frame.presentCart requires accountId');
87
+ }
88
+ return wrapPromise(FrameSDK.presentCart(options.accountId, options.items, options.shippingAmountInCents));
58
89
  }
59
90
  export function presentOnboarding(options) {
60
91
  guardInitialized();
@@ -63,20 +94,41 @@ export function presentOnboarding(options) {
63
94
  }
64
95
  return wrapPromise(FrameSDK.presentOnboarding(options.accountId ?? null, options.capabilities ?? [], options.googlePayMerchantId ?? null));
65
96
  }
97
+ /**
98
+ * Presents the Apple Pay sheet and creates a charge from the resulting wallet
99
+ * payment method. Resolves with the created resource's id string on success,
100
+ * or rejects with `USER_CANCELED` if the sheet is dismissed.
101
+ *
102
+ * - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
103
+ * - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
104
+ */
66
105
  export function presentApplePay(options) {
67
106
  guardInitialized();
68
107
  if (!options?.owner || (options.owner.type !== 'customer' && options.owner.type !== 'account')) {
69
- throw new Error('Frame.presentApplePay requires owner: { type: "customer" | "account", id: string }');
108
+ throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentApplePay requires owner: { type: "customer" | "account", id: string }');
70
109
  }
71
110
  if (!options.owner.id) {
72
- throw new Error('Frame.presentApplePay requires owner.id');
111
+ throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentApplePay requires owner.id');
73
112
  }
74
113
  if (!options.merchantId) {
75
- throw new Error('Frame.presentApplePay requires merchantId');
114
+ throwCoded(ErrorCodes.INVALID_MERCHANT_ID, 'Frame.presentApplePay requires merchantId');
76
115
  }
77
116
  return wrapPromise(FrameSDK.presentApplePay(options.owner.type, options.owner.id, options.amount, options.currency ?? 'usd', options.merchantId));
78
117
  }
118
+ /**
119
+ * Presents Google Pay and creates a charge from the resulting wallet payment method.
120
+ * Resolves with the created resource's id string on success.
121
+ *
122
+ * - `owner.type === 'customer'` → creates a `ChargeIntent`; resolves with its id.
123
+ * - `owner.type === 'account'` → creates a `Transfer`; resolves with its id.
124
+ */
79
125
  export function presentGooglePay(options) {
80
126
  guardInitialized();
81
- return wrapPromise(FrameSDK.presentGooglePay(options.amountCents, options.customerId ?? null, options.currencyCode ?? 'USD', options.googlePayMerchantId ?? null));
127
+ if (!options?.owner || (options.owner.type !== 'customer' && options.owner.type !== 'account')) {
128
+ throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentGooglePay requires owner: { type: "customer" | "account", id: string }');
129
+ }
130
+ if (!options.owner.id) {
131
+ throwCoded(ErrorCodes.INVALID_OWNER, 'Frame.presentGooglePay requires owner.id');
132
+ }
133
+ return wrapPromise(FrameSDK.presentGooglePay(options.amountCents, options.owner.type, options.owner.id, options.currencyCode ?? 'USD', options.googlePayMerchantId ?? null));
82
134
  }
package/lib/types.d.ts CHANGED
@@ -9,8 +9,6 @@ export interface FrameCartItem {
9
9
  amountInCents: number;
10
10
  imageUrl: string;
11
11
  }
12
- export type ChargeIntentStatus = 'canceled' | 'disputed' | 'failed' | 'incomplete' | 'pending' | 'refunded' | 'reversed' | 'succeeded';
13
- export type AuthorizationMode = 'automatic' | 'manual';
14
12
  export interface BillingAddress {
15
13
  city?: string;
16
14
  country?: string;
@@ -46,43 +44,6 @@ export interface PaymentMethod {
46
44
  ach?: BankAccount;
47
45
  billing?: BillingAddress;
48
46
  }
49
- export interface Customer {
50
- id: string;
51
- object: string;
52
- created: number;
53
- updated: number;
54
- livemode: boolean;
55
- name?: string;
56
- email?: string;
57
- phone?: string;
58
- }
59
- export interface Charge {
60
- id: string;
61
- object: string;
62
- amount: number;
63
- currency: string;
64
- status: string;
65
- created: number;
66
- livemode: boolean;
67
- }
68
- /** Charge intent returned from presentCheckout / presentCart */
69
- export interface ChargeIntent {
70
- id: string;
71
- currency: string;
72
- amount: number;
73
- status: ChargeIntentStatus;
74
- created: number;
75
- updated: number;
76
- livemode: boolean;
77
- object: string;
78
- description?: string;
79
- authorizationMode?: AuthorizationMode;
80
- failureDescription?: string;
81
- customer?: Customer;
82
- paymentMethod?: PaymentMethod;
83
- latestCharge?: Charge;
84
- shipping?: BillingAddress;
85
- }
86
47
  /** Error shape when native module rejects (same as FrameErrorShape from errors.ts) */
87
48
  export interface FrameError {
88
49
  code: string;
@@ -98,22 +59,34 @@ export interface OnboardingResult {
98
59
  /** Present when status === 'completed' and a payment method was created/verified */
99
60
  paymentMethodId?: string;
100
61
  }
101
- /** Identifies who the Apple Pay payment method belongs to. */
102
- export type ApplePayOwner = {
62
+ /**
63
+ * Identifies who the wallet payment method belongs to and which downstream
64
+ * resource is created when the user authorizes payment. Used by both
65
+ * `presentApplePay` and `presentGooglePay`.
66
+ *
67
+ * - `{ type: 'customer', id }` → creates a `ChargeIntent`; promise resolves with the ChargeIntent id.
68
+ * - `{ type: 'account', id }` → creates a `Transfer`; promise resolves with the Transfer id.
69
+ *
70
+ * The promise always resolves with a string id; the caller knows which resource
71
+ * it refers to based on the owner type they passed in.
72
+ */
73
+ export type WalletOwner = {
103
74
  type: 'customer';
104
75
  id: string;
105
76
  } | {
106
77
  type: 'account';
107
78
  id: string;
108
79
  };
80
+ /** @deprecated Use {@link WalletOwner}. Retained as an alias for source compatibility. */
81
+ export type ApplePayOwner = WalletOwner;
109
82
  /** Options for Frame.presentApplePay. */
110
83
  export interface PresentApplePayOptions {
111
84
  /** Payment amount in cents. */
112
85
  amount: number;
113
86
  /** ISO 4217 currency code. Defaults to 'usd'. */
114
87
  currency?: string;
115
- /** Customer or account that owns the resulting payment method. */
116
- owner: ApplePayOwner;
88
+ /** Customer or account that owns the resulting payment method and charge. */
89
+ owner: WalletOwner;
117
90
  /** Apple Pay merchant ID configured in your Apple Developer account. */
118
91
  merchantId: string;
119
92
  }
@@ -121,8 +94,8 @@ export interface PresentApplePayOptions {
121
94
  export interface PresentGooglePayOptions {
122
95
  /** Payment amount in cents. */
123
96
  amountCents: number;
124
- /** Optional Frame customer ID to associate the resulting payment method with. */
125
- customerId?: string | null;
97
+ /** Customer or account that owns the resulting payment method and charge. */
98
+ owner: WalletOwner;
126
99
  /** ISO 4217 currency code. Defaults to 'USD'. */
127
100
  currencyCode?: string;
128
101
  /** Optional override for the Google Pay merchant ID. */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,2CAA2C;AAC3C,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;IACtB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,MAAM,kBAAkB,GAC1B,UAAU,GACV,UAAU,GACV,QAAQ,GACR,YAAY,GACZ,SAAS,GACT,UAAU,GACV,UAAU,GACV,WAAW,CAAC;AAEhB,MAAM,MAAM,iBAAiB,GAAG,WAAW,GAAG,QAAQ,CAAC;AAEvD,MAAM,WAAW,cAAc;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,YA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;IAClC,mBAAmB,CAAC,EAAE,eAAe,CAAC;IACtC,cAAc,CAAC,EAAE,eAAe,CAAC;IACjC,oBAAoB,CAAC,EAAE,eAAe,CAAC;IACvC,kBAAkB,CAAC,EAAE,eAAe,CAAC;IACrC,OAAO,CAAC,EAAE,eAAe,CAAC;IAC1B,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,WAAW,CAAC,EAAE,eAAe,CAAC;IAC9B,aAAa,CAAC,EAAE,eAAe,CAAC;IAChC,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,0BAA0B,CAAC,EAAE,eAAe,CAAC;IAC7C,+BAA+B,CAAC,EAAE,eAAe,CAAC;IAClD,8BAA8B,CAAC,EAAE,eAAe,CAAC;CAClD;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,IAAI,CAAC,EAAE,cAAc,CAAC;IACtB,SAAS,CAAC,EAAE,cAAc,CAAC;IAC3B,KAAK,CAAC,EAAE,cAAc,CAAC;IACvB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,MAAM,CAAC,EAAE,cAAc,CAAC;CACzB;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,EAAE,gBAAgB,CAAC;IAC1B,KAAK,CAAC,EAAE,eAAe,CAAC;IACxB,KAAK,CAAC,EAAE,eAAe,CAAC;CACzB"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "framepayments-react-native",
3
- "version": "2.1.1",
3
+ "version": "2.1.2",
4
4
  "description": "React Native SDK for Frame Payments - modal checkout and cart, with API usage via frame-node.",
5
5
  "main": "lib/index.js",
6
6
  "types": "lib/index.d.ts",
@@ -1,11 +1,13 @@
1
1
  /**
2
- * Unit tests for the native module bridge (initialize, presentCheckout, presentCart).
3
- * NativeModules.FrameSDK is mocked.
2
+ * Unit tests for the native module bridge (initialize, presentCheckout, presentCart,
3
+ * presentApplePay, presentGooglePay, presentOnboarding). NativeModules.FrameSDK is mocked.
4
4
  */
5
5
 
6
6
  const mockInitialize = jest.fn((_secretKey: string, _publishableKey: string, _debugMode: boolean) => Promise.resolve());
7
- const mockPresentCheckout = jest.fn((_customerId: unknown, _amount: number) => Promise.resolve({ id: 'ci_1', amount: 10000 }));
8
- const mockPresentCart = jest.fn((_customerId: unknown, _items: unknown[], _shipping: number) => Promise.resolve({ id: 'ci_2', amount: 15000 }));
7
+ const mockPresentCheckout = jest.fn((_accountId: unknown, _amount: number) => Promise.resolve('tr_1'));
8
+ const mockPresentCart = jest.fn((_accountId: unknown, _items: unknown[], _shipping: number) => Promise.resolve('tr_2'));
9
+ const mockPresentApplePay = jest.fn((_ownerType: string, _ownerId: string, _amount: number, _currency: string, _merchantId: string) => Promise.resolve('tr_3'));
10
+ const mockPresentGooglePay = jest.fn((_amountCents: number, _ownerType: string, _ownerId: string, _currencyCode: string, _googlePayMerchantId: string | null) => Promise.resolve('tr_4'));
9
11
  const mockPresentOnboarding = jest.fn((_accountId: unknown, _capabilities: unknown[], _merchantId: string | null) => Promise.resolve({ status: 'completed', paymentMethodId: 'pm_1' }));
10
12
 
11
13
  const mockPlatform = { OS: 'ios' as 'ios' | 'android' };
@@ -16,6 +18,8 @@ jest.mock('react-native', () => ({
16
18
  initialize: mockInitialize,
17
19
  presentCheckout: mockPresentCheckout,
18
20
  presentCart: mockPresentCart,
21
+ presentApplePay: mockPresentApplePay,
22
+ presentGooglePay: mockPresentGooglePay,
19
23
  presentOnboarding: mockPresentOnboarding,
20
24
  },
21
25
  },
@@ -24,12 +28,14 @@ jest.mock('react-native', () => ({
24
28
 
25
29
  // Re-import after mock so we get the mocked NativeModules
26
30
  let initialize: (opts: { secretKey: string; publishableKey: string; debugMode?: boolean }) => Promise<void>;
27
- let presentCheckout: (opts: { customerId?: string | null; amount: number }) => Promise<unknown>;
31
+ let presentCheckout: (opts: { accountId: string; amount: number }) => Promise<string>;
28
32
  let presentCart: (opts: {
29
- customerId?: string | null;
33
+ accountId: string;
30
34
  items: Array<{ id: string; title: string; amountInCents: number; imageUrl: string }>;
31
35
  shippingAmountInCents: number;
32
- }) => Promise<unknown>;
36
+ }) => Promise<string>;
37
+ let presentApplePay: (opts: { amount: number; currency?: string; owner: { type: 'customer' | 'account'; id: string }; merchantId: string }) => Promise<string>;
38
+ let presentGooglePay: (opts: { amountCents: number; owner: { type: 'customer' | 'account'; id: string }; currencyCode?: string; googlePayMerchantId?: string }) => Promise<string>;
33
39
  let presentOnboarding: (opts: { accountId?: string | null; capabilities?: string[]; applePayMerchantId?: string | null; googlePayMerchantId?: string | null }) => Promise<unknown>;
34
40
 
35
41
  beforeEach(() => {
@@ -37,12 +43,16 @@ beforeEach(() => {
37
43
  mockInitialize.mockClear();
38
44
  mockPresentCheckout.mockClear();
39
45
  mockPresentCart.mockClear();
46
+ mockPresentApplePay.mockClear();
47
+ mockPresentGooglePay.mockClear();
40
48
  mockPresentOnboarding.mockClear();
41
49
  mockPlatform.OS = 'ios';
42
50
  const native = require('../native');
43
51
  initialize = native.initialize;
44
52
  presentCheckout = native.presentCheckout;
45
53
  presentCart = native.presentCart;
54
+ presentApplePay = native.presentApplePay;
55
+ presentGooglePay = native.presentGooglePay;
46
56
  presentOnboarding = native.presentOnboarding;
47
57
  });
48
58
 
@@ -50,12 +60,12 @@ describe('initialize', () => {
50
60
  it('calls native FrameSDK.initialize with secretKey, publishableKey, and debugMode', () => {
51
61
  initialize({ secretKey: 'sk_test_xxx', publishableKey: 'pk_test_xxx', debugMode: true });
52
62
  expect(mockInitialize).toHaveBeenCalledTimes(1);
53
- expect(mockInitialize).toHaveBeenCalledWith('sk_test_xxx', 'pk_test_xxx', true);
63
+ expect(mockInitialize).toHaveBeenCalledWith('sk_test_xxx', 'pk_test_xxx', true, null);
54
64
  });
55
65
 
56
66
  it('defaults debugMode to false', () => {
57
67
  initialize({ secretKey: 'sk_test_yyy', publishableKey: 'pk_test_yyy' });
58
- expect(mockInitialize).toHaveBeenCalledWith('sk_test_yyy', 'pk_test_yyy', false);
68
+ expect(mockInitialize).toHaveBeenCalledWith('sk_test_yyy', 'pk_test_yyy', false, null);
59
69
  });
60
70
 
61
71
  it('throws if secretKey is missing', () => {
@@ -74,7 +84,7 @@ describe('initialize', () => {
74
84
  describe('presentCheckout', () => {
75
85
  it('throws NOT_INITIALIZED if initialize was not called', async () => {
76
86
  try {
77
- await presentCheckout({ amount: 10000 });
87
+ await presentCheckout({ accountId: 'acct_1', amount: 10000 });
78
88
  expect(true).toBe(false);
79
89
  } catch (e: any) {
80
90
  expect(e.code).toBe('NOT_INITIALIZED');
@@ -83,17 +93,22 @@ describe('presentCheckout', () => {
83
93
  expect(mockPresentCheckout).not.toHaveBeenCalled();
84
94
  });
85
95
 
86
- it('calls native presentCheckout with customerId and amount after initialize', async () => {
96
+ it('throws INVALID_ACCOUNT when accountId is missing', async () => {
87
97
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
88
- const result = await presentCheckout({ customerId: 'cus_1', amount: 10000 });
89
- expect(mockPresentCheckout).toHaveBeenCalledWith('cus_1', 10000);
90
- expect(result).toEqual({ id: 'ci_1', amount: 10000 });
98
+ try {
99
+ await presentCheckout({ amount: 5000 } as any);
100
+ expect(true).toBe(false);
101
+ } catch (e: any) {
102
+ expect(e.code).toBe('INVALID_ACCOUNT');
103
+ }
104
+ expect(mockPresentCheckout).not.toHaveBeenCalled();
91
105
  });
92
106
 
93
- it('passes null for customerId when not provided', async () => {
107
+ it('calls native presentCheckout with accountId and amount; resolves with transfer id string', async () => {
94
108
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
95
- await presentCheckout({ amount: 5000 });
96
- expect(mockPresentCheckout).toHaveBeenCalledWith(null, 5000);
109
+ const result = await presentCheckout({ accountId: 'acct_1', amount: 10000 });
110
+ expect(mockPresentCheckout).toHaveBeenCalledWith('acct_1', 10000);
111
+ expect(result).toBe('tr_1');
97
112
  });
98
113
  });
99
114
 
@@ -104,7 +119,7 @@ describe('presentCart', () => {
104
119
 
105
120
  it('throws NOT_INITIALIZED if initialize was not called', async () => {
106
121
  try {
107
- await presentCart({ items, shippingAmountInCents: 500 });
122
+ await presentCart({ accountId: 'acct_1', items, shippingAmountInCents: 500 });
108
123
  expect(true).toBe(false);
109
124
  } catch (e: any) {
110
125
  expect(e.code).toBe('NOT_INITIALIZED');
@@ -112,21 +127,160 @@ describe('presentCart', () => {
112
127
  expect(mockPresentCart).not.toHaveBeenCalled();
113
128
  });
114
129
 
115
- it('calls native presentCart with customerId, items, shipping after initialize', async () => {
130
+ it('throws INVALID_ACCOUNT when accountId is missing', async () => {
131
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
132
+ try {
133
+ await presentCart({ items, shippingAmountInCents: 0 } as any);
134
+ expect(true).toBe(false);
135
+ } catch (e: any) {
136
+ expect(e.code).toBe('INVALID_ACCOUNT');
137
+ }
138
+ expect(mockPresentCart).not.toHaveBeenCalled();
139
+ });
140
+
141
+ it('calls native presentCart with accountId, items, shipping; resolves with transfer id string', async () => {
116
142
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
117
143
  const result = await presentCart({
118
- customerId: 'cus_2',
144
+ accountId: 'acct_2',
119
145
  items,
120
146
  shippingAmountInCents: 500,
121
147
  });
122
- expect(mockPresentCart).toHaveBeenCalledWith('cus_2', items, 500);
123
- expect(result).toEqual({ id: 'ci_2', amount: 15000 });
148
+ expect(mockPresentCart).toHaveBeenCalledWith('acct_2', items, 500);
149
+ expect(result).toBe('tr_2');
150
+ });
151
+ });
152
+
153
+ describe('presentApplePay', () => {
154
+ it('throws NOT_INITIALIZED if initialize was not called', async () => {
155
+ try {
156
+ await presentApplePay({ amount: 100, owner: { type: 'account', id: 'acct_1' }, merchantId: 'merchant.test' });
157
+ expect(true).toBe(false);
158
+ } catch (e: any) {
159
+ expect(e.code).toBe('NOT_INITIALIZED');
160
+ }
161
+ expect(mockPresentApplePay).not.toHaveBeenCalled();
162
+ });
163
+
164
+ it('throws INVALID_OWNER when owner is missing', async () => {
165
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
166
+ try {
167
+ await presentApplePay({ amount: 100, merchantId: 'merchant.test' } as any);
168
+ expect(true).toBe(false);
169
+ } catch (e: any) {
170
+ expect(e.code).toBe('INVALID_OWNER');
171
+ }
172
+ expect(mockPresentApplePay).not.toHaveBeenCalled();
173
+ });
174
+
175
+ it('throws INVALID_OWNER when owner.id is empty', async () => {
176
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
177
+ try {
178
+ await presentApplePay({ amount: 100, owner: { type: 'account', id: '' }, merchantId: 'merchant.test' });
179
+ expect(true).toBe(false);
180
+ } catch (e: any) {
181
+ expect(e.code).toBe('INVALID_OWNER');
182
+ }
183
+ expect(mockPresentApplePay).not.toHaveBeenCalled();
184
+ });
185
+
186
+ it('throws INVALID_MERCHANT_ID when merchantId is missing', async () => {
187
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
188
+ try {
189
+ await presentApplePay({ amount: 100, owner: { type: 'account', id: 'acct_1' } } as any);
190
+ expect(true).toBe(false);
191
+ } catch (e: any) {
192
+ expect(e.code).toBe('INVALID_MERCHANT_ID');
193
+ }
194
+ expect(mockPresentApplePay).not.toHaveBeenCalled();
195
+ });
196
+
197
+ it('forwards account owner; resolves with transfer id string', async () => {
198
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
199
+ const result = await presentApplePay({
200
+ amount: 12345,
201
+ currency: 'usd',
202
+ owner: { type: 'account', id: 'acct_1' },
203
+ merchantId: 'merchant.test',
204
+ });
205
+ expect(mockPresentApplePay).toHaveBeenCalledWith('account', 'acct_1', 12345, 'usd', 'merchant.test');
206
+ expect(result).toBe('tr_3');
207
+ });
208
+
209
+ it('forwards customer owner; resolves with charge intent id string', async () => {
210
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
211
+ await presentApplePay({
212
+ amount: 9999,
213
+ owner: { type: 'customer', id: 'cus_1' },
214
+ merchantId: 'merchant.test',
215
+ });
216
+ expect(mockPresentApplePay).toHaveBeenCalledWith('customer', 'cus_1', 9999, 'usd', 'merchant.test');
217
+ });
218
+
219
+ it('defaults currency to usd', async () => {
220
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
221
+ await presentApplePay({ amount: 100, owner: { type: 'account', id: 'acct_1' }, merchantId: 'merchant.test' });
222
+ expect(mockPresentApplePay).toHaveBeenCalledWith('account', 'acct_1', 100, 'usd', 'merchant.test');
223
+ });
224
+ });
225
+
226
+ describe('presentGooglePay', () => {
227
+ it('throws NOT_INITIALIZED if initialize was not called', async () => {
228
+ try {
229
+ await presentGooglePay({ amountCents: 100, owner: { type: 'account', id: 'acct_1' } });
230
+ expect(true).toBe(false);
231
+ } catch (e: any) {
232
+ expect(e.code).toBe('NOT_INITIALIZED');
233
+ }
234
+ expect(mockPresentGooglePay).not.toHaveBeenCalled();
235
+ });
236
+
237
+ it('throws INVALID_OWNER when owner is missing', async () => {
238
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
239
+ try {
240
+ await presentGooglePay({ amountCents: 100 } as any);
241
+ expect(true).toBe(false);
242
+ } catch (e: any) {
243
+ expect(e.code).toBe('INVALID_OWNER');
244
+ }
245
+ expect(mockPresentGooglePay).not.toHaveBeenCalled();
246
+ });
247
+
248
+ it('throws INVALID_OWNER when owner.id is empty', async () => {
249
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
250
+ try {
251
+ await presentGooglePay({ amountCents: 100, owner: { type: 'account', id: '' } });
252
+ expect(true).toBe(false);
253
+ } catch (e: any) {
254
+ expect(e.code).toBe('INVALID_OWNER');
255
+ }
256
+ expect(mockPresentGooglePay).not.toHaveBeenCalled();
257
+ });
258
+
259
+ it('forwards account owner; resolves with transfer id string', async () => {
260
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
261
+ const result = await presentGooglePay({
262
+ amountCents: 9999,
263
+ owner: { type: 'account', id: 'acct_1' },
264
+ currencyCode: 'EUR',
265
+ googlePayMerchantId: 'BCR2DN4T...',
266
+ });
267
+ expect(mockPresentGooglePay).toHaveBeenCalledWith(9999, 'account', 'acct_1', 'EUR', 'BCR2DN4T...');
268
+ expect(result).toBe('tr_4');
269
+ });
270
+
271
+ it('forwards customer owner; resolves with charge intent id string', async () => {
272
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
273
+ await presentGooglePay({
274
+ amountCents: 4242,
275
+ owner: { type: 'customer', id: 'cus_1' },
276
+ });
277
+ expect(mockPresentGooglePay).toHaveBeenCalledWith(4242, 'customer', 'cus_1', 'USD', null);
124
278
  });
125
279
 
126
- it('passes null for customerId when not provided', async () => {
280
+ it('defaults currencyCode to USD and merchantId to null', async () => {
127
281
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
128
- await presentCart({ items, shippingAmountInCents: 0 });
129
- expect(mockPresentCart).toHaveBeenCalledWith(null, items, 0);
282
+ await presentGooglePay({ amountCents: 100, owner: { type: 'account', id: 'acct_1' } });
283
+ expect(mockPresentGooglePay).toHaveBeenCalledWith(100, 'account', 'acct_1', 'USD', null);
130
284
  });
131
285
  });
132
286
 
package/src/errors.ts CHANGED
@@ -8,12 +8,20 @@ export const ErrorCodes = {
8
8
  NO_ROOT_VC: 'NO_ROOT_VC',
9
9
  NO_ACTIVITY: 'NO_ACTIVITY',
10
10
  INVALID_ITEMS: 'INVALID_ITEMS',
11
+ INVALID_ACCOUNT: 'INVALID_ACCOUNT',
12
+ INVALID_OWNER: 'INVALID_OWNER',
13
+ INVALID_MERCHANT_ID: 'INVALID_MERCHANT_ID',
14
+ INVALID_AMOUNT: 'INVALID_AMOUNT',
11
15
  NETWORK_ERROR: 'NETWORK_ERROR',
12
16
  API_ERROR: 'API_ERROR',
13
17
  PARSE_ERROR: 'PARSE_ERROR',
14
18
  NO_RESULT: 'NO_RESULT',
15
19
  INIT_FAILED: 'INIT_FAILED',
16
- ENCODE_ERROR: 'ENCODE_ERROR',
20
+ APPLE_PAY_UNAVAILABLE: 'APPLE_PAY_UNAVAILABLE',
21
+ GOOGLE_PAY_UNAVAILABLE: 'GOOGLE_PAY_UNAVAILABLE',
22
+ NOT_ATTESTED: 'NOT_ATTESTED',
23
+ PAYMENT_METHOD_FAILED: 'PAYMENT_METHOD_FAILED',
24
+ PAYMENT_FAILED: 'PAYMENT_FAILED',
17
25
  } as const;
18
26
 
19
27
  export type FrameErrorCode = (typeof ErrorCodes)[keyof typeof ErrorCodes];
package/src/index.ts CHANGED
@@ -27,9 +27,6 @@ export {
27
27
  } from './native';
28
28
  export type {
29
29
  FrameCartItem,
30
- ChargeIntent,
31
- ChargeIntentStatus,
32
- AuthorizationMode,
33
30
  FrameError,
34
31
  BillingAddress,
35
32
  PaymentCard,
@@ -38,6 +35,7 @@ export type {
38
35
  OnboardingCapability,
39
36
  OnboardingResult,
40
37
  OnboardingResultStatus,
38
+ WalletOwner,
41
39
  ApplePayOwner,
42
40
  PresentApplePayOptions,
43
41
  PresentGooglePayOptions,