Skip to content

Commit 1d45741

Browse files
committed
feat(checkout): CHECKOUT-9388 Lazy load customer strategies by importing them on demand
1 parent 3bf2f2f commit 1d45741

38 files changed

+272
-87
lines changed

.circleci/config.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,9 +243,6 @@ workflows:
243243
<<: *pull_request_filter
244244
requires:
245245
- build-prerelease
246-
- sdk-on-cdn:
247-
filters:
248-
<<: *pull_request_filter
249246
- security/scan:
250247
name: "Gitleaks secrets scan"
251248
filters:
@@ -293,6 +290,9 @@ workflows:
293290
<<: *release_filter
294291
requires:
295292
- build
293+
- sdk-on-cdn:
294+
filters:
295+
<<: *release_filter
296296
- security/scan:
297297
name: "Gitleaks secrets scan"
298298
filters:
@@ -309,6 +309,7 @@ workflows:
309309
- lint
310310
- build
311311
- e2e
312+
- sdk-on-cdn
312313
- "Gitleaks secrets scan"
313314
- upload_to_sentry:
314315
filters:

package-lock.json

Lines changed: 39 additions & 31 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"prettier": "@bigcommerce/eslint-config/prettier",
4949
"homepage": "https://github.com/bigcommerce/checkout-js#readme",
5050
"dependencies": {
51-
"@bigcommerce/checkout-sdk": "^1.799.0",
51+
"@bigcommerce/checkout-sdk": "github:bigcommerce/checkout-sdk-js#f6997b7c3962192541e2dc281a84dde6c28d4d04",
5252
"@bigcommerce/citadel": "^2.15.1",
5353
"@bigcommerce/form-poster": "^1.2.2",
5454
"@bigcommerce/memoize": "^1.0.0",
@@ -101,7 +101,7 @@
101101
"@babel/preset-env": "^7.9.0",
102102
"@bigcommerce/eslint-config": "^2.6.1",
103103
"@bigcommerce/eslint-plugin": "^1.4.0",
104-
"@faker-js/faker": "^6.3.1",
104+
"@faker-js/faker": "^7.6.0",
105105
"@nx/devkit": "19.8.9",
106106
"@nx/eslint": "19.8.9",
107107
"@nx/eslint-plugin": "19.8.9",
@@ -183,7 +183,7 @@
183183
"ts-loader": "^9.3.0",
184184
"tslib": "^2.5.3",
185185
"typescript": "^5.6.2",
186-
"webpack": "^5.94.0",
186+
"webpack": "^5.101.3",
187187
"webpack-assets-manifest": "^5.1.0",
188188
"webpack-cli": "^4.9.2",
189189
"webpack-inject-plugin": "^1.5.3",

packages/amazon-pay-v2-integration/src/AmazonPayV2Button.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createAmazonPayV2CustomerStrategy } from '@bigcommerce/checkout-sdk/integrations/amazon-pay';
12
import React, { type FunctionComponent, useEffect } from 'react';
23

34
import { CheckoutButton } from '@bigcommerce/checkout/checkout-button-integration';
@@ -35,7 +36,7 @@ const AmazonPayV2Button: FunctionComponent<CheckoutButtonProps> = (props) => {
3536

3637
return (
3738
<div className="AmazonPayContainer">
38-
<CheckoutButton {...props} />
39+
<CheckoutButton integrations={[createAmazonPayV2CustomerStrategy]} {...props} />
3940
</div>
4041
);
4142
};

packages/bigcommerce-payments-integration/src/BigCommercePayments/BigCommercePaymentsButton.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
createCheckoutService,
55
createLanguageService,
66
} from '@bigcommerce/checkout-sdk';
7+
import { createBigCommercePaymentsCustomerStrategy } from '@bigcommerce/checkout-sdk/integrations/bigcommerce-payments';
78
import React from 'react';
89

910
import { type CheckoutButtonProps } from '@bigcommerce/checkout/payment-integration-api';
@@ -39,6 +40,7 @@ describe('BigCommercePaymentsButton', () => {
3940

4041
expect(checkoutService.initializeCustomer).toHaveBeenCalledWith({
4142
methodId: defaultProps.methodId,
43+
integrations: [createBigCommercePaymentsCustomerStrategy],
4244
bigcommerce_payments: {
4345
container: 'bigcommerce-payments-button-container',
4446
onClick: expect.any(Function),

packages/bigcommerce-payments-integration/src/BigCommercePayments/BigCommercePaymentsButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createBigCommercePaymentsCustomerStrategy } from '@bigcommerce/checkout-sdk/integrations/bigcommerce-payments';
12
import React, { type FunctionComponent } from 'react';
23

34
import { CheckoutButton } from '@bigcommerce/checkout/checkout-button-integration';
@@ -17,6 +18,7 @@ const BigCommercePaymentsButton: FunctionComponent<CheckoutButtonProps> = (props
1718
return (
1819
<CheckoutButton
1920
additionalInitializationOptions={additionalInitializationOptions}
21+
integrations={[createBigCommercePaymentsCustomerStrategy]}
2022
{...props}
2123
/>
2224
);

packages/bigcommerce-payments-integration/src/BigCommercePaymentsPayLater/BigcommercePaymentsPayLaterButton.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
createCheckoutService,
55
createLanguageService,
66
} from '@bigcommerce/checkout-sdk';
7+
import { createBigCommercePaymentsPayLaterCustomerStrategy } from '@bigcommerce/checkout-sdk/integrations/bigcommerce-payments';
78
import React from 'react';
89

910
import { type CheckoutButtonProps } from '@bigcommerce/checkout/payment-integration-api';
@@ -39,6 +40,7 @@ describe('BigcommercePaymentsPayLaterButton', () => {
3940

4041
expect(checkoutService.initializeCustomer).toHaveBeenCalledWith({
4142
methodId: defaultProps.methodId,
43+
integrations: [createBigCommercePaymentsPayLaterCustomerStrategy],
4244
bigcommerce_payments_paylater: {
4345
container: 'bigcommerce-payments-paylater-button-container',
4446
onClick: expect.any(Function),

packages/bigcommerce-payments-integration/src/BigCommercePaymentsPayLater/BigcommercePaymentsPayLaterButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { createBigCommercePaymentsPayLaterCustomerStrategy } from '@bigcommerce/checkout-sdk/integrations/bigcommerce-payments';
12
import React, { type FunctionComponent } from 'react';
23

34
import { CheckoutButton } from '@bigcommerce/checkout/checkout-button-integration';
@@ -17,6 +18,7 @@ const BigcommercePaymentsPayLaterButton: FunctionComponent<CheckoutButtonProps>
1718
return (
1819
<CheckoutButton
1920
additionalInitializationOptions={additionalInitializationOptions}
21+
integrations={[createBigCommercePaymentsPayLaterCustomerStrategy]}
2022
{...props}
2123
/>
2224
);

packages/bolt-integration/src/BoltEmbeddedPaymentMethod.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { type CustomerInitializeOptions } from '@bigcommerce/checkout-sdk';
2+
import { createBoltCustomerStrategy } from '@bigcommerce/checkout-sdk/integrations/bolt';
13
import React, { type FunctionComponent, useCallback, useState } from 'react';
24

35
import { HostedWidgetPaymentComponent } from '@bigcommerce/checkout/hosted-widget-integration';
@@ -47,6 +49,16 @@ const BoltEmbeddedPaymentMethod: FunctionComponent<PaymentMethodProps> = ({
4749
[checkoutService, boltEmbeddedContainerId, setFieldValue],
4850
);
4951

52+
const initializeBoltCustomer = useCallback(
53+
(options: CustomerInitializeOptions) => {
54+
return checkoutService.initializeCustomer({
55+
...options,
56+
integrations: [createBoltCustomerStrategy],
57+
});
58+
},
59+
[checkoutService],
60+
);
61+
5062
const renderCustomPaymentForm = useCallback(
5163
() => (
5264
<BoltCustomForm
@@ -71,6 +83,7 @@ const BoltEmbeddedPaymentMethod: FunctionComponent<PaymentMethodProps> = ({
7183
deinitializePayment={checkoutService.deinitializePayment}
7284
disableSubmit={disableSubmit}
7385
hidePaymentSubmitButton={hidePaymentSubmitButton}
86+
initializeCustomer={initializeBoltCustomer}
7487
initializePayment={initializeBoltPayment}
7588
instruments={instruments}
7689
isInitializing={isInitializingPayment()}

packages/checkout-button-integration/src/CheckoutButton.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@ const CheckoutButton: FunctionComponent<CheckoutButtonProps> = ({
1414
onUnhandledError,
1515
onWalletButtonClick,
1616
additionalInitializationOptions,
17+
integrations,
1718
}) => {
1819
const initializeCustomerStrategyOrThrow = async () => {
1920
try {
2021
await initializeCustomer({
2122
methodId,
23+
integrations,
2224
[methodId]: {
2325
container: containerId,
2426
onUnhandledError,

0 commit comments

Comments
 (0)