framepayments-react-native 2.0.8 → 2.1.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.
@@ -47,11 +47,6 @@ RCT_EXTERN_METHOD(presentCart:(id)customerId
47
47
  rejecter:(RCTPromiseRejectBlock)reject)
48
48
 
49
49
  RCT_EXTERN_METHOD(presentOnboarding:(id)accountId
50
- capabilities:(NSArray *)capabilities
51
- resolver:(RCTPromiseResolveBlock)resolve
52
- rejecter:(RCTPromiseRejectBlock)reject)
53
-
54
- RCT_EXTERN_METHOD(presentOnboardingWithApplePay:(id)accountId
55
50
  capabilities:(NSArray *)capabilities
56
51
  applePayMerchantId:(id)applePayMerchantId
57
52
  resolver:(RCTPromiseResolveBlock)resolve
@@ -107,25 +102,14 @@ RCT_EXTERN_METHOD(presentApplePay:(NSString *)ownerType
107
102
  });
108
103
  }
109
104
 
110
- - (void)presentOnboarding:(id)accountId capabilities:(NSArray *)capabilities resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
111
- dispatch_async(dispatch_get_main_queue(), ^{
112
- UIViewController *topVC = FrameGetTopViewController();
113
- if (!topVC) {
114
- reject(@"NO_ROOT_VC", @"Could not find root view controller to present onboarding", nil);
115
- return;
116
- }
117
- [[[ObjCFrameSDKBridge alloc] init] presentOnboardingFrom:topVC accountId:accountId capabilities:capabilities resolver:resolve rejecter:reject];
118
- });
119
- }
120
-
121
- - (void)presentOnboardingWithApplePay:(id)accountId capabilities:(NSArray *)capabilities applePayMerchantId:(id)applePayMerchantId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
105
+ - (void)presentOnboarding:(id)accountId capabilities:(NSArray *)capabilities applePayMerchantId:(id)applePayMerchantId resolver:(RCTPromiseResolveBlock)resolve rejecter:(RCTPromiseRejectBlock)reject {
122
106
  dispatch_async(dispatch_get_main_queue(), ^{
123
107
  UIViewController *topVC = FrameGetTopViewController();
124
108
  if (!topVC) {
125
109
  reject(@"NO_ROOT_VC", @"Could not find root view controller to present onboarding", nil);
126
110
  return;
127
111
  }
128
- [[[ObjCFrameSDKBridge alloc] init] presentOnboardingWithApplePayFrom:topVC accountId:accountId capabilities:capabilities applePayMerchantId:applePayMerchantId resolver:resolve rejecter:reject];
112
+ [[[ObjCFrameSDKBridge alloc] init] presentOnboardingFrom:topVC accountId:accountId capabilities:capabilities applePayMerchantId:applePayMerchantId resolver:resolve rejecter:reject];
129
113
  });
130
114
  }
131
115
 
@@ -51,14 +51,7 @@ public class FrameSDKBridge: NSObject {
51
51
  }
52
52
 
53
53
  @objc public
54
- func presentOnboarding(from viewController: UIViewController, accountId: NSObject?, capabilities: NSArray, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
55
- let parsedCapabilities = parseCapabilities(capabilities)
56
- let accountIdString = accountId as? String
57
- presentOnboardingOnMain(from: viewController, accountId: accountIdString, capabilities: parsedCapabilities, applePayMerchantId: nil, resolve: resolve, reject: reject)
58
- }
59
-
60
- @objc public
61
- func presentOnboardingWithApplePay(from viewController: UIViewController, accountId: NSObject?, capabilities: NSArray, applePayMerchantId: NSObject?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
54
+ func presentOnboarding(from viewController: UIViewController, accountId: NSObject?, capabilities: NSArray, applePayMerchantId: NSObject?, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
62
55
  let parsedCapabilities = parseCapabilities(capabilities)
63
56
  let accountIdString = accountId as? String
64
57
  let merchantIdString = applePayMerchantId as? String
@@ -208,9 +201,9 @@ public class FrameSDKBridge: NSObject {
208
201
  accountId: accountId,
209
202
  requiredCapabilities: capabilities,
210
203
  applePayMerchantId: applePayMerchantId,
211
- onComplete: { [weak hosting] in
204
+ onComplete: { [weak top] in
212
205
  delegate?.finish(completed: true)
213
- hosting?.dismiss(animated: true)
206
+ top?.dismiss(animated: true)
214
207
  }
215
208
  ),
216
209
  theme: FrameRNTheme.resolved()
@@ -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,gBAAgB,EAChB,sBAAsB,EACtB,uBAAuB,EACxB,MAAM,SAAS,CAAC;AAmBjB,wBAAgB,UAAU,CAAC,OAAO,EAAE;IAClC,SAAS,EAAE,MAAM,CAAC;IAClB,cAAc,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,GAAG,OAAO,CAAC,IAAI,CAAC,CAgBhB;AAwBD,wBAAgB,eAAe,CAAC,OAAO,EAAE;IACvC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,MAAM,EAAE,MAAM,CAAC;CAChB,GAAG,OAAO,CAAC,YAAY,CAAC,CAKxB;AAED,wBAAgB,WAAW,CAAC,OAAO,EAAE;IACnC,UAAU,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC3B,KAAK,EAAE,aAAa,EAAE,CAAC;IACvB,qBAAqB,EAAE,MAAM,CAAC;CAC/B,GAAG,OAAO,CAAC,YAAY,CAAC,CASxB;AAED,wBAAgB,iBAAiB,CAAC,OAAO,EAAE;IACzC,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,YAAY,CAAC,EAAE,oBAAoB,EAAE,CAAC;IACtC,kBAAkB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACnC,mBAAmB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACrC,GAAG,OAAO,CAAC,gBAAgB,CAAC,CA0B5B;AAED,wBAAgB,eAAe,CAAC,OAAO,EAAE,sBAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBtF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,u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BAAsB,GAAG,OAAO,CAAC,YAAY,CAAC,CAoBtF;AAED,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,OAAO,CAAC,YAAY,CAAC,CAUxF;AAED;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,GAAG,OAAO,CAAC,IAAI,CAAC,CAMhE"}
package/lib/native.js CHANGED
@@ -53,11 +53,8 @@ export function presentCart(options) {
53
53
  }
54
54
  export function presentOnboarding(options) {
55
55
  guardInitialized();
56
- if (Platform.OS === 'ios' && options.applePayMerchantId) {
57
- return wrapPromise(FrameSDK.presentOnboardingWithApplePay(options.accountId ?? null, options.capabilities ?? [], options.applePayMerchantId));
58
- }
59
56
  if (Platform.OS === 'ios') {
60
- return wrapPromise(FrameSDK.presentOnboarding(options.accountId ?? null, options.capabilities ?? []));
57
+ return wrapPromise(FrameSDK.presentOnboarding(options.accountId ?? null, options.capabilities ?? [], options.applePayMerchantId ?? null));
61
58
  }
62
59
  return wrapPromise(FrameSDK.presentOnboarding(options.accountId ?? null, options.capabilities ?? [], options.googlePayMerchantId ?? null));
63
60
  }
package/package.json CHANGED
@@ -1,14 +1,16 @@
1
1
  {
2
2
  "name": "framepayments-react-native",
3
- "version": "2.0.8",
3
+ "version": "2.1.0",
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",
7
7
  "scripts": {
8
8
  "build": "tsc",
9
+ "watch": "tsc --watch",
9
10
  "typecheck": "tsc --noEmit",
10
11
  "lint": "eslint src --ext .ts,.tsx",
11
12
  "test": "jest",
13
+ "prepare": "npm run build",
12
14
  "prepublishOnly": "npm run build"
13
15
  },
14
16
  "keywords": [
@@ -6,8 +6,7 @@
6
6
  const mockInitialize = jest.fn((_secretKey: string, _publishableKey: string, _debugMode: boolean) => Promise.resolve());
7
7
  const mockPresentCheckout = jest.fn((_customerId: unknown, _amount: number) => Promise.resolve({ id: 'ci_1', amount: 10000 }));
8
8
  const mockPresentCart = jest.fn((_customerId: unknown, _items: unknown[], _shipping: number) => Promise.resolve({ id: 'ci_2', amount: 15000 }));
9
- const mockPresentOnboarding = jest.fn((_accountId: unknown, _capabilities: unknown[]) => Promise.resolve({ status: 'completed', paymentMethodId: 'pm_1' }));
10
- const mockPresentOnboardingWithApplePay = jest.fn((_accountId: unknown, _capabilities: unknown[], _merchantId: string) => Promise.resolve({ status: 'completed', paymentMethodId: 'pm_2' }));
9
+ const mockPresentOnboarding = jest.fn((_accountId: unknown, _capabilities: unknown[], _merchantId: string | null) => Promise.resolve({ status: 'completed', paymentMethodId: 'pm_1' }));
11
10
 
12
11
  const mockPlatform = { OS: 'ios' as 'ios' | 'android' };
13
12
 
@@ -18,7 +17,6 @@ jest.mock('react-native', () => ({
18
17
  presentCheckout: mockPresentCheckout,
19
18
  presentCart: mockPresentCart,
20
19
  presentOnboarding: mockPresentOnboarding,
21
- presentOnboardingWithApplePay: mockPresentOnboardingWithApplePay,
22
20
  },
23
21
  },
24
22
  Platform: mockPlatform,
@@ -40,7 +38,6 @@ beforeEach(() => {
40
38
  mockPresentCheckout.mockClear();
41
39
  mockPresentCart.mockClear();
42
40
  mockPresentOnboarding.mockClear();
43
- mockPresentOnboardingWithApplePay.mockClear();
44
41
  mockPlatform.OS = 'ios';
45
42
  const native = require('../native');
46
43
  initialize = native.initialize;
@@ -145,33 +142,33 @@ describe('presentOnboarding', () => {
145
142
  expect(mockPresentOnboarding).not.toHaveBeenCalled();
146
143
  });
147
144
 
148
- it('calls native presentOnboarding with accountId and capabilities after initialize', async () => {
145
+ it('calls native presentOnboarding with accountId, capabilities, and null merchantId after initialize on iOS', async () => {
146
+ mockPlatform.OS = 'ios';
149
147
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
150
148
  const result = await presentOnboarding({ accountId: 'acct_1', capabilities: ['kyc', 'bank_account_verification'] });
151
149
  expect(mockPresentOnboarding).toHaveBeenCalledWith('acct_1', ['kyc', 'bank_account_verification'], null);
152
150
  expect(result).toEqual({ status: 'completed', paymentMethodId: 'pm_1' });
153
151
  });
154
152
 
155
- it('passes null for accountId and empty array for capabilities when not provided', async () => {
153
+ it('passes null for accountId and empty array for capabilities when not provided on iOS', async () => {
154
+ mockPlatform.OS = 'ios';
156
155
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
157
156
  await presentOnboarding({});
158
157
  expect(mockPresentOnboarding).toHaveBeenCalledWith(null, [], null);
159
158
  });
160
159
 
161
- it('routes to presentOnboardingWithApplePay on iOS when applePayMerchantId is set', async () => {
160
+ it('forwards applePayMerchantId on iOS', async () => {
162
161
  mockPlatform.OS = 'ios';
163
162
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
164
163
  await presentOnboarding({ accountId: 'acct_1', capabilities: ['kyc'], applePayMerchantId: 'merchant.com.example' });
165
- expect(mockPresentOnboardingWithApplePay).toHaveBeenCalledWith('acct_1', ['kyc'], 'merchant.com.example');
166
- expect(mockPresentOnboarding).not.toHaveBeenCalled();
164
+ expect(mockPresentOnboarding).toHaveBeenCalledWith('acct_1', ['kyc'], 'merchant.com.example');
167
165
  });
168
166
 
169
- it('still routes to presentOnboarding on Android even when applePayMerchantId is set', async () => {
167
+ it('ignores applePayMerchantId on Android', async () => {
170
168
  mockPlatform.OS = 'android';
171
169
  await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
172
170
  await presentOnboarding({ accountId: 'acct_1', capabilities: ['kyc'], applePayMerchantId: 'merchant.com.example' });
173
171
  expect(mockPresentOnboarding).toHaveBeenCalledWith('acct_1', ['kyc'], null);
174
- expect(mockPresentOnboardingWithApplePay).not.toHaveBeenCalled();
175
172
  });
176
173
 
177
174
  it('forwards googlePayMerchantId to native presentOnboarding on Android', async () => {
@@ -180,4 +177,11 @@ describe('presentOnboarding', () => {
180
177
  await presentOnboarding({ accountId: 'acct_1', capabilities: ['kyc'], googlePayMerchantId: 'BCR2DN4T...' });
181
178
  expect(mockPresentOnboarding).toHaveBeenCalledWith('acct_1', ['kyc'], 'BCR2DN4T...');
182
179
  });
180
+
181
+ it('ignores googlePayMerchantId on iOS', async () => {
182
+ mockPlatform.OS = 'ios';
183
+ await initialize({ secretKey: 'sk_xxx', publishableKey: 'pk_xxx' });
184
+ await presentOnboarding({ accountId: 'acct_1', capabilities: ['kyc'], googlePayMerchantId: 'BCR2DN4T...' });
185
+ expect(mockPresentOnboarding).toHaveBeenCalledWith('acct_1', ['kyc'], null);
186
+ });
183
187
  });
package/src/native.ts CHANGED
@@ -106,20 +106,12 @@ export function presentOnboarding(options: {
106
106
  googlePayMerchantId?: string | null;
107
107
  }): Promise<OnboardingResult> {
108
108
  guardInitialized();
109
- if (Platform.OS === 'ios' && options.applePayMerchantId) {
110
- return wrapPromise(
111
- FrameSDK.presentOnboardingWithApplePay(
112
- options.accountId ?? null,
113
- options.capabilities ?? [],
114
- options.applePayMerchantId
115
- )
116
- );
117
- }
118
109
  if (Platform.OS === 'ios') {
119
110
  return wrapPromise(
120
111
  FrameSDK.presentOnboarding(
121
112
  options.accountId ?? null,
122
- options.capabilities ?? []
113
+ options.capabilities ?? [],
114
+ options.applePayMerchantId ?? null
123
115
  )
124
116
  );
125
117
  }