@@ -3,7 +3,7 @@ import { createScriptLoader } from '@bigcommerce/script-loader';
3
3
4
4
import { BillingAddressActionCreator , BillingAddressRequestSender } from '../billing' ;
5
5
import { createDataStoreProjection } from '../common/data-store' ;
6
- import { ErrorActionCreator } from '../common/error' ;
6
+ import { DefaultErrorLogger , ErrorActionCreator , ErrorLogger } from '../common/error' ;
7
7
import { getDefaultLogger } from '../common/log' ;
8
8
import { getEnvironment } from '../common/utility' ;
9
9
import { ConfigActionCreator , ConfigRequestSender , ConfigState , ConfigWindow } from '../config' ;
@@ -28,7 +28,8 @@ import {
28
28
WorkerExtensionMessenger ,
29
29
} from '../extension' ;
30
30
import { FormFieldsActionCreator , FormFieldsRequestSender } from '../form' ;
31
- import * as defaultPaymentStrategyFactories from '../generated/payment-strategies' ;
31
+ import * as customerStrategyFactories from '../generated/customer-strategies' ;
32
+ import * as paymentStrategyFactories from '../generated/payment-strategies' ;
32
33
import { CountryActionCreator , CountryRequestSender } from '../geography' ;
33
34
import { OrderActionCreator , OrderRequestSender } from '../order' ;
34
35
import {
@@ -107,7 +108,11 @@ export default function createCheckoutService(options?: CheckoutServiceOptions):
107
108
errors : { } ,
108
109
statuses : { } ,
109
110
} ;
110
- const { locale = '' , shouldWarnMutation = true } = options || { } ;
111
+ const {
112
+ locale = '' ,
113
+ shouldWarnMutation = true ,
114
+ errorLogger = new DefaultErrorLogger ( ) ,
115
+ } = options || { } ;
111
116
const requestSender = createRequestSender ( { host : options && options . host } ) ;
112
117
const store = createCheckoutStore ( { config } , { shouldWarnMutation } ) ;
113
118
const paymentClient = createPaymentClient ( store ) ;
@@ -136,12 +141,20 @@ export default function createCheckoutService(options?: CheckoutServiceOptions):
136
141
formFieldsActionCreator ,
137
142
) ;
138
143
const paymentIntegrationService = createPaymentIntegrationService ( store ) ;
144
+
139
145
const registryV2 = createPaymentStrategyRegistryV2 (
140
146
paymentIntegrationService ,
141
- defaultPaymentStrategyFactories ,
147
+ paymentStrategyFactories ,
148
+ // TODO: Replace once CHECKOUT-9450.lazy_load_payment_strategies experiment is rolled out
149
+ // process.env.ESSENTIAL_BUILD ? {} : paymentStrategyFactories,
142
150
{ useFallback : true } ,
143
151
) ;
144
- const customerRegistryV2 = createCustomerStrategyRegistryV2 ( paymentIntegrationService ) ;
152
+ const customerRegistryV2 = createCustomerStrategyRegistryV2 (
153
+ paymentIntegrationService ,
154
+ customerStrategyFactories ,
155
+ // TODO: Replace once CHECKOUT-9450.lazy_load_payment_strategies experiment is rolled out
156
+ // process.env.ESSENTIAL_BUILD ? {} : customerStrategyFactories,
157
+ ) ;
145
158
const extensionActionCreator = new ExtensionActionCreator (
146
159
new ExtensionRequestSender ( requestSender ) ,
147
160
) ;
@@ -174,6 +187,8 @@ export default function createCheckoutService(options?: CheckoutServiceOptions):
174
187
new CustomerStrategyActionCreator (
175
188
createCustomerStrategyRegistry ( store , requestSender , locale ) ,
176
189
customerRegistryV2 ,
190
+ paymentIntegrationService ,
191
+ errorLogger ,
177
192
) ,
178
193
new ErrorActionCreator ( ) ,
179
194
new GiftCertificateActionCreator ( new GiftCertificateRequestSender ( requestSender ) ) ,
@@ -187,10 +202,13 @@ export default function createCheckoutService(options?: CheckoutServiceOptions):
187
202
requestSender ,
188
203
spamProtection ,
189
204
locale ,
205
+ errorLogger ,
190
206
) ,
191
207
registryV2 ,
192
208
orderActionCreator ,
193
209
spamProtectionActionCreator ,
210
+ paymentIntegrationService ,
211
+ errorLogger ,
194
212
) ,
195
213
new PickupOptionActionCreator ( new PickupOptionRequestSender ( requestSender ) ) ,
196
214
new ShippingCountryActionCreator (
@@ -213,4 +231,5 @@ export interface CheckoutServiceOptions {
213
231
host ?: string ;
214
232
shouldWarnMutation ?: boolean ;
215
233
externalSource ?: string ;
234
+ errorLogger ?: ErrorLogger ;
216
235
}
0 commit comments