Skip to content

Commit d3d7cb4

Browse files
feat(payment): PAYPAL-5717 Added AppSwitch to PPCP button strategy
1 parent e653ddf commit d3d7cb4

File tree

1 file changed

+2
-14
lines changed

1 file changed

+2
-14
lines changed

packages/paypal-commerce-integration/src/paypal-commerce/paypal-commerce-button-strategy.ts

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,6 @@ import PayPalCommerceButtonInitializeOptions, {
2424
import { isExperimentEnabled } from '@bigcommerce/checkout-sdk/utility';
2525

2626
export default class PayPalCommerceButtonStrategy implements CheckoutButtonStrategy {
27-
private methodId?: string;
28-
2927
constructor(
3028
private paymentIntegrationService: PaymentIntegrationService,
3129
private paypalCommerceIntegrationService: PayPalCommerceIntegrationService,
@@ -71,8 +69,6 @@ export default class PayPalCommerceButtonStrategy implements CheckoutButtonStrat
7169
);
7270
}
7371

74-
this.methodId = methodId;
75-
7672
if (!isBuyNowFlow) {
7773
// Info: default checkout should not be loaded for BuyNow flow,
7874
// since there is no checkout session available for that.
@@ -111,8 +107,7 @@ export default class PayPalCommerceButtonStrategy implements CheckoutButtonStrat
111107

112108
const defaultCallbacks = {
113109
...(this.isPaypalCommerceAppSwitchEnabled() && { appSwitchWhenAvailable: true }),
114-
createOrder: () =>
115-
this.paypalCommerceIntegrationService.createOrder('paypalcommerce'),
110+
createOrder: () => this.paypalCommerceIntegrationService.createOrder('paypalcommerce'),
116111
onApprove: ({ orderID }: ApproveCallbackPayload) =>
117112
this.paypalCommerceIntegrationService.tokenizePayment(methodId, orderID),
118113
};
@@ -273,14 +268,7 @@ export default class PayPalCommerceButtonStrategy implements CheckoutButtonStrat
273268
private isPaypalCommerceAppSwitchEnabled(): boolean {
274269
const state = this.paymentIntegrationService.getState();
275270
const features = state.getStoreConfigOrThrow().checkoutSettings.features;
276-
const paymentMethod = state.getPaymentMethodOrThrow<PayPalCommerceInitializationData>(
277-
this.methodId || '',
278-
);
279-
const { isHostedCheckoutEnabled } = paymentMethod.initializationData || {};
280271

281-
return (
282-
!isHostedCheckoutEnabled &&
283-
isExperimentEnabled(features, 'PAYPAL-5716.app_switch_functionality')
284-
);
272+
return isExperimentEnabled(features, 'PAYPAL-5716.app_switch_functionality');
285273
}
286274
}

0 commit comments

Comments
 (0)