@daffodil/authorizenet 0.94.1 → 0.95.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/fesm2022/daffodil-authorizenet-driver-in-memory.mjs +145 -85
  2. package/fesm2022/daffodil-authorizenet-driver-in-memory.mjs.map +1 -1
  3. package/fesm2022/daffodil-authorizenet-driver-magento-2.4.7.mjs +184 -0
  4. package/fesm2022/daffodil-authorizenet-driver-magento-2.4.7.mjs.map +1 -0
  5. package/fesm2022/daffodil-authorizenet-driver-magento-auto.mjs +7 -0
  6. package/fesm2022/daffodil-authorizenet-driver-magento-auto.mjs.map +1 -0
  7. package/fesm2022/daffodil-authorizenet-driver-testing.mjs +88 -47
  8. package/fesm2022/daffodil-authorizenet-driver-testing.mjs.map +1 -1
  9. package/fesm2022/daffodil-authorizenet-driver.mjs +153 -262
  10. package/fesm2022/daffodil-authorizenet-driver.mjs.map +1 -1
  11. package/fesm2022/daffodil-authorizenet-state-testing.mjs +87 -43
  12. package/fesm2022/daffodil-authorizenet-state-testing.mjs.map +1 -1
  13. package/fesm2022/daffodil-authorizenet-state.mjs +364 -363
  14. package/fesm2022/daffodil-authorizenet-state.mjs.map +1 -1
  15. package/fesm2022/daffodil-authorizenet-testing.mjs +49 -39
  16. package/fesm2022/daffodil-authorizenet-testing.mjs.map +1 -1
  17. package/fesm2022/daffodil-authorizenet.mjs +72 -62
  18. package/fesm2022/daffodil-authorizenet.mjs.map +1 -1
  19. package/package.json +1 -1
  20. package/types/daffodil-authorizenet-driver-in-memory.d.ts +35 -34
  21. package/types/daffodil-authorizenet-driver-magento-2.4.7.d.ts +45 -0
  22. package/types/daffodil-authorizenet-driver-magento-auto.d.ts +1 -0
  23. package/types/daffodil-authorizenet-driver-testing.d.ts +23 -20
  24. package/types/daffodil-authorizenet-driver.d.ts +116 -146
  25. package/types/daffodil-authorizenet-state-testing.d.ts +25 -21
  26. package/types/daffodil-authorizenet-state.d.ts +133 -140
  27. package/types/daffodil-authorizenet-testing.d.ts +13 -16
  28. package/types/daffodil-authorizenet.d.ts +57 -69
  29. package/fesm2022/daffodil-authorizenet-driver-magento.mjs +0 -124
  30. package/fesm2022/daffodil-authorizenet-driver-magento.mjs.map +0 -1
  31. package/types/daffodil-authorizenet-driver-magento.d.ts +0 -44
@@ -1,376 +1,377 @@
1
- import * as i1 from '@ngrx/store';
2
- import { createFeatureSelector, createSelector, defaultMemoize, select, combineReducers, StoreModule } from '@ngrx/store';
3
- import { DaffPaymentActionTypes, DaffPaymentStateModule, daffPaymentProvideAvailableProcessors, daffPaymentProvideExtraReducers, daffPaymentReducerFactory } from '@daffodil/payment/state';
4
- import { createMultiInjectionToken, createConfigInjectionToken, createSingleInjectionToken, backoff } from '@daffodil/core';
5
- import { daffTransformErrorToStateError, substream, daffComposeReducers } from '@daffodil/core/state';
6
- import * as i0 from '@angular/core';
7
- import { Injectable, Inject, inject, NgModule } from '@angular/core';
8
- import * as i1$1 from '@ngrx/effects';
9
- import { createEffect, ofType, EffectsModule } from '@ngrx/effects';
10
- import { of, defer } from 'rxjs';
11
- import { switchMap, map, catchError, tap } from 'rxjs/operators';
12
- import * as i2 from '@daffodil/authorizenet';
13
- import { DAFF_AUTHORIZENET_PAYMENT_KIND } from '@daffodil/authorizenet';
14
- import { DaffAuthorizeNetAcceptjsMissingError, DaffAuthorizeNetDriver, DaffAuthorizeNetPaymentId, DaffAuthorizeNetPaymentDriver } from '@daffodil/authorizenet/driver';
15
- import { DaffCartPaymentUpdateWithBilling, DaffCartPaymentActionTypes } from '@daffodil/cart/state';
16
-
1
+ import * as i1$1 from "@ngrx/store";
2
+ import { StoreModule, combineReducers, createFeatureSelector, createSelector, defaultMemoize, provideState, select } from "@ngrx/store";
3
+ import { DaffPaymentActionTypes, DaffPaymentStateModule, daffPaymentProvideAvailableProcessors, daffPaymentProvideExtraReducers, daffPaymentReducerFactory, provideDaffPaymentState } from "@daffodil/payment/state";
4
+ import { backoff, createConfigInjectionToken, createMultiInjectionToken, createSingleInjectionToken } from "@daffodil/core";
5
+ import { daffComposeReducers, daffTransformErrorToStateError, substream } from "@daffodil/core/state";
6
+ import * as i0 from "@angular/core";
7
+ import { Inject, Injectable, NgModule, inject, makeEnvironmentProviders } from "@angular/core";
8
+ import * as i1 from "@ngrx/effects";
9
+ import { EffectsModule, createEffect, ofType, provideEffects } from "@ngrx/effects";
10
+ import { defer, of } from "rxjs";
11
+ import { catchError, map, switchMap, tap } from "rxjs/operators";
12
+ import * as i2 from "@daffodil/authorizenet";
13
+ import { DAFF_AUTHORIZENET_PAYMENT_KIND } from "@daffodil/authorizenet";
14
+ import { DaffAuthorizeNetAcceptjsMissingError, DaffAuthorizeNetDriver, DaffAuthorizeNetPaymentDriver, DaffAuthorizeNetPaymentId } from "@daffodil/authorizenet/driver";
15
+ import { DaffCartPaymentActionTypes, DaffCartPaymentUpdateWithBilling } from "@daffodil/cart/state";
17
16
  var DaffAuthorizeNetActionTypes;
18
- (function (DaffAuthorizeNetActionTypes) {
19
- DaffAuthorizeNetActionTypes["UpdatePaymentAction"] = "[@daffodil/authorizenet] Update Payment";
20
- DaffAuthorizeNetActionTypes["UpdatePaymentSuccessAction"] = "[@daffodil/authorizenet] Update Payment Success";
21
- DaffAuthorizeNetActionTypes["UpdatePaymentFailureAction"] = "[@daffodil/authorizenet] Update Payment Failure";
22
- DaffAuthorizeNetActionTypes["ApplyPaymentAction"] = "[@daffodil/authorizenet] Apply Payment";
23
- DaffAuthorizeNetActionTypes["LoadAcceptJsAction"] = "[@daffodil/authorizenet] Load Accept Js";
24
- DaffAuthorizeNetActionTypes["LoadAcceptJsSuccessAction"] = "[@daffodil/authorizenet] Load Accept Js Success";
25
- DaffAuthorizeNetActionTypes["LoadAcceptJsFailureAction"] = "[@daffodil/authorizenet] Load Accept Js Failure";
17
+ (function(DaffAuthorizeNetActionTypes) {
18
+ DaffAuthorizeNetActionTypes["UpdatePaymentAction"] = "[@daffodil/authorizenet] Update Payment";
19
+ DaffAuthorizeNetActionTypes["UpdatePaymentSuccessAction"] = "[@daffodil/authorizenet] Update Payment Success";
20
+ DaffAuthorizeNetActionTypes["UpdatePaymentFailureAction"] = "[@daffodil/authorizenet] Update Payment Failure";
21
+ DaffAuthorizeNetActionTypes["ApplyPaymentAction"] = "[@daffodil/authorizenet] Apply Payment";
22
+ DaffAuthorizeNetActionTypes["LoadAcceptJsAction"] = "[@daffodil/authorizenet] Load Accept Js";
23
+ DaffAuthorizeNetActionTypes["LoadAcceptJsSuccessAction"] = "[@daffodil/authorizenet] Load Accept Js Success";
24
+ DaffAuthorizeNetActionTypes["LoadAcceptJsFailureAction"] = "[@daffodil/authorizenet] Load Accept Js Failure";
26
25
  })(DaffAuthorizeNetActionTypes || (DaffAuthorizeNetActionTypes = {}));
27
- /**
28
- * An action triggered to initialize a generate token request.
29
- *
30
- * @param payload - An DaffAuthorizeNetRequestData object.
31
- */
32
- class DaffAuthorizeNetUpdatePayment {
33
- constructor(tokenRequest, address) {
34
- this.tokenRequest = tokenRequest;
35
- this.address = address;
36
- this.type = DaffAuthorizeNetActionTypes.UpdatePaymentAction;
37
- }
38
- }
39
- /**
40
- * An action triggered upon successfully updating the payment method.
41
- *
42
- * @param payload - A string that is the payment nonce for a credit card.
43
- */
44
- class DaffAuthorizeNetUpdatePaymentSuccess {
45
- constructor() {
46
- this.type = DaffAuthorizeNetActionTypes.UpdatePaymentSuccessAction;
47
- }
48
- }
49
- /**
50
- * An action triggered upon failing to update the payment method.
51
- *
52
- * @param payload - A string that is an error message.
53
- */
54
- class DaffAuthorizeNetUpdatePaymentFailure {
55
- constructor(payload) {
56
- this.payload = payload;
57
- this.type = DaffAuthorizeNetActionTypes.UpdatePaymentFailureAction;
58
- }
59
- }
60
- class DaffLoadAcceptJs {
61
- constructor() {
62
- this.type = DaffAuthorizeNetActionTypes.LoadAcceptJsAction;
63
- }
64
- }
65
- /**
66
- * Indicates that the AcceptJs library has loaded successfully.
67
- */
68
- class DaffLoadAcceptJsSuccess {
69
- constructor() {
70
- this.type = DaffAuthorizeNetActionTypes.LoadAcceptJsSuccessAction;
71
- }
72
- }
73
- /**
74
- * Indicates that the AcceptJs library has failed to load
75
- */
76
- class DaffLoadAcceptJsFailure {
77
- constructor(payload) {
78
- this.payload = payload;
79
- this.type = DaffAuthorizeNetActionTypes.LoadAcceptJsFailureAction;
80
- }
81
- ;
82
- }
83
- /**
84
- * Triggers the application of an authorize.net payment.
85
- *
86
- * @role action
87
- */
88
- class DaffAuthorizenetApplyPayment {
89
- constructor(request, address) {
90
- this.request = request;
91
- this.address = address;
92
- this.type = DaffAuthorizeNetActionTypes.ApplyPaymentAction;
93
- }
94
- ;
95
- }
96
-
26
+ var DaffAuthorizeNetUpdatePayment = class {
27
+ constructor(tokenRequest, address) {
28
+ this.tokenRequest = tokenRequest;
29
+ this.address = address;
30
+ this.type = DaffAuthorizeNetActionTypes.UpdatePaymentAction;
31
+ }
32
+ };
33
+ var DaffAuthorizeNetUpdatePaymentSuccess = class {
34
+ constructor() {
35
+ this.type = DaffAuthorizeNetActionTypes.UpdatePaymentSuccessAction;
36
+ }
37
+ };
38
+ var DaffAuthorizeNetUpdatePaymentFailure = class {
39
+ constructor(payload) {
40
+ this.payload = payload;
41
+ this.type = DaffAuthorizeNetActionTypes.UpdatePaymentFailureAction;
42
+ }
43
+ };
44
+ var DaffLoadAcceptJs = class {
45
+ constructor() {
46
+ this.type = DaffAuthorizeNetActionTypes.LoadAcceptJsAction;
47
+ }
48
+ };
49
+ var DaffLoadAcceptJsSuccess = class {
50
+ constructor() {
51
+ this.type = DaffAuthorizeNetActionTypes.LoadAcceptJsSuccessAction;
52
+ }
53
+ };
54
+ var DaffLoadAcceptJsFailure = class {
55
+ constructor(payload) {
56
+ this.payload = payload;
57
+ this.type = DaffAuthorizeNetActionTypes.LoadAcceptJsFailureAction;
58
+ }
59
+ };
60
+ var DaffAuthorizenetApplyPayment = class {
61
+ constructor(request, address) {
62
+ this.request = request;
63
+ this.address = address;
64
+ this.type = DaffAuthorizeNetActionTypes.ApplyPaymentAction;
65
+ }
66
+ };
97
67
  const daffAuthorizeNetReducerInitialState = {
98
- isAcceptLoaded: false,
99
- paymentError: null,
100
- acceptJsLoadError: null,
101
- loading: false,
68
+ isAcceptLoaded: false,
69
+ paymentError: null,
70
+ acceptJsLoadError: null,
71
+ loading: false
102
72
  };
103
-
104
73
  function daffAuthorizeNetReducer(state = daffAuthorizeNetReducerInitialState, action) {
105
- switch (action.type) {
106
- case DaffAuthorizeNetActionTypes.UpdatePaymentAction:
107
- case DaffAuthorizeNetActionTypes.ApplyPaymentAction:
108
- return {
109
- ...state,
110
- loading: true,
111
- };
112
- case DaffAuthorizeNetActionTypes.UpdatePaymentSuccessAction:
113
- case DaffPaymentActionTypes.GenerateTokenSuccessAction:
114
- return {
115
- ...state,
116
- loading: false,
117
- paymentError: null,
118
- };
119
- case DaffAuthorizeNetActionTypes.UpdatePaymentFailureAction:
120
- case DaffPaymentActionTypes.GenerateTokenFailureAction:
121
- return {
122
- ...state,
123
- loading: false,
124
- paymentError: action.payload,
125
- };
126
- case DaffAuthorizeNetActionTypes.LoadAcceptJsSuccessAction:
127
- return {
128
- ...state,
129
- isAcceptLoaded: true,
130
- acceptJsLoadError: null,
131
- };
132
- case DaffAuthorizeNetActionTypes.LoadAcceptJsFailureAction:
133
- return {
134
- ...state,
135
- loading: false,
136
- acceptJsLoadError: action.payload,
137
- };
138
- default:
139
- return state;
140
- }
74
+ switch (action.type) {
75
+ case DaffAuthorizeNetActionTypes.UpdatePaymentAction:
76
+ case DaffAuthorizeNetActionTypes.ApplyPaymentAction: return {
77
+ ...state,
78
+ loading: true
79
+ };
80
+ case DaffAuthorizeNetActionTypes.UpdatePaymentSuccessAction:
81
+ case DaffPaymentActionTypes.GenerateTokenSuccessAction: return {
82
+ ...state,
83
+ loading: false,
84
+ paymentError: null
85
+ };
86
+ case DaffAuthorizeNetActionTypes.UpdatePaymentFailureAction:
87
+ case DaffPaymentActionTypes.GenerateTokenFailureAction: return {
88
+ ...state,
89
+ loading: false,
90
+ paymentError: action.payload
91
+ };
92
+ case DaffAuthorizeNetActionTypes.LoadAcceptJsSuccessAction: return {
93
+ ...state,
94
+ isAcceptLoaded: true,
95
+ acceptJsLoadError: null
96
+ };
97
+ case DaffAuthorizeNetActionTypes.LoadAcceptJsFailureAction: return {
98
+ ...state,
99
+ loading: false,
100
+ acceptJsLoadError: action.payload
101
+ };
102
+ default: return state;
103
+ }
141
104
  }
142
-
143
- const daffAuthorizeNetReducers = {
144
- authorizeNet: daffAuthorizeNetReducer,
145
- };
146
-
147
- const DAFF_AUTHORIZENET_STORE_FEATURE_KEY = 'daffAuthorizenet';
148
-
149
- const {
150
- /**
151
- * A token to hold the injectable extra reducers.
152
- *
153
- * Prefer using {@link daffAuthorizeNetProvideExtraReducers}.
154
- */
155
- token: DAFF_AUTHORIZE_NET_EXTRA_REDUCERS,
156
- /**
157
- * Provides additional reducers that run after the standard Daffodil authorizenet reducers.
158
- *
159
- * @example
160
- * ```ts
161
- * providers: [
162
- * ...daffAuthorizeNetProvideExtraReducers(
163
- * myReducer1,
164
- * myReducer2
165
- * )
166
- * ]
167
- * ```
168
- */
169
- provider: daffAuthorizeNetProvideExtraReducers, } = createMultiInjectionToken('DAFF_AUTHORIZE_NET_EXTRA_REDUCERS', { providedIn: 'any' });
170
-
105
+ const daffAuthorizeNetReducers = { authorizeNet: daffAuthorizeNetReducer };
106
+ const DAFF_AUTHORIZENET_STORE_FEATURE_KEY = "daffAuthorizenet";
107
+ const { token: DAFF_AUTHORIZE_NET_EXTRA_REDUCERS, provider: daffAuthorizeNetProvideExtraReducers } = createMultiInjectionToken("DAFF_AUTHORIZE_NET_EXTRA_REDUCERS", { providedIn: "any" });
171
108
  const createAuthorizeNetSelectors = () => {
172
- /**
173
- * AuthorizeNet Feature State
174
- */
175
- const selectAuthorizeNetFeatureState = createFeatureSelector(DAFF_AUTHORIZENET_STORE_FEATURE_KEY);
176
- /**
177
- * AuthorizeNet State
178
- */
179
- const selectAuthorizeNetState = createSelector(selectAuthorizeNetFeatureState, (state) => state.authorizeNet);
180
- /**
181
- * AuthorizeNet loading state
182
- */
183
- const selectLoading = createSelector(selectAuthorizeNetState, (state) => state.loading);
184
- /**
185
- * AuthorizeNet payment error
186
- */
187
- const selectPaymentError = createSelector(selectAuthorizeNetState, (state) => state.paymentError);
188
- /**
189
- * AcceptJs load error
190
- */
191
- const selectAcceptJsLoadError = createSelector(selectAuthorizeNetState, (state) => state.acceptJsLoadError);
192
- /**
193
- * AcceptJs is loaded
194
- */
195
- const selectIsAcceptJsLoaded = createSelector(selectAuthorizeNetState, (state) => state.isAcceptLoaded);
196
- return {
197
- selectAuthorizeNetFeatureState,
198
- selectAuthorizeNetState,
199
- selectLoading,
200
- selectPaymentError,
201
- selectAcceptJsLoadError,
202
- selectIsAcceptJsLoaded,
203
- };
109
+ const selectAuthorizeNetFeatureState = createFeatureSelector(DAFF_AUTHORIZENET_STORE_FEATURE_KEY);
110
+ const selectAuthorizeNetState = createSelector(selectAuthorizeNetFeatureState, (state) => state.authorizeNet);
111
+ return {
112
+ selectAuthorizeNetFeatureState,
113
+ selectAuthorizeNetState,
114
+ selectLoading: createSelector(selectAuthorizeNetState, (state) => state.loading),
115
+ selectPaymentError: createSelector(selectAuthorizeNetState, (state) => state.paymentError),
116
+ selectAcceptJsLoadError: createSelector(selectAuthorizeNetState, (state) => state.acceptJsLoadError),
117
+ selectIsAcceptJsLoaded: createSelector(selectAuthorizeNetState, (state) => state.isAcceptLoaded)
118
+ };
204
119
  };
205
120
  const daffAuthorizeNetSelectors = defaultMemoize(() => createAuthorizeNetSelectors()).memoized;
206
-
207
121
  const daffAuthorizeNetStateDefaultConfig = {
208
- acceptMaxRetries: 5,
209
- acceptBackoffTiming: 30,
122
+ acceptMaxRetries: 5,
123
+ acceptBackoffTiming: 30
210
124
  };
211
-
212
- const { token: DAFF_AUTHORIZE_NET_STATE_CONFIG,
213
- /**
214
- * Provider function for {@link DAFF_AUTHORIZE_NET_STATE_CONFIG}.
215
- */
216
- provider: provideDaffAuthorizeNetStateConfig, } = createConfigInjectionToken(daffAuthorizeNetStateDefaultConfig, 'DAFF_AUTHORIZE_NET_STATE_CONFIG');
217
-
218
- /**
219
- * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
220
- * Can be used to further refine Daffodil errors into more specific app errors.
221
- */
222
- const { token: DAFF_AUTHORIZENET_ERROR_MATCHER,
223
- /**
224
- * Provider function for {@link DAFF_AUTHORIZENET_ERROR_MATCHER}.
225
- */
226
- provider: provideDaffAuthorizenetErrorMatcher, } = createSingleInjectionToken('DAFF_AUTHORIZENET_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
227
-
228
- class DaffAuthorizeNetFacade {
229
- constructor(store) {
230
- this.store = store;
231
- const { selectIsAcceptJsLoaded, selectLoading, selectPaymentError, selectAcceptJsLoadError, } = daffAuthorizeNetSelectors();
232
- this.isAcceptJsLoaded$ = this.store.pipe(select(selectIsAcceptJsLoaded));
233
- this.loading$ = this.store.pipe(select(selectLoading));
234
- this.paymentError$ = this.store.pipe(select(selectPaymentError));
235
- this.acceptJsLoadError$ = this.store.pipe(select(selectAcceptJsLoadError));
236
- }
237
- dispatch(action) {
238
- this.store.dispatch(action);
239
- }
240
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetFacade, deps: [{ token: i1.Store }], target: i0.ɵɵFactoryTarget.Injectable }); }
241
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetFacade, providedIn: 'root' }); }
242
- }
243
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetFacade, decorators: [{
244
- type: Injectable,
245
- args: [{
246
- providedIn: 'root',
247
- }]
248
- }], ctorParameters: () => [{ type: i1.Store }] });
249
-
250
- class DaffAuthorizeNetEffects {
251
- constructor(actions$, driver, authorizeNetPaymentId, errorMatcher, config, acceptJsLoadingService) {
252
- this.actions$ = actions$;
253
- this.driver = driver;
254
- this.authorizeNetPaymentId = authorizeNetPaymentId;
255
- this.errorMatcher = errorMatcher;
256
- this.config = config;
257
- this.acceptJsLoadingService = acceptJsLoadingService;
258
- this.updatePayment$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthorizeNetActionTypes.UpdatePaymentAction), switchMap((action) => this.driver.generateToken(action.tokenRequest).pipe(map(resp => new DaffCartPaymentUpdateWithBilling({
259
- method: this.authorizeNetPaymentId,
260
- payment_info: resp,
261
- }, action.address)), catchError((error) => of(new DaffAuthorizeNetUpdatePaymentFailure(this.errorMatcher(error))))))));
262
- this.updatePaymentSuccessSubstream$ = createEffect(() => this.actions$.pipe(substream([DaffAuthorizeNetActionTypes.UpdatePaymentAction, DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingSuccessAction], DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingFailureAction), map(() => new DaffAuthorizeNetUpdatePaymentSuccess())));
263
- this.updatePaymentFailureSubstream$ = createEffect(() => this.actions$.pipe(substream([DaffAuthorizeNetActionTypes.UpdatePaymentAction, DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingFailureAction], DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingSuccessAction), map(([updatePaymentAction, updatePaymentFailureAction]) => new DaffAuthorizeNetUpdatePaymentFailure(this.errorMatcher(updatePaymentFailureAction.payload[0])))));
264
- this.loadAcceptJs$ = createEffect(() => (maxTries = this.config.acceptMaxRetries, ms = this.config.acceptBackoffTiming) => this.actions$.pipe(ofType(DaffAuthorizeNetActionTypes.LoadAcceptJsAction), tap((action) => this.acceptJsLoadingService.load()), switchMap(() => defer(() => of(this.acceptJsLoadingService.getAccept())).pipe(backoff(maxTries, ms), map((Accept) => Accept ? new DaffLoadAcceptJsSuccess() : new DaffLoadAcceptJsFailure(new DaffAuthorizeNetAcceptjsMissingError('Accept.js failed to load.'))), catchError((error) => of(new DaffLoadAcceptJsFailure(this.errorMatcher(error))))))));
265
- }
266
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetEffects, deps: [{ token: i1$1.Actions }, { token: DaffAuthorizeNetDriver }, { token: DaffAuthorizeNetPaymentId }, { token: DAFF_AUTHORIZENET_ERROR_MATCHER }, { token: DAFF_AUTHORIZE_NET_STATE_CONFIG }, { token: i2.DaffAcceptJsLoadingService }], target: i0.ɵɵFactoryTarget.Injectable }); }
267
- /** @nocollapse */ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetEffects }); }
268
- }
269
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetEffects, decorators: [{
270
- type: Injectable
271
- }], ctorParameters: () => [{ type: i1$1.Actions }, { type: undefined, decorators: [{
272
- type: Inject,
273
- args: [DaffAuthorizeNetDriver]
274
- }] }, { type: undefined, decorators: [{
275
- type: Inject,
276
- args: [DaffAuthorizeNetPaymentId]
277
- }] }, { type: undefined, decorators: [{
278
- type: Inject,
279
- args: [DAFF_AUTHORIZENET_ERROR_MATCHER]
280
- }] }, { type: undefined, decorators: [{
281
- type: Inject,
282
- args: [DAFF_AUTHORIZE_NET_STATE_CONFIG]
283
- }] }, { type: i2.DaffAcceptJsLoadingService }] });
284
-
285
- const {
286
- /**
287
- * An internal token to hold the Daffodil authorizenet reducers.
288
- * Includes the extra and standard reducers.
289
- *
290
- * @docs-private
291
- */
292
- token: DAFF_AUTHORIZE_NET_REDUCERS,
293
- /**
294
- * Provider function for {@link DAFF_AUTHORIZE_NET_REDUCERS}.
295
- */
296
- provider: provideDaffAuthorizeNetReducers, } = createSingleInjectionToken('DAFF_AUTHORIZE_NET_REDUCERS', {
297
- providedIn: 'any',
298
- factory: () => daffComposeReducers([
299
- combineReducers({
300
- authorizeNet: daffAuthorizeNetReducer,
301
- }),
302
- ...inject(DAFF_AUTHORIZE_NET_EXTRA_REDUCERS),
303
- ]),
125
+ const { token: DAFF_AUTHORIZE_NET_STATE_CONFIG, provider: provideDaffAuthorizeNetStateConfig } = createConfigInjectionToken(daffAuthorizeNetStateDefaultConfig, "DAFF_AUTHORIZE_NET_STATE_CONFIG");
126
+ const { token: DAFF_AUTHORIZENET_ERROR_MATCHER, provider: provideDaffAuthorizenetErrorMatcher } = createSingleInjectionToken("DAFF_AUTHORIZENET_ERROR_MATCHER", { factory: () => daffTransformErrorToStateError });
127
+ var DaffAuthorizeNetFacade = class DaffAuthorizeNetFacade {
128
+ constructor(store) {
129
+ this.store = store;
130
+ const { selectIsAcceptJsLoaded, selectLoading, selectPaymentError, selectAcceptJsLoadError } = daffAuthorizeNetSelectors();
131
+ this.isAcceptJsLoaded$ = this.store.pipe(select(selectIsAcceptJsLoaded));
132
+ this.loading$ = this.store.pipe(select(selectLoading));
133
+ this.paymentError$ = this.store.pipe(select(selectPaymentError));
134
+ this.acceptJsLoadError$ = this.store.pipe(select(selectAcceptJsLoadError));
135
+ }
136
+ dispatch(action) {
137
+ this.store.dispatch(action);
138
+ }
139
+ static {
140
+ this.ɵfac = i0.ɵɵngDeclareFactory({
141
+ minVersion: "12.0.0",
142
+ version: "22.2.4",
143
+ ngImport: i0,
144
+ type: DaffAuthorizeNetFacade,
145
+ deps: [{ token: i1$1.Store }],
146
+ target: i0.ɵɵFactoryTarget.Injectable
147
+ });
148
+ }
149
+ static {
150
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
151
+ minVersion: "12.0.0",
152
+ version: "22.2.4",
153
+ ngImport: i0,
154
+ type: DaffAuthorizeNetFacade,
155
+ providedIn: "root"
156
+ });
157
+ }
158
+ };
159
+ i0.ɵɵngDeclareClassMetadata({
160
+ minVersion: "12.0.0",
161
+ version: "22.2.4",
162
+ ngImport: i0,
163
+ type: DaffAuthorizeNetFacade,
164
+ decorators: [{
165
+ type: Injectable,
166
+ args: [{ providedIn: "root" }]
167
+ }],
168
+ ctorParameters: () => [{ type: i1$1.Store }]
304
169
  });
170
+ var DaffAuthorizeNetEffects = class DaffAuthorizeNetEffects {
171
+ constructor(actions$, driver, authorizeNetPaymentId, errorMatcher, config, acceptJsLoadingService) {
172
+ this.actions$ = actions$;
173
+ this.driver = driver;
174
+ this.authorizeNetPaymentId = authorizeNetPaymentId;
175
+ this.errorMatcher = errorMatcher;
176
+ this.config = config;
177
+ this.acceptJsLoadingService = acceptJsLoadingService;
178
+ this.updatePayment$ = createEffect(() => this.actions$.pipe(ofType(DaffAuthorizeNetActionTypes.UpdatePaymentAction), switchMap((action) => this.driver.generateToken(action.tokenRequest).pipe(map((resp) => new DaffCartPaymentUpdateWithBilling({
179
+ method: this.authorizeNetPaymentId,
180
+ payment_info: resp
181
+ }, action.address)), catchError((error) => of(new DaffAuthorizeNetUpdatePaymentFailure(this.errorMatcher(error))))))));
182
+ this.updatePaymentSuccessSubstream$ = createEffect(() => this.actions$.pipe(substream([DaffAuthorizeNetActionTypes.UpdatePaymentAction, DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingSuccessAction], DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingFailureAction), map(() => new DaffAuthorizeNetUpdatePaymentSuccess())));
183
+ this.updatePaymentFailureSubstream$ = createEffect(() => this.actions$.pipe(substream([DaffAuthorizeNetActionTypes.UpdatePaymentAction, DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingFailureAction], DaffCartPaymentActionTypes.CartPaymentUpdateWithBillingSuccessAction), map(([updatePaymentAction, updatePaymentFailureAction]) => new DaffAuthorizeNetUpdatePaymentFailure(this.errorMatcher(updatePaymentFailureAction.payload[0])))));
184
+ this.loadAcceptJs$ = createEffect(() => (maxTries = this.config.acceptMaxRetries, ms = this.config.acceptBackoffTiming) => this.actions$.pipe(ofType(DaffAuthorizeNetActionTypes.LoadAcceptJsAction), tap((action) => this.acceptJsLoadingService.load()), switchMap(() => defer(() => of(this.acceptJsLoadingService.getAccept())).pipe(backoff(maxTries, ms), map((Accept) => Accept ? new DaffLoadAcceptJsSuccess() : new DaffLoadAcceptJsFailure(new DaffAuthorizeNetAcceptjsMissingError("Accept.js failed to load."))), catchError((error) => of(new DaffLoadAcceptJsFailure(this.errorMatcher(error))))))));
185
+ }
186
+ static {
187
+ this.ɵfac = i0.ɵɵngDeclareFactory({
188
+ minVersion: "12.0.0",
189
+ version: "22.2.4",
190
+ ngImport: i0,
191
+ type: DaffAuthorizeNetEffects,
192
+ deps: [
193
+ { token: i1.Actions },
194
+ { token: DaffAuthorizeNetDriver },
195
+ { token: DaffAuthorizeNetPaymentId },
196
+ { token: DAFF_AUTHORIZENET_ERROR_MATCHER },
197
+ { token: DAFF_AUTHORIZE_NET_STATE_CONFIG },
198
+ { token: i2.DaffAcceptJsLoadingService }
199
+ ],
200
+ target: i0.ɵɵFactoryTarget.Injectable
201
+ });
202
+ }
203
+ static {
204
+ this.ɵprov = i0.ɵɵngDeclareInjectable({
205
+ minVersion: "12.0.0",
206
+ version: "22.2.4",
207
+ ngImport: i0,
208
+ type: DaffAuthorizeNetEffects
209
+ });
210
+ }
211
+ };
212
+ i0.ɵɵngDeclareClassMetadata({
213
+ minVersion: "12.0.0",
214
+ version: "22.2.4",
215
+ ngImport: i0,
216
+ type: DaffAuthorizeNetEffects,
217
+ decorators: [{ type: Injectable }],
218
+ ctorParameters: () => [
219
+ { type: i1.Actions },
220
+ {
221
+ type: void 0,
222
+ decorators: [{
223
+ type: Inject,
224
+ args: [DaffAuthorizeNetDriver]
225
+ }]
226
+ },
227
+ {
228
+ type: void 0,
229
+ decorators: [{
230
+ type: Inject,
231
+ args: [DaffAuthorizeNetPaymentId]
232
+ }]
233
+ },
234
+ {
235
+ type: void 0,
236
+ decorators: [{
237
+ type: Inject,
238
+ args: [DAFF_AUTHORIZENET_ERROR_MATCHER]
239
+ }]
240
+ },
241
+ {
242
+ type: void 0,
243
+ decorators: [{
244
+ type: Inject,
245
+ args: [DAFF_AUTHORIZE_NET_STATE_CONFIG]
246
+ }]
247
+ },
248
+ { type: i2.DaffAcceptJsLoadingService }
249
+ ]
250
+ });
251
+ const { token: DAFF_AUTHORIZE_NET_REDUCERS, provider: provideDaffAuthorizeNetReducers, factoryProvider: provideDaffAuthorizeNetReducersFactory } = createSingleInjectionToken("DAFF_AUTHORIZE_NET_REDUCERS");
252
+ var DaffAuthorizeNetStateModule = class DaffAuthorizeNetStateModule {
253
+ static withConfig(config = {}) {
254
+ return {
255
+ ngModule: DaffAuthorizeNetStateModule,
256
+ providers: [provideDaffAuthorizeNetStateConfig({
257
+ ...daffAuthorizeNetStateDefaultConfig,
258
+ ...config
259
+ })]
260
+ };
261
+ }
262
+ static {
263
+ this.ɵfac = i0.ɵɵngDeclareFactory({
264
+ minVersion: "12.0.0",
265
+ version: "22.2.4",
266
+ ngImport: i0,
267
+ type: DaffAuthorizeNetStateModule,
268
+ deps: [],
269
+ target: i0.ɵɵFactoryTarget.NgModule
270
+ });
271
+ }
272
+ static {
273
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
274
+ minVersion: "14.0.0",
275
+ version: "22.2.4",
276
+ ngImport: i0,
277
+ type: DaffAuthorizeNetStateModule,
278
+ imports: [i1$1.StoreFeatureModule, i1.EffectsFeatureModule]
279
+ });
280
+ }
281
+ static {
282
+ this.ɵinj = i0.ɵɵngDeclareInjector({
283
+ minVersion: "12.0.0",
284
+ version: "22.2.4",
285
+ ngImport: i0,
286
+ type: DaffAuthorizeNetStateModule,
287
+ providers: [provideDaffAuthorizeNetStateConfig(daffAuthorizeNetStateDefaultConfig), provideDaffAuthorizeNetReducersFactory((() => daffComposeReducers([combineReducers({ authorizeNet: daffAuthorizeNetReducer }), ...inject(DAFF_AUTHORIZE_NET_EXTRA_REDUCERS)])))],
288
+ imports: [StoreModule.forFeature(DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_REDUCERS), EffectsModule.forFeature([DaffAuthorizeNetEffects])]
289
+ });
290
+ }
291
+ };
292
+ i0.ɵɵngDeclareClassMetadata({
293
+ minVersion: "12.0.0",
294
+ version: "22.2.4",
295
+ ngImport: i0,
296
+ type: DaffAuthorizeNetStateModule,
297
+ decorators: [{
298
+ type: NgModule,
299
+ args: [{
300
+ imports: [StoreModule.forFeature(DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_REDUCERS), EffectsModule.forFeature([DaffAuthorizeNetEffects])],
301
+ providers: [provideDaffAuthorizeNetStateConfig(daffAuthorizeNetStateDefaultConfig), provideDaffAuthorizeNetReducersFactory((() => daffComposeReducers([combineReducers({ authorizeNet: daffAuthorizeNetReducer }), ...inject(DAFF_AUTHORIZE_NET_EXTRA_REDUCERS)])))]
302
+ }]
303
+ }]
304
+ });
305
+ var DaffAuthorizeNetPaymentStateModule = class DaffAuthorizeNetPaymentStateModule {
306
+ static {
307
+ this.ɵfac = i0.ɵɵngDeclareFactory({
308
+ minVersion: "12.0.0",
309
+ version: "22.2.4",
310
+ ngImport: i0,
311
+ type: DaffAuthorizeNetPaymentStateModule,
312
+ deps: [],
313
+ target: i0.ɵɵFactoryTarget.NgModule
314
+ });
315
+ }
316
+ static {
317
+ this.ɵmod = i0.ɵɵngDeclareNgModule({
318
+ minVersion: "14.0.0",
319
+ version: "22.2.4",
320
+ ngImport: i0,
321
+ type: DaffAuthorizeNetPaymentStateModule,
322
+ imports: [DaffPaymentStateModule]
323
+ });
324
+ }
325
+ static {
326
+ this.ɵinj = i0.ɵɵngDeclareInjector({
327
+ minVersion: "12.0.0",
328
+ version: "22.2.4",
329
+ ngImport: i0,
330
+ type: DaffAuthorizeNetPaymentStateModule,
331
+ providers: [daffPaymentProvideAvailableProcessors({
332
+ kind: DAFF_AUTHORIZENET_PAYMENT_KIND,
333
+ action: DaffAuthorizeNetActionTypes.ApplyPaymentAction,
334
+ driver: DaffAuthorizeNetPaymentDriver
335
+ }), ...daffPaymentProvideExtraReducers(combineReducers({ payment: daffPaymentReducerFactory([DaffAuthorizeNetActionTypes.ApplyPaymentAction]) }))],
336
+ imports: [DaffPaymentStateModule]
337
+ });
338
+ }
339
+ };
340
+ i0.ɵɵngDeclareClassMetadata({
341
+ minVersion: "12.0.0",
342
+ version: "22.2.4",
343
+ ngImport: i0,
344
+ type: DaffAuthorizeNetPaymentStateModule,
345
+ decorators: [{
346
+ type: NgModule,
347
+ args: [{
348
+ imports: [DaffPaymentStateModule],
349
+ providers: [daffPaymentProvideAvailableProcessors({
350
+ kind: DAFF_AUTHORIZENET_PAYMENT_KIND,
351
+ action: DaffAuthorizeNetActionTypes.ApplyPaymentAction,
352
+ driver: DaffAuthorizeNetPaymentDriver
353
+ }), ...daffPaymentProvideExtraReducers(combineReducers({ payment: daffPaymentReducerFactory([DaffAuthorizeNetActionTypes.ApplyPaymentAction]) }))]
354
+ }]
355
+ }]
356
+ });
357
+ const provideDaffAuthorizeNetState = (config = {}) => makeEnvironmentProviders([
358
+ provideState(DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_REDUCERS),
359
+ provideEffects(DaffAuthorizeNetEffects),
360
+ provideDaffAuthorizeNetStateConfig({
361
+ ...daffAuthorizeNetStateDefaultConfig,
362
+ ...config
363
+ }),
364
+ provideDaffAuthorizeNetReducersFactory(() => daffComposeReducers([combineReducers({ authorizeNet: daffAuthorizeNetReducer }), ...inject(DAFF_AUTHORIZE_NET_EXTRA_REDUCERS)]))
365
+ ]);
366
+ const provideDaffAuthorizeNetPaymentState = () => makeEnvironmentProviders([
367
+ provideDaffPaymentState(),
368
+ daffPaymentProvideAvailableProcessors({
369
+ kind: DAFF_AUTHORIZENET_PAYMENT_KIND,
370
+ action: DaffAuthorizeNetActionTypes.ApplyPaymentAction,
371
+ driver: DaffAuthorizeNetPaymentDriver
372
+ }),
373
+ ...daffPaymentProvideExtraReducers(combineReducers({ payment: daffPaymentReducerFactory([DaffAuthorizeNetActionTypes.ApplyPaymentAction]) }))
374
+ ]);
375
+ export { DAFF_AUTHORIZENET_ERROR_MATCHER, DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_EXTRA_REDUCERS, DAFF_AUTHORIZE_NET_STATE_CONFIG, DaffAuthorizeNetActionTypes, DaffAuthorizeNetFacade, DaffAuthorizeNetPaymentStateModule, DaffAuthorizeNetStateModule, DaffAuthorizeNetUpdatePayment, DaffAuthorizeNetUpdatePaymentFailure, DaffAuthorizeNetUpdatePaymentSuccess, DaffAuthorizenetApplyPayment, DaffLoadAcceptJs, DaffLoadAcceptJsFailure, DaffLoadAcceptJsSuccess, daffAuthorizeNetProvideExtraReducers, daffAuthorizeNetReducer, daffAuthorizeNetReducerInitialState, daffAuthorizeNetReducers, daffAuthorizeNetSelectors, daffAuthorizeNetStateDefaultConfig, provideDaffAuthorizeNetPaymentState, provideDaffAuthorizeNetState, provideDaffAuthorizeNetStateConfig, provideDaffAuthorizenetErrorMatcher };
305
376
 
306
- class DaffAuthorizeNetStateModule {
307
- static withConfig(config = {}) {
308
- return {
309
- ngModule: DaffAuthorizeNetStateModule,
310
- providers: [
311
- provideDaffAuthorizeNetStateConfig({
312
- ...daffAuthorizeNetStateDefaultConfig,
313
- ...config,
314
- }),
315
- ],
316
- };
317
- }
318
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
319
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetStateModule, imports: [i1.StoreFeatureModule, i1$1.EffectsFeatureModule] }); }
320
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetStateModule, providers: [
321
- provideDaffAuthorizeNetStateConfig(daffAuthorizeNetStateDefaultConfig),
322
- ], imports: [StoreModule.forFeature(DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_REDUCERS),
323
- EffectsModule.forFeature([DaffAuthorizeNetEffects])] }); }
324
- }
325
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetStateModule, decorators: [{
326
- type: NgModule,
327
- args: [{
328
- imports: [
329
- StoreModule.forFeature(DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_REDUCERS),
330
- EffectsModule.forFeature([DaffAuthorizeNetEffects]),
331
- ],
332
- providers: [
333
- provideDaffAuthorizeNetStateConfig(daffAuthorizeNetStateDefaultConfig),
334
- ],
335
- }]
336
- }] });
337
-
338
- class DaffAuthorizeNetPaymentStateModule {
339
- /** @nocollapse */ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetPaymentStateModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
340
- /** @nocollapse */ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetPaymentStateModule, imports: [DaffPaymentStateModule] }); }
341
- /** @nocollapse */ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetPaymentStateModule, providers: [
342
- daffPaymentProvideAvailableProcessors({
343
- kind: DAFF_AUTHORIZENET_PAYMENT_KIND,
344
- action: DaffAuthorizeNetActionTypes.ApplyPaymentAction,
345
- driver: DaffAuthorizeNetPaymentDriver,
346
- }),
347
- ...daffPaymentProvideExtraReducers(combineReducers({
348
- payment: daffPaymentReducerFactory([DaffAuthorizeNetActionTypes.ApplyPaymentAction]),
349
- })),
350
- ], imports: [DaffPaymentStateModule] }); }
351
- }
352
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.9", ngImport: i0, type: DaffAuthorizeNetPaymentStateModule, decorators: [{
353
- type: NgModule,
354
- args: [{
355
- imports: [
356
- DaffPaymentStateModule,
357
- ],
358
- providers: [
359
- daffPaymentProvideAvailableProcessors({
360
- kind: DAFF_AUTHORIZENET_PAYMENT_KIND,
361
- action: DaffAuthorizeNetActionTypes.ApplyPaymentAction,
362
- driver: DaffAuthorizeNetPaymentDriver,
363
- }),
364
- ...daffPaymentProvideExtraReducers(combineReducers({
365
- payment: daffPaymentReducerFactory([DaffAuthorizeNetActionTypes.ApplyPaymentAction]),
366
- })),
367
- ],
368
- }]
369
- }] });
370
-
371
- /**
372
- * Generated bundle index. Do not edit.
373
- */
374
-
375
- export { DAFF_AUTHORIZENET_ERROR_MATCHER, DAFF_AUTHORIZENET_STORE_FEATURE_KEY, DAFF_AUTHORIZE_NET_EXTRA_REDUCERS, DAFF_AUTHORIZE_NET_STATE_CONFIG, DaffAuthorizeNetActionTypes, DaffAuthorizeNetFacade, DaffAuthorizeNetPaymentStateModule, DaffAuthorizeNetStateModule, DaffAuthorizeNetUpdatePayment, DaffAuthorizeNetUpdatePaymentFailure, DaffAuthorizeNetUpdatePaymentSuccess, DaffAuthorizenetApplyPayment, DaffLoadAcceptJs, DaffLoadAcceptJsFailure, DaffLoadAcceptJsSuccess, daffAuthorizeNetProvideExtraReducers, daffAuthorizeNetReducer, daffAuthorizeNetReducerInitialState, daffAuthorizeNetReducers, daffAuthorizeNetSelectors, daffAuthorizeNetStateDefaultConfig, provideDaffAuthorizeNetStateConfig, provideDaffAuthorizenetErrorMatcher };
376
- //# sourceMappingURL=daffodil-authorizenet-state.mjs.map
377
+ //# sourceMappingURL=daffodil-authorizenet-state.mjs.map