Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(payment): PAYPAL-4705 removed PAYPAL-3996.paypal_fastlane_shipping_update experiment #2759

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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