Skip to content

Commit

Permalink
refactor(payment): PAYPAL-4705 removed PAYPAL-3996.paypal_fastlane_sh…
Browse files Browse the repository at this point in the history
…ipping_update experiment (#2759)
  • Loading branch information
serhii-tkachenko authored Jan 6, 2025
1 parent 450c3e3 commit 0f344ec
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import { PaymentMethod } from '@bigcommerce/checkout-sdk/payment-integration-api
import {
getBillingAddress,
getCart,
getConfig,
getCountries,
getCustomer,
getPaymentMethod,
Expand Down Expand Up @@ -130,12 +129,6 @@ describe('BraintreeFastlaneShippingStrategy', () => {
jest.spyOn(store.getState().cart, 'getCart').mockReturnValue(getCart());
jest.spyOn(store.getState().cart, 'getCartOrThrow').mockReturnValue(getCart());
jest.spyOn(store.getState().countries, 'getCountries').mockReturnValue(getCountries());
jest.spyOn(store.getState().config, 'getStoreConfigOrThrow').mockReturnValue(
// TODO: remove ts-ignore and update test with related type (PAYPAL-4383)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
getConfig().storeConfig,
);
jest.spyOn(store.getState().customer, 'getCustomerOrThrow').mockReturnValue({
...getCustomer(),
isGuest: true,
Expand Down Expand Up @@ -580,19 +573,6 @@ describe('BraintreeFastlaneShippingStrategy', () => {

describe('#handleBraintreeFastlaneShippingAddressChange', () => {
beforeEach(() => {
const storeConfig = getConfig().storeConfig;

const storeConfigWithAFeature = {
...storeConfig,
checkoutSettings: {
...storeConfig.checkoutSettings,
features: {
...storeConfig.checkoutSettings.features,
'PAYPAL-3996.paypal_fastlane_shipping_update': true,
},
},
};

jest.spyOn(braintreeIntegrationServiceMock, 'getBraintreeFastlane').mockImplementation(
() => braintreeFastlane,
);
Expand All @@ -609,12 +589,6 @@ describe('BraintreeFastlaneShippingStrategy', () => {
isFastlaneEnabled: true,
},
});
jest.spyOn(store.getState().config, 'getStoreConfigOrThrow').mockReturnValue(
// TODO: remove ts-ignore and update test with related type (PAYPAL-4383)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
storeConfigWithAFeature,
);
jest.spyOn(
store.getState().paymentProviderCustomer,
'getPaymentProviderCustomer',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,10 +429,8 @@ export default class BraintreeFastlaneShippingStrategy implements ShippingStrate
return isEqual(this._normalizeAddress(firstAddress), this._normalizeAddress(secondAddress));
}

// TODO: reimplement this method when PAYPAL-3996.paypal_fastlane_shipping_update and Fastlane features will be rolled out to 100%
private async _shouldUseBraintreeFastlaneShippingComponent(methodId: string): Promise<boolean> {
const state = this._store.getState();
const features = state.config.getStoreConfigOrThrow().checkoutSettings.features;
const paymentProviderCustomer = state.paymentProviderCustomer.getPaymentProviderCustomer();
const braintreePaymentProviderCustomer = isBraintreeAcceleratedCheckoutCustomer(
paymentProviderCustomer,
Expand All @@ -443,8 +441,6 @@ export default class BraintreeFastlaneShippingStrategy implements ShippingStrate
// Info: to avoid loading payment method we should check for values
// that does not require api calls first
if (
features &&
features['PAYPAL-3996.paypal_fastlane_shipping_update'] &&
!!braintreePaymentProviderCustomer &&
braintreePaymentProviderCustomer !== BraintreeFastlaneAuthenticationState.CANCELED
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -484,20 +484,6 @@ describe('PayPalCommerceFastlaneShippingStrategy', () => {
instruments: [bcInstrumentMock],
});

// TODO: remove ts-ignore and update test with related type (PAYPAL-4383)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
jest.spyOn(store.getState().config, 'getStoreConfigOrThrow').mockReturnValue({
...storeConfig,
checkoutSettings: {
...storeConfig.checkoutSettings,
features: {
...storeConfig.checkoutSettings.features,
'PAYPAL-3996.paypal_fastlane_shipping_update': true,
},
},
});

await strategy.initialize({
...initializationOptions,
paypalcommercefastlane: {
Expand Down Expand Up @@ -530,20 +516,6 @@ describe('PayPalCommerceFastlaneShippingStrategy', () => {
instruments: [bcInstrumentMock],
});

// TODO: remove ts-ignore and update test with related type (PAYPAL-4383)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore
jest.spyOn(store.getState().config, 'getStoreConfigOrThrow').mockReturnValue({
...storeConfig,
checkoutSettings: {
...storeConfig.checkoutSettings,
features: {
...storeConfig.checkoutSettings.features,
'PAYPAL-3996.paypal_fastlane_shipping_update': true,
},
},
});

jest.spyOn(paypalFastlane.profile, 'showShippingAddressSelector').mockImplementation(
// TODO: remove ts-ignore and update test with related type (PAYPAL-4383)
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,15 +129,10 @@ export default class PayPalCommerceFastlaneShippingStrategy implements ShippingS
return !customerAuthenticationState && paypalConnectSessionId === cart.id;
}

// TODO: reimplement this method when PAYPAL-3996.paypal_fastlane_shipping_update and Fastlane features will be rolled out to 100%
private _shouldUsePayPalFastlaneShippingComponent(): boolean {
const state = this._store.getState();
const features = state.config.getStoreConfigOrThrow().checkoutSettings.features;
const customerAuthenticationState = this._getPayPalCustomerAuthenticationState();

return (
features &&
features['PAYPAL-3996.paypal_fastlane_shipping_update'] &&
!!customerAuthenticationState &&
customerAuthenticationState !== PayPalFastlaneAuthenticationState.CANCELED
);
Expand Down

0 comments on commit 0f344ec

Please sign in to comment.