@@ -9,13 +9,13 @@ import {
99} from '@bigcommerce/checkout-sdk/payment-integration-api' ;
1010import {
1111 getFastlaneStyles ,
12- PayPalCommerceFastlaneUtils ,
13- PayPalCommerceInitializationData ,
14- PayPalCommerceSdk ,
1512 PayPalFastlaneAuthenticationResult ,
1613 PayPalFastlaneAuthenticationState ,
1714 PayPalFastlaneStylesOption ,
18- } from '@bigcommerce/checkout-sdk/paypal-commerce-utils' ;
15+ PayPalFastlaneUtils ,
16+ PayPalInitializationData ,
17+ PayPalSdkScriptLoader ,
18+ } from '@bigcommerce/checkout-sdk/paypal-utils' ;
1919
2020import PayPalCommerceFastlaneCustomerInitializeOptions , {
2121 WithPayPalCommerceFastlaneCustomerInitializeOptions ,
@@ -24,8 +24,8 @@ import PayPalCommerceFastlaneCustomerInitializeOptions, {
2424export default class PayPalCommerceFastlaneCustomerStrategy implements CustomerStrategy {
2525 constructor (
2626 private paymentIntegrationService : PaymentIntegrationService ,
27- private paypalCommerceSdk : PayPalCommerceSdk ,
28- private paypalCommerceFastlaneUtils : PayPalCommerceFastlaneUtils ,
27+ private paypalSdkScriptLoader : PayPalSdkScriptLoader ,
28+ private paypalFastlaneUtils : PayPalFastlaneUtils ,
2929 ) { }
3030
3131 async initialize (
@@ -44,18 +44,17 @@ export default class PayPalCommerceFastlaneCustomerStrategy implements CustomerS
4444
4545 const state = this . paymentIntegrationService . getState ( ) ;
4646 const cart = state . getCartOrThrow ( ) ;
47- const paymentMethod =
48- state . getPaymentMethodOrThrow < PayPalCommerceInitializationData > ( methodId ) ;
47+ const paymentMethod = state . getPaymentMethodOrThrow < PayPalInitializationData > ( methodId ) ;
4948
5049 const isTestModeEnabled = ! ! paymentMethod . initializationData ?. isDeveloperModeApplicable ;
5150
52- const paypalFastlaneSdk = await this . paypalCommerceSdk . getPayPalFastlaneSdk (
51+ const paypalFastlaneSdk = await this . paypalSdkScriptLoader . getPayPalFastlaneSdk (
5352 paymentMethod ,
5453 cart . currency . code ,
5554 cart . id ,
5655 ) ;
5756
58- await this . paypalCommerceFastlaneUtils . initializePayPalFastlane (
57+ await this . paypalFastlaneUtils . initializePayPalFastlane (
5958 paypalFastlaneSdk ,
6059 isTestModeEnabled ,
6160 this . getFastlaneStyles ( methodId , paypalcommercefastlane ) ,
@@ -132,24 +131,22 @@ export default class PayPalCommerceFastlaneCustomerStrategy implements CustomerS
132131 const billingAddress = state . getBillingAddress ( ) ;
133132 const customerEmail = customer ?. email || billingAddress ?. email || '' ;
134133
135- const { customerContextId } = await this . paypalCommerceFastlaneUtils . lookupCustomerOrThrow (
134+ const { customerContextId } = await this . paypalFastlaneUtils . lookupCustomerOrThrow (
136135 customerEmail ,
137136 ) ;
138137
139138 const authenticationResult =
140- await this . paypalCommerceFastlaneUtils . triggerAuthenticationFlowOrThrow (
141- customerContextId ,
142- ) ;
139+ await this . paypalFastlaneUtils . triggerAuthenticationFlowOrThrow ( customerContextId ) ;
143140
144141 const isAuthenticationFlowCanceled =
145142 authenticationResult . authenticationState === PayPalFastlaneAuthenticationState . CANCELED ;
146143
147144 await this . updateCustomerDataState ( methodId , authenticationResult ) ;
148145
149146 if ( isAuthenticationFlowCanceled ) {
150- this . paypalCommerceFastlaneUtils . removeStorageSessionId ( ) ;
147+ this . paypalFastlaneUtils . removeStorageSessionId ( ) ;
151148 } else {
152- this . paypalCommerceFastlaneUtils . updateStorageSessionId ( cartId ) ;
149+ this . paypalFastlaneUtils . updateStorageSessionId ( cartId ) ;
153150 }
154151 }
155152
@@ -161,7 +158,7 @@ export default class PayPalCommerceFastlaneCustomerStrategy implements CustomerS
161158 const cart = state . getCartOrThrow ( ) ;
162159
163160 const { authenticationState, addresses, billingAddress, shippingAddress, instruments } =
164- this . paypalCommerceFastlaneUtils . mapPayPalFastlaneProfileToBcCustomerData (
161+ this . paypalFastlaneUtils . mapPayPalFastlaneProfileToBcCustomerData (
165162 methodId ,
166163 authenticationResult ,
167164 ) ;
@@ -182,7 +179,7 @@ export default class PayPalCommerceFastlaneCustomerStrategy implements CustomerS
182179 ) ;
183180
184181 const paymentMethod =
185- updatedState . getPaymentMethodOrThrow < PayPalCommerceInitializationData > ( methodId ) ;
182+ updatedState . getPaymentMethodOrThrow < PayPalInitializationData > ( methodId ) ;
186183 const { isFastlaneShippingOptionAutoSelectEnabled } =
187184 paymentMethod . initializationData || { } ;
188185 const consignments = updatedState . getConsignments ( ) || [ ] ;
@@ -213,8 +210,7 @@ export default class PayPalCommerceFastlaneCustomerStrategy implements CustomerS
213210 paypalcommercefastlane : PayPalCommerceFastlaneCustomerInitializeOptions | undefined ,
214211 ) : PayPalFastlaneStylesOption | undefined {
215212 const state = this . paymentIntegrationService . getState ( ) ;
216- const paymentMethod =
217- state . getPaymentMethodOrThrow < PayPalCommerceInitializationData > ( methodId ) ;
213+ const paymentMethod = state . getPaymentMethodOrThrow < PayPalInitializationData > ( methodId ) ;
218214
219215 const { fastlaneStyles, isFastlaneStylingEnabled } = paymentMethod . initializationData || { } ;
220216
0 commit comments