@paypal/checkout-components 5.0.385 → 5.0.386
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/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +1 -2
- package/src/funding/funding.js +4 -17
- package/src/funding/funding.test.js +16 -300
- package/src/funding/venmo/config.jsx +8 -7
- package/src/funding/venmo/config.test.js +37 -17
- package/src/marks/component.jsx +0 -5
- package/src/ui/buttons/buttons.jsx +0 -2
- package/src/ui/buttons/props.js +0 -6
- package/src/zoid/buttons/component.jsx +2 -33
- package/src/funding/util.js +0 -99
- package/src/funding/util.test.js +0 -264
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@paypal/checkout-components",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.386",
|
|
4
4
|
"description": "PayPal Checkout components, for integrating checkout products.",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -23,7 +23,6 @@
|
|
|
23
23
|
"jest-ssr": "jest test/ssr --env=node --no-cache --collectCoverage --collectCoverageFrom='src/' --coverageDirectory='coverage/jest'",
|
|
24
24
|
"karma": "cross-env NODE_ENV=test babel-node ./node_modules/.bin/karma start",
|
|
25
25
|
"lint": "eslint --ext .js --ext .jsx src/ test/ *.js",
|
|
26
|
-
"lint:fix": "eslint --ext .js --ext .jsx src/ test/ *.js --fix",
|
|
27
26
|
"postversion": "./scripts/postversion.sh",
|
|
28
27
|
"preversion": "./scripts/preversion.sh",
|
|
29
28
|
"reinstall": "rimraf flow-typed && rimraf node_modules && npm install && npm run flow-typed",
|
package/src/funding/funding.js
CHANGED
|
@@ -16,7 +16,6 @@ import type { Wallet, Experiment } from "../types";
|
|
|
16
16
|
import { BUTTON_LAYOUT, BUTTON_FLOW } from "../constants";
|
|
17
17
|
|
|
18
18
|
import { getFundingConfig } from "./config";
|
|
19
|
-
import { supportsVenmoPopups, isSupportedNativeVenmoBrowser } from "./util";
|
|
20
19
|
|
|
21
20
|
type IsFundingEligibleOptions = {|
|
|
22
21
|
layout?: $Values<typeof BUTTON_LAYOUT>,
|
|
@@ -36,7 +35,6 @@ type IsFundingEligibleOptions = {|
|
|
|
36
35
|
supportedNativeBrowser: boolean,
|
|
37
36
|
experiment?: Experiment,
|
|
38
37
|
displayOnly?: $ReadOnlyArray<$Values<typeof DISPLAY_ONLY_VALUES>>,
|
|
39
|
-
userAgent?: string,
|
|
40
38
|
|};
|
|
41
39
|
|
|
42
40
|
function isFundingVaultable({
|
|
@@ -86,7 +84,6 @@ export function isFundingEligible(
|
|
|
86
84
|
supportedNativeBrowser,
|
|
87
85
|
experiment,
|
|
88
86
|
displayOnly,
|
|
89
|
-
userAgent,
|
|
90
87
|
}: IsFundingEligibleOptions
|
|
91
88
|
): boolean {
|
|
92
89
|
if (!fundingEligibility[source] || !fundingEligibility[source].eligible) {
|
|
@@ -159,17 +156,10 @@ export function isFundingEligible(
|
|
|
159
156
|
return false;
|
|
160
157
|
}
|
|
161
158
|
|
|
162
|
-
if (fundingConfig.requires
|
|
159
|
+
if (fundingConfig.requires) {
|
|
163
160
|
const required = fundingConfig.requires({ experiment, platform });
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
? supportsVenmoPopups(experiment, userAgent)
|
|
167
|
-
: supportsPopups;
|
|
168
|
-
const nativeBrowserSupport =
|
|
169
|
-
source === FUNDING.VENMO
|
|
170
|
-
? isSupportedNativeVenmoBrowser(experiment, userAgent)
|
|
171
|
-
: supportedNativeBrowser;
|
|
172
|
-
if (required.popup === true && popupSupport === false) {
|
|
161
|
+
|
|
162
|
+
if (required.popup === true && supportsPopups === false) {
|
|
173
163
|
return false;
|
|
174
164
|
}
|
|
175
165
|
|
|
@@ -177,7 +167,7 @@ export function isFundingEligible(
|
|
|
177
167
|
return false;
|
|
178
168
|
}
|
|
179
169
|
|
|
180
|
-
if (required.native === true &&
|
|
170
|
+
if (required.native === true && supportedNativeBrowser === false) {
|
|
181
171
|
return false;
|
|
182
172
|
}
|
|
183
173
|
}
|
|
@@ -214,7 +204,6 @@ export function determineEligibleFunding({
|
|
|
214
204
|
supportedNativeBrowser,
|
|
215
205
|
experiment,
|
|
216
206
|
displayOnly = [],
|
|
217
|
-
userAgent = "",
|
|
218
207
|
}: {|
|
|
219
208
|
fundingSource: ?$Values<typeof FUNDING>,
|
|
220
209
|
remembered: $ReadOnlyArray<$Values<typeof FUNDING>>,
|
|
@@ -234,7 +223,6 @@ export function determineEligibleFunding({
|
|
|
234
223
|
supportedNativeBrowser: boolean,
|
|
235
224
|
experiment: Experiment,
|
|
236
225
|
displayOnly?: $ReadOnlyArray<$Values<typeof DISPLAY_ONLY_VALUES>>,
|
|
237
|
-
userAgent?: string,
|
|
238
226
|
|}): $ReadOnlyArray<$Values<typeof FUNDING>> {
|
|
239
227
|
if (fundingSource) {
|
|
240
228
|
return [fundingSource];
|
|
@@ -259,7 +247,6 @@ export function determineEligibleFunding({
|
|
|
259
247
|
supportedNativeBrowser,
|
|
260
248
|
experiment,
|
|
261
249
|
displayOnly,
|
|
262
|
-
userAgent,
|
|
263
250
|
})
|
|
264
251
|
);
|
|
265
252
|
|
|
@@ -1,23 +1,10 @@
|
|
|
1
1
|
/* @flow */
|
|
2
|
-
import { COMPONENTS, FUNDING } from "@paypal/sdk-constants/src";
|
|
3
|
-
import { describe, expect
|
|
2
|
+
import { COMPONENTS, FUNDING, PLATFORM } from "@paypal/sdk-constants/src";
|
|
3
|
+
import { describe, expect } from "vitest";
|
|
4
4
|
|
|
5
5
|
import { BUTTON_FLOW } from "../constants";
|
|
6
6
|
|
|
7
7
|
import { isFundingEligible, isWalletFundingEligible } from "./funding";
|
|
8
|
-
import { supportsVenmoPopups, isSupportedNativeVenmoBrowser } from "./util";
|
|
9
|
-
import { getFundingConfig } from "./config";
|
|
10
|
-
|
|
11
|
-
// Mock the venmo utility functions
|
|
12
|
-
vi.mock("./util", () => ({
|
|
13
|
-
supportsVenmoPopups: vi.fn(),
|
|
14
|
-
isSupportedNativeVenmoBrowser: vi.fn(),
|
|
15
|
-
}));
|
|
16
|
-
|
|
17
|
-
// Mock getFundingConfig to control funding config behavior
|
|
18
|
-
vi.mock("./config", () => ({
|
|
19
|
-
getFundingConfig: vi.fn(),
|
|
20
|
-
}));
|
|
21
8
|
|
|
22
9
|
const defaultMockFundingOptions = {
|
|
23
10
|
platform: "desktop",
|
|
@@ -68,41 +55,9 @@ const defaultMockFundingOptions = {
|
|
|
68
55
|
onShippingChange: null,
|
|
69
56
|
onShippingAddressChange: null,
|
|
70
57
|
onShippingOptionsChange: null,
|
|
71
|
-
userAgent:
|
|
72
|
-
"Mozilla/5.0 (iPhone; CPU iPhone OS 14_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.0 Mobile/15E148 Safari/604.1",
|
|
73
58
|
};
|
|
74
59
|
|
|
75
60
|
describe("Funding eligibility", () => {
|
|
76
|
-
beforeEach(() => {
|
|
77
|
-
// Mock getFundingConfig with basic configs for all funding sources
|
|
78
|
-
vi.mocked(getFundingConfig).mockReturnValue({
|
|
79
|
-
[FUNDING.PAYLATER]: {
|
|
80
|
-
enabled: true,
|
|
81
|
-
automatic: true,
|
|
82
|
-
},
|
|
83
|
-
[FUNDING.CARD]: {
|
|
84
|
-
enabled: true,
|
|
85
|
-
automatic: true,
|
|
86
|
-
},
|
|
87
|
-
[FUNDING.SEPA]: {
|
|
88
|
-
enabled: false,
|
|
89
|
-
automatic: false,
|
|
90
|
-
},
|
|
91
|
-
[FUNDING.OXXO]: {
|
|
92
|
-
enabled: false,
|
|
93
|
-
automatic: false,
|
|
94
|
-
},
|
|
95
|
-
[FUNDING.VENMO]: {
|
|
96
|
-
enabled: true,
|
|
97
|
-
automatic: true,
|
|
98
|
-
},
|
|
99
|
-
[FUNDING.PAYPAL]: {
|
|
100
|
-
enabled: true,
|
|
101
|
-
automatic: true,
|
|
102
|
-
},
|
|
103
|
-
});
|
|
104
|
-
});
|
|
105
|
-
|
|
106
61
|
describe("Desktop", () => {
|
|
107
62
|
test("should not be eligible if funding source is missing from fundingEligibility", () => {
|
|
108
63
|
const fundingEligible = isFundingEligible(
|
|
@@ -218,268 +173,29 @@ describe("Funding eligibility", () => {
|
|
|
218
173
|
});
|
|
219
174
|
});
|
|
220
175
|
|
|
221
|
-
describe("
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
vi.clearAllMocks();
|
|
225
|
-
|
|
226
|
-
// Mock getFundingConfig to return configs with venmo requirements
|
|
227
|
-
vi.mocked(getFundingConfig).mockReturnValue({
|
|
228
|
-
[FUNDING.PAYLATER]: {
|
|
229
|
-
enabled: true,
|
|
230
|
-
automatic: true,
|
|
231
|
-
},
|
|
232
|
-
[FUNDING.CARD]: {
|
|
233
|
-
enabled: true,
|
|
234
|
-
automatic: true,
|
|
235
|
-
},
|
|
236
|
-
[FUNDING.SEPA]: {
|
|
237
|
-
enabled: false,
|
|
238
|
-
automatic: false,
|
|
239
|
-
},
|
|
240
|
-
[FUNDING.OXXO]: {
|
|
241
|
-
enabled: false,
|
|
242
|
-
automatic: false,
|
|
243
|
-
},
|
|
244
|
-
[FUNDING.VENMO]: {
|
|
245
|
-
enabled: true,
|
|
246
|
-
automatic: true,
|
|
247
|
-
requires: () => ({
|
|
248
|
-
popup: true,
|
|
249
|
-
native: true,
|
|
250
|
-
}),
|
|
251
|
-
},
|
|
252
|
-
[FUNDING.PAYPAL]: {
|
|
253
|
-
enabled: true,
|
|
254
|
-
automatic: true,
|
|
255
|
-
requires: () => ({
|
|
256
|
-
popup: true,
|
|
257
|
-
native: true,
|
|
258
|
-
}),
|
|
259
|
-
},
|
|
260
|
-
});
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
afterEach(() => {
|
|
264
|
-
vi.resetAllMocks();
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
test("should use supportsVenmoPopups for venmo funding source when popup is required", () => {
|
|
268
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(true);
|
|
269
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(true);
|
|
270
|
-
|
|
271
|
-
const options = {
|
|
272
|
-
...defaultMockFundingOptions,
|
|
273
|
-
fundingSource: FUNDING.VENMO,
|
|
274
|
-
platform: "mobile",
|
|
275
|
-
experiment: { venmoEnableWebOnNonNativeBrowser: true },
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
279
|
-
|
|
280
|
-
expect(supportsVenmoPopups).toHaveBeenCalledWith(
|
|
281
|
-
options.experiment,
|
|
282
|
-
options.userAgent
|
|
283
|
-
);
|
|
284
|
-
expect(result).toBe(true);
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
test("should use isSupportedNativeVenmoBrowser for venmo funding source when native is required", () => {
|
|
288
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(true);
|
|
289
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(true);
|
|
290
|
-
|
|
291
|
-
const options = {
|
|
292
|
-
...defaultMockFundingOptions,
|
|
293
|
-
fundingSource: FUNDING.VENMO,
|
|
294
|
-
platform: "mobile",
|
|
295
|
-
experiment: { venmoEnableWebOnNonNativeBrowser: true },
|
|
296
|
-
};
|
|
297
|
-
|
|
298
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
299
|
-
|
|
300
|
-
expect(isSupportedNativeVenmoBrowser).toHaveBeenCalledWith(
|
|
301
|
-
options.experiment,
|
|
302
|
-
options.userAgent
|
|
303
|
-
);
|
|
304
|
-
expect(result).toBe(true);
|
|
305
|
-
});
|
|
306
|
-
|
|
307
|
-
test("should return false when venmo popup support is required but supportsVenmoPopups returns false", () => {
|
|
308
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(false);
|
|
309
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(true);
|
|
310
|
-
|
|
311
|
-
const options = {
|
|
312
|
-
...defaultMockFundingOptions,
|
|
313
|
-
fundingSource: FUNDING.VENMO,
|
|
314
|
-
platform: "mobile",
|
|
315
|
-
experiment: {},
|
|
316
|
-
};
|
|
317
|
-
|
|
318
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
319
|
-
|
|
320
|
-
expect(supportsVenmoPopups).toHaveBeenCalledWith(
|
|
321
|
-
options.experiment,
|
|
322
|
-
options.userAgent
|
|
323
|
-
);
|
|
324
|
-
expect(result).toBe(false);
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
test("should return false when venmo native support is required but isSupportedNativeVenmoBrowser returns false", () => {
|
|
328
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(true);
|
|
329
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(false);
|
|
176
|
+
describe("Mobile", () => {
|
|
177
|
+
test("should be eligible if window.popupBridge is defined for Venmo and supportsPopups is false", () => {
|
|
178
|
+
window.popupBridge = {};
|
|
330
179
|
|
|
331
|
-
const
|
|
180
|
+
const fundingEligible = isFundingEligible(FUNDING.VENMO, {
|
|
332
181
|
...defaultMockFundingOptions,
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
experiment: {},
|
|
336
|
-
};
|
|
337
|
-
|
|
338
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
339
|
-
|
|
340
|
-
expect(isSupportedNativeVenmoBrowser).toHaveBeenCalledWith(
|
|
341
|
-
options.experiment,
|
|
342
|
-
options.userAgent
|
|
343
|
-
);
|
|
344
|
-
expect(result).toBe(false);
|
|
345
|
-
});
|
|
346
|
-
|
|
347
|
-
test("should use standard supportsPopups for non-venmo funding sources", () => {
|
|
348
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(false);
|
|
349
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(false);
|
|
350
|
-
|
|
351
|
-
// Update the mock to not require popup and native for PayPal to isolate the test
|
|
352
|
-
vi.mocked(getFundingConfig).mockReturnValue({
|
|
353
|
-
[FUNDING.PAYLATER]: {
|
|
354
|
-
enabled: true,
|
|
355
|
-
automatic: true,
|
|
356
|
-
},
|
|
357
|
-
[FUNDING.CARD]: {
|
|
358
|
-
enabled: true,
|
|
359
|
-
automatic: true,
|
|
360
|
-
},
|
|
361
|
-
[FUNDING.SEPA]: {
|
|
362
|
-
enabled: false,
|
|
363
|
-
automatic: false,
|
|
364
|
-
},
|
|
365
|
-
[FUNDING.OXXO]: {
|
|
366
|
-
enabled: false,
|
|
367
|
-
automatic: false,
|
|
368
|
-
},
|
|
369
|
-
[FUNDING.VENMO]: {
|
|
370
|
-
enabled: true,
|
|
371
|
-
automatic: true,
|
|
372
|
-
requires: () => ({
|
|
373
|
-
popup: true,
|
|
374
|
-
native: true,
|
|
375
|
-
}),
|
|
376
|
-
},
|
|
377
|
-
[FUNDING.PAYPAL]: {
|
|
378
|
-
enabled: true,
|
|
379
|
-
automatic: true,
|
|
380
|
-
// No requires function for PayPal to test standard behavior
|
|
381
|
-
},
|
|
182
|
+
platform: PLATFORM.MOBILE,
|
|
183
|
+
supportsPopups: false,
|
|
382
184
|
});
|
|
383
185
|
|
|
384
|
-
|
|
385
|
-
...defaultMockFundingOptions,
|
|
386
|
-
fundingSource: FUNDING.PAYPAL,
|
|
387
|
-
platform: "mobile",
|
|
388
|
-
supportsPopups: true,
|
|
389
|
-
supportedNativeBrowser: true,
|
|
390
|
-
experiment: {},
|
|
391
|
-
fundingEligibility: {
|
|
392
|
-
...defaultMockFundingOptions.fundingEligibility,
|
|
393
|
-
paypal: {
|
|
394
|
-
eligible: true,
|
|
395
|
-
vaultable: false,
|
|
396
|
-
branded: false,
|
|
397
|
-
},
|
|
398
|
-
},
|
|
399
|
-
};
|
|
400
|
-
|
|
401
|
-
const result = isFundingEligible(FUNDING.PAYPAL, options);
|
|
186
|
+
expect(fundingEligible).toBe(true);
|
|
402
187
|
|
|
403
|
-
|
|
404
|
-
expect(supportsVenmoPopups).not.toHaveBeenCalled();
|
|
405
|
-
expect(isSupportedNativeVenmoBrowser).not.toHaveBeenCalled();
|
|
406
|
-
expect(result).toBe(true);
|
|
188
|
+
window.popupBridge = undefined;
|
|
407
189
|
});
|
|
408
190
|
|
|
409
|
-
test("should
|
|
410
|
-
|
|
411
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(true);
|
|
412
|
-
|
|
413
|
-
const options = {
|
|
191
|
+
test("should not be eligible if window.popupBridge is undefined for Venmo and supportsPopups is false", () => {
|
|
192
|
+
const fundingEligible = isFundingEligible(FUNDING.VENMO, {
|
|
414
193
|
...defaultMockFundingOptions,
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
};
|
|
419
|
-
|
|
420
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
421
|
-
|
|
422
|
-
expect(supportsVenmoPopups).toHaveBeenCalledWith(
|
|
423
|
-
undefined,
|
|
424
|
-
options.userAgent
|
|
425
|
-
);
|
|
426
|
-
expect(isSupportedNativeVenmoBrowser).toHaveBeenCalledWith(
|
|
427
|
-
undefined,
|
|
428
|
-
options.userAgent
|
|
429
|
-
);
|
|
430
|
-
expect(result).toBe(true);
|
|
431
|
-
});
|
|
432
|
-
|
|
433
|
-
test("should pass through experiment flags to venmo utility functions", () => {
|
|
434
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(true);
|
|
435
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(true);
|
|
436
|
-
|
|
437
|
-
const experimentFlags = {
|
|
438
|
-
venmoEnableWebOnNonNativeBrowser: true,
|
|
439
|
-
venmoVaultWithoutPurchase: false,
|
|
440
|
-
};
|
|
441
|
-
|
|
442
|
-
const options = {
|
|
443
|
-
...defaultMockFundingOptions,
|
|
444
|
-
fundingSource: FUNDING.VENMO,
|
|
445
|
-
platform: "mobile",
|
|
446
|
-
experiment: experimentFlags,
|
|
447
|
-
};
|
|
448
|
-
|
|
449
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
450
|
-
|
|
451
|
-
expect(supportsVenmoPopups).toHaveBeenCalledWith(
|
|
452
|
-
experimentFlags,
|
|
453
|
-
options.userAgent
|
|
454
|
-
);
|
|
455
|
-
expect(isSupportedNativeVenmoBrowser).toHaveBeenCalledWith(
|
|
456
|
-
experimentFlags,
|
|
457
|
-
options.userAgent
|
|
458
|
-
);
|
|
459
|
-
expect(result).toBe(true);
|
|
460
|
-
});
|
|
461
|
-
|
|
462
|
-
test("should respect combination of venmo popup and native requirements", () => {
|
|
463
|
-
// Test case where popup succeeds but native fails
|
|
464
|
-
vi.mocked(supportsVenmoPopups).mockReturnValue(true);
|
|
465
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(false);
|
|
466
|
-
|
|
467
|
-
const options = {
|
|
468
|
-
...defaultMockFundingOptions,
|
|
469
|
-
fundingSource: FUNDING.VENMO,
|
|
470
|
-
platform: "mobile",
|
|
471
|
-
experiment: {},
|
|
472
|
-
};
|
|
473
|
-
|
|
474
|
-
const result = isFundingEligible(FUNDING.VENMO, options);
|
|
475
|
-
|
|
476
|
-
expect(result).toBe(false);
|
|
477
|
-
|
|
478
|
-
// Test case where both succeed
|
|
479
|
-
vi.mocked(isSupportedNativeVenmoBrowser).mockReturnValue(true);
|
|
194
|
+
platform: PLATFORM.MOBILE,
|
|
195
|
+
supportsPopups: false,
|
|
196
|
+
});
|
|
480
197
|
|
|
481
|
-
|
|
482
|
-
expect(result2).toBe(true);
|
|
198
|
+
expect(fundingEligible).toBe(false);
|
|
483
199
|
});
|
|
484
200
|
});
|
|
485
201
|
});
|
|
@@ -48,18 +48,19 @@ export function getVenmoConfig(): FundingSourceConfig {
|
|
|
48
48
|
return true;
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
-
requires: ({ platform }) => {
|
|
51
|
+
requires: ({ experiment, platform }) => {
|
|
52
|
+
const isNonNativeSupported =
|
|
53
|
+
experiment?.venmoEnableWebOnNonNativeBrowser === true ||
|
|
54
|
+
(__WEB__ && window.popupBridge);
|
|
55
|
+
|
|
52
56
|
if (platform === PLATFORM.MOBILE) {
|
|
53
57
|
return {
|
|
54
|
-
native: true,
|
|
55
|
-
popup: true,
|
|
58
|
+
native: isNonNativeSupported ? false : true,
|
|
59
|
+
popup: isNonNativeSupported ? false : true,
|
|
56
60
|
};
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
return {
|
|
60
|
-
native: false,
|
|
61
|
-
popup: false,
|
|
62
|
-
};
|
|
63
|
+
return {};
|
|
63
64
|
},
|
|
64
65
|
|
|
65
66
|
Logo: ({ logoColor, optional, shouldApplyRebrandedStyles }) => {
|
|
@@ -8,9 +8,6 @@ import { BUTTON_FLOW } from "../../constants";
|
|
|
8
8
|
import { getVenmoConfig } from "./config";
|
|
9
9
|
|
|
10
10
|
describe("Venmo eligibility", () => {
|
|
11
|
-
window.navigator.mockUserAgent =
|
|
12
|
-
"Mozilla/5.0 (iPhone; CPU iPhone OS 17_0 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.0 Mobile/15E148 Safari/604.1";
|
|
13
|
-
|
|
14
11
|
const baseEligibilityProps = {
|
|
15
12
|
fundingSource: undefined,
|
|
16
13
|
components: ["buttons"],
|
|
@@ -105,35 +102,58 @@ describe("Venmo eligibility", () => {
|
|
|
105
102
|
});
|
|
106
103
|
|
|
107
104
|
describe("requires", () => {
|
|
108
|
-
test("should
|
|
109
|
-
|
|
105
|
+
test("should not check for native or popup eligibility if platform is mobile and window.popupBridge is defined", () => {
|
|
106
|
+
window.popupBridge = {};
|
|
107
|
+
|
|
108
|
+
const isVenmoEligible = venmoConfig.requires?.({
|
|
109
|
+
experiment: {
|
|
110
|
+
venmoEnableWebOnNonNativeBrowser: true,
|
|
111
|
+
},
|
|
110
112
|
platform: PLATFORM.MOBILE,
|
|
111
113
|
});
|
|
112
114
|
|
|
113
|
-
expect(
|
|
114
|
-
native:
|
|
115
|
-
popup:
|
|
115
|
+
expect(isVenmoEligible).toEqual({
|
|
116
|
+
native: false,
|
|
117
|
+
popup: false,
|
|
116
118
|
});
|
|
119
|
+
|
|
120
|
+
window.popupBridge = undefined;
|
|
117
121
|
});
|
|
118
122
|
|
|
119
|
-
test("should not
|
|
120
|
-
const
|
|
121
|
-
|
|
123
|
+
test("should not check for native or popup eligibility if platform is mobile and venmoEnableWebOnNonNativeBrowser is true", () => {
|
|
124
|
+
const isVenmoEligible = venmoConfig.requires?.({
|
|
125
|
+
experiment: {
|
|
126
|
+
venmoEnableWebOnNonNativeBrowser: true,
|
|
127
|
+
},
|
|
128
|
+
platform: PLATFORM.MOBILE,
|
|
122
129
|
});
|
|
123
130
|
|
|
124
|
-
expect(
|
|
131
|
+
expect(isVenmoEligible).toEqual({
|
|
125
132
|
native: false,
|
|
126
133
|
popup: false,
|
|
127
134
|
});
|
|
128
135
|
});
|
|
129
136
|
|
|
130
|
-
test("should
|
|
131
|
-
const
|
|
137
|
+
test("should check for native and popup eligibility if platform is mobile and venmoEnableWebOnNonNativeBrowser is false and window.popupBridge is not defined", () => {
|
|
138
|
+
const isVenmoEligible = venmoConfig.requires?.({
|
|
139
|
+
experiment: {
|
|
140
|
+
venmoEnableWebOnNonNativeBrowser: false,
|
|
141
|
+
},
|
|
142
|
+
platform: PLATFORM.MOBILE,
|
|
143
|
+
});
|
|
132
144
|
|
|
133
|
-
expect(
|
|
134
|
-
native:
|
|
135
|
-
popup:
|
|
145
|
+
expect(isVenmoEligible).toEqual({
|
|
146
|
+
native: true,
|
|
147
|
+
popup: true,
|
|
148
|
+
});
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
test("should not check for native and popup eligibility if platform is not mobile", () => {
|
|
152
|
+
const isVenmoEligible = venmoConfig.requires?.({
|
|
153
|
+
platform: PLATFORM.DESKTOP,
|
|
136
154
|
});
|
|
155
|
+
|
|
156
|
+
expect(isVenmoEligible).toEqual({});
|
|
137
157
|
});
|
|
138
158
|
});
|
|
139
159
|
});
|
package/src/marks/component.jsx
CHANGED
|
@@ -9,7 +9,6 @@ import {
|
|
|
9
9
|
memoize,
|
|
10
10
|
isApplePaySupported,
|
|
11
11
|
supportsPopups as userAgentSupportsPopups,
|
|
12
|
-
getUserAgent,
|
|
13
12
|
} from "@krakenjs/belter/src";
|
|
14
13
|
import {
|
|
15
14
|
PLATFORM,
|
|
@@ -52,7 +51,6 @@ type MarksProps = {|
|
|
|
52
51
|
onShippingAddressChange?: OnShippingAddressChange,
|
|
53
52
|
onShippingOptionsChange?: OnShippingOptionsChange,
|
|
54
53
|
displayOnly?: $ReadOnlyArray<$Values<typeof DISPLAY_ONLY_VALUES>>,
|
|
55
|
-
userAgent: string,
|
|
56
54
|
|};
|
|
57
55
|
|
|
58
56
|
export type MarksComponent = (MarksProps) => MarksInstance;
|
|
@@ -64,7 +62,6 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
64
62
|
onShippingAddressChange,
|
|
65
63
|
onShippingOptionsChange,
|
|
66
64
|
displayOnly,
|
|
67
|
-
userAgent = getUserAgent(),
|
|
68
65
|
}: MarksProps = {}): MarksInstance {
|
|
69
66
|
const height = DEFAULT_HEIGHT;
|
|
70
67
|
const fundingEligibility = getFundingEligibility();
|
|
@@ -102,7 +99,6 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
102
99
|
supportedNativeBrowser,
|
|
103
100
|
experiment,
|
|
104
101
|
displayOnly,
|
|
105
|
-
userAgent,
|
|
106
102
|
});
|
|
107
103
|
const env = getEnv();
|
|
108
104
|
|
|
@@ -127,7 +123,6 @@ export const getMarksComponent: () => MarksComponent = memoize(() => {
|
|
|
127
123
|
supportedNativeBrowser,
|
|
128
124
|
experiment,
|
|
129
125
|
displayOnly,
|
|
130
|
-
userAgent,
|
|
131
126
|
});
|
|
132
127
|
};
|
|
133
128
|
|
|
@@ -168,7 +168,6 @@ export function Buttons(props: ButtonsProps): ElementNode {
|
|
|
168
168
|
userIDToken,
|
|
169
169
|
vault,
|
|
170
170
|
wallet,
|
|
171
|
-
userAgent,
|
|
172
171
|
} = normalizeButtonProps(props);
|
|
173
172
|
const { layout, shape, tagline } = style;
|
|
174
173
|
|
|
@@ -191,7 +190,6 @@ export function Buttons(props: ButtonsProps): ElementNode {
|
|
|
191
190
|
supportedNativeBrowser,
|
|
192
191
|
experiment,
|
|
193
192
|
displayOnly,
|
|
194
|
-
userAgent,
|
|
195
193
|
});
|
|
196
194
|
const multiple = fundingSources.length > 1;
|
|
197
195
|
|
package/src/ui/buttons/props.js
CHANGED
|
@@ -491,7 +491,6 @@ export type RenderButtonProps = {|
|
|
|
491
491
|
displayOnly?: $ReadOnlyArray<$Values<typeof DISPLAY_ONLY_VALUES>>,
|
|
492
492
|
message?: ButtonMessage,
|
|
493
493
|
messageMarkup?: string,
|
|
494
|
-
userAgent: string,
|
|
495
494
|
|};
|
|
496
495
|
|
|
497
496
|
export type PrerenderDetails = {|
|
|
@@ -634,7 +633,6 @@ export type ButtonProps = {|
|
|
|
634
633
|
message?: ButtonMessage,
|
|
635
634
|
messageMarkup?: string,
|
|
636
635
|
hideSubmitButtonForCardForm?: boolean,
|
|
637
|
-
userAgent: string,
|
|
638
636
|
|};
|
|
639
637
|
|
|
640
638
|
// eslint-disable-next-line flowtype/require-exact-type
|
|
@@ -685,7 +683,6 @@ export type ButtonPropsInputs = {
|
|
|
685
683
|
messageMarkup?: string | void,
|
|
686
684
|
renderedButtons: $ReadOnlyArray<$Values<typeof FUNDING>>,
|
|
687
685
|
buttonColor: ButtonColor,
|
|
688
|
-
userAgent: string,
|
|
689
686
|
};
|
|
690
687
|
|
|
691
688
|
export const DEFAULT_STYLE = {
|
|
@@ -1265,7 +1262,6 @@ export function normalizeButtonProps(
|
|
|
1265
1262
|
messageMarkup,
|
|
1266
1263
|
renderedButtons,
|
|
1267
1264
|
shopperSessionId,
|
|
1268
|
-
userAgent,
|
|
1269
1265
|
} = props;
|
|
1270
1266
|
|
|
1271
1267
|
const { country, lang } = locale;
|
|
@@ -1319,7 +1315,6 @@ export function normalizeButtonProps(
|
|
|
1319
1315
|
supportsPopups,
|
|
1320
1316
|
supportedNativeBrowser,
|
|
1321
1317
|
displayOnly,
|
|
1322
|
-
userAgent,
|
|
1323
1318
|
})
|
|
1324
1319
|
) {
|
|
1325
1320
|
throw new Error(`Funding Source not eligible: ${fundingSource}`);
|
|
@@ -1371,6 +1366,5 @@ export function normalizeButtonProps(
|
|
|
1371
1366
|
displayOnly,
|
|
1372
1367
|
message,
|
|
1373
1368
|
messageMarkup,
|
|
1374
|
-
userAgent,
|
|
1375
1369
|
};
|
|
1376
1370
|
}
|