@daffodil/payment 0.88.1 → 0.89.0

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 (75) hide show
  1. package/driver/in-memory/index.d.ts +69 -1
  2. package/driver/index.d.ts +36 -1
  3. package/driver/testing/index.d.ts +33 -1
  4. package/fesm2022/daffodil-payment-driver-in-memory.mjs +10 -10
  5. package/fesm2022/daffodil-payment-driver-in-memory.mjs.map +1 -1
  6. package/fesm2022/daffodil-payment-driver-testing.mjs +7 -7
  7. package/fesm2022/daffodil-payment-driver-testing.mjs.map +1 -1
  8. package/fesm2022/daffodil-payment-driver.mjs.map +1 -1
  9. package/fesm2022/daffodil-payment-state-testing.mjs +7 -7
  10. package/fesm2022/daffodil-payment-state-testing.mjs.map +1 -1
  11. package/fesm2022/daffodil-payment-state.mjs +7 -7
  12. package/fesm2022/daffodil-payment-state.mjs.map +1 -1
  13. package/fesm2022/daffodil-payment-testing.mjs +13 -13
  14. package/fesm2022/daffodil-payment-testing.mjs.map +1 -1
  15. package/index.d.ts +30 -1
  16. package/package.json +1 -1
  17. package/state/index.d.ts +204 -1
  18. package/state/testing/index.d.ts +29 -1
  19. package/testing/index.d.ts +64 -1
  20. package/driver/errors/invalid-api-response.d.ts +0 -10
  21. package/driver/errors/map.d.ts +0 -7
  22. package/driver/errors/public_api.d.ts +0 -2
  23. package/driver/in-memory/backend/payment.service.d.ts +0 -35
  24. package/driver/in-memory/collection-name.const.d.ts +0 -1
  25. package/driver/in-memory/driver/payment-driver.module.d.ts +0 -13
  26. package/driver/in-memory/driver/payment.service.d.ts +0 -19
  27. package/driver/in-memory/public_api.d.ts +0 -3
  28. package/driver/interfaces/payment-service.interface.d.ts +0 -12
  29. package/driver/public_api.d.ts +0 -2
  30. package/driver/testing/drivers/payment-driver.module.d.ts +0 -12
  31. package/driver/testing/drivers/payment.service.d.ts +0 -18
  32. package/driver/testing/drivers/public_api.d.ts +0 -2
  33. package/driver/testing/public_api.d.ts +0 -1
  34. package/models/public_api.d.ts +0 -2
  35. package/models/request.type.d.ts +0 -13
  36. package/models/response.type.d.ts +0 -14
  37. package/public_api.d.ts +0 -1
  38. package/state/actions/payment.actions.d.ts +0 -43
  39. package/state/facades/payment/facade.d.ts +0 -21
  40. package/state/facades/payment/interface.d.ts +0 -16
  41. package/state/facades/public_api.d.ts +0 -2
  42. package/state/injection-tokens/available-processors.token.d.ts +0 -2
  43. package/state/injection-tokens/error-matcher.token.d.ts +0 -2
  44. package/state/injection-tokens/processor-collection.token.d.ts +0 -2
  45. package/state/injection-tokens/public_api.d.ts +0 -3
  46. package/state/models/available-processor.type.d.ts +0 -21
  47. package/state/models/processor-collection.type.d.ts +0 -5
  48. package/state/models/public_api.d.ts +0 -2
  49. package/state/payment.module.d.ts +0 -10
  50. package/state/public_api.d.ts +0 -7
  51. package/state/reducers/payment/adapter.d.ts +0 -21
  52. package/state/reducers/payment/initial-state.d.ts +0 -5
  53. package/state/reducers/payment/interface.d.ts +0 -15
  54. package/state/reducers/payment/public_api.d.ts +0 -4
  55. package/state/reducers/payment/reducer.d.ts +0 -7
  56. package/state/reducers/public_api.d.ts +0 -4
  57. package/state/reducers/reducers.interface.d.ts +0 -14
  58. package/state/reducers/store-feature-key.d.ts +0 -4
  59. package/state/reducers/token/extra.token.d.ts +0 -3
  60. package/state/reducers/token/public_api.d.ts +0 -1
  61. package/state/reducers/token/reducers.token.d.ts +0 -3
  62. package/state/selectors/feature.selector.d.ts +0 -9
  63. package/state/selectors/payment.selector.d.ts +0 -17
  64. package/state/selectors/public_api.d.ts +0 -1
  65. package/state/testing/mock-payment-facade.d.ts +0 -17
  66. package/state/testing/payment-testing.module.d.ts +0 -9
  67. package/state/testing/public_api.d.ts +0 -2
  68. package/testing/factories/kind.factory.d.ts +0 -18
  69. package/testing/factories/payment-request.factory.d.ts +0 -17
  70. package/testing/factories/payment-response.factory.d.ts +0 -17
  71. package/testing/factories/public_api.d.ts +0 -3
  72. package/testing/injection-tokens/factories/kind.token.d.ts +0 -3
  73. package/testing/injection-tokens/public_api.d.ts +0 -1
  74. package/testing/public_api.d.ts +0 -3
  75. package/testing/testing.module.d.ts +0 -9
package/index.d.ts CHANGED
@@ -1 +1,30 @@
1
- export * from './public_api';
1
+ /**
2
+ * A payment request that can be used to generate a token or additional data for use with an ecommerce platform.
3
+ */
4
+ interface DaffPaymentRequest<T = unknown> {
5
+ /**
6
+ * The payment kind. A constant identifying the payment processor and payment method.
7
+ */
8
+ kind: string;
9
+ /**
10
+ * The payment data that will be used to generate a payment token or additional data.
11
+ */
12
+ data?: T;
13
+ }
14
+
15
+ /**
16
+ * A payment response that can be sent to an ecommerce platform to set payment information for the provided method.
17
+ */
18
+ interface DaffPaymentResponse<T = unknown> {
19
+ /**
20
+ * The payment method.
21
+ * This can be specific to the platform in use and should not be considered a constant.
22
+ */
23
+ method: string;
24
+ /**
25
+ * The payment data that represents validated payment information.
26
+ */
27
+ data?: T;
28
+ }
29
+
30
+ export type { DaffPaymentRequest, DaffPaymentResponse };
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@daffodil/payment","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/payment"]}}},"version":"0.88.1","description":"A client-side Angular package for managing ecommerce payments agnostic to the ecommerce platform.","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/common":"^19.0.0","@angular/core":"^19.0.0","@daffodil/core":"0.88.1","@ngrx/effects":"^19.0.0","@ngrx/store":"^19.0.0","rxjs":"7.8.1"},"optionalDependencies":{"@apollo/client":"^3.12.6","@daffodil/driver":"0.88.1","apollo-angular":"^10.0.3","@faker-js/faker":"^9.8.0"},"module":"fesm2022/daffodil-payment.mjs","typings":"index.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./index.d.ts","default":"./fesm2022/daffodil-payment.mjs"},"./driver":{"types":"./driver/index.d.ts","default":"./fesm2022/daffodil-payment-driver.mjs"},"./state":{"types":"./state/index.d.ts","default":"./fesm2022/daffodil-payment-state.mjs"},"./testing":{"types":"./testing/index.d.ts","default":"./fesm2022/daffodil-payment-testing.mjs"},"./driver/in-memory":{"types":"./driver/in-memory/index.d.ts","default":"./fesm2022/daffodil-payment-driver-in-memory.mjs"},"./driver/testing":{"types":"./driver/testing/index.d.ts","default":"./fesm2022/daffodil-payment-driver-testing.mjs"},"./state/testing":{"types":"./state/testing/index.d.ts","default":"./fesm2022/daffodil-payment-state-testing.mjs"}},"sideEffects":false,"dependencies":{"tslib":"^2.3.0"}}
1
+ {"name":"@daffodil/payment","nx":{"targets":{"build":{"outputs":["{workspaceRoot}/dist/payment"]}}},"version":"0.89.0","description":"A client-side Angular package for managing ecommerce payments agnostic to the ecommerce platform.","repository":{"type":"git","url":"https://github.com/graycoreio/daffodil"},"author":"Graycore LLC","license":"MIT","bugs":{"url":"https://github.com/graycoreio/daffodil/issues"},"homepage":"https://github.com/graycoreio/daffodil","peerDependencies":{"@angular/common":"^20.0.0","@angular/core":"^20.0.0","@daffodil/core":"0.89.0","@ngrx/effects":"^20.0.0","@ngrx/store":"^20.0.0","rxjs":"7.8.1"},"optionalDependencies":{"@apollo/client":"^3.12.6","@daffodil/driver":"0.89.0","apollo-angular":"^11.0.0","@faker-js/faker":"^9.8.0"},"module":"fesm2022/daffodil-payment.mjs","typings":"index.d.ts","exports":{"./package.json":{"default":"./package.json"},".":{"types":"./index.d.ts","default":"./fesm2022/daffodil-payment.mjs"},"./driver":{"types":"./driver/index.d.ts","default":"./fesm2022/daffodil-payment-driver.mjs"},"./state":{"types":"./state/index.d.ts","default":"./fesm2022/daffodil-payment-state.mjs"},"./testing":{"types":"./testing/index.d.ts","default":"./fesm2022/daffodil-payment-testing.mjs"},"./driver/in-memory":{"types":"./driver/in-memory/index.d.ts","default":"./fesm2022/daffodil-payment-driver-in-memory.mjs"},"./driver/testing":{"types":"./driver/testing/index.d.ts","default":"./fesm2022/daffodil-payment-driver-testing.mjs"},"./state/testing":{"types":"./state/testing/index.d.ts","default":"./fesm2022/daffodil-payment-state-testing.mjs"}},"sideEffects":false,"dependencies":{"tslib":"^2.3.0"}}
package/state/index.d.ts CHANGED
@@ -1 +1,204 @@
1
- export * from './public_api';
1
+ import * as _ngrx_store from '@ngrx/store';
2
+ import { Action, ActionReducer, MemoizedSelector, Store } from '@ngrx/store';
3
+ import { DaffIdentifiable } from '@daffodil/core';
4
+ import { DaffStateError, DaffStoreFacade, daffTransformErrorToStateError } from '@daffodil/core/state';
5
+ import { DaffPersonalAddress } from '@daffodil/geography';
6
+ import { DaffPaymentRequest, DaffPaymentResponse } from '@daffodil/payment';
7
+ import * as _angular_core from '@angular/core';
8
+ import { InjectionToken } from '@angular/core';
9
+ import { Observable } from 'rxjs';
10
+ import { DaffPaymentDriverInterface } from '@daffodil/payment/driver';
11
+
12
+ /**
13
+ * The payment action types enum.
14
+ */
15
+ declare enum DaffPaymentActionTypes {
16
+ GenerateTokenSuccessAction = "[@daffodil/payment] Generate Token Success Action",
17
+ GenerateTokenFailureAction = "[@daffodil/payment] Generate Token Failure Action"
18
+ }
19
+ /**
20
+ * Generates a payment token.
21
+ *
22
+ * @param query The payment query.
23
+ */
24
+ interface DaffPaymentGenerateTokenPayload<T extends DaffPaymentRequest = DaffPaymentRequest> {
25
+ readonly request: T;
26
+ readonly address?: DaffPersonalAddress | DaffIdentifiable;
27
+ }
28
+ interface DaffPaymentGenerateToken<T extends DaffPaymentRequest = DaffPaymentRequest> extends DaffPaymentGenerateTokenPayload<T>, Action {
29
+ }
30
+ /**
31
+ * Indicates a successful generation of a payment token.
32
+ */
33
+ declare class DaffPaymentGenerateTokenSuccess<T extends DaffPaymentResponse = DaffPaymentResponse> implements Action {
34
+ payload: T;
35
+ readonly type = DaffPaymentActionTypes.GenerateTokenSuccessAction;
36
+ constructor(payload: T);
37
+ }
38
+ /**
39
+ * A failed payment with the error message.
40
+ */
41
+ declare class DaffPaymentGenerateTokenFailure implements Action {
42
+ payload: DaffStateError;
43
+ readonly type = DaffPaymentActionTypes.GenerateTokenFailureAction;
44
+ constructor(payload: DaffStateError);
45
+ }
46
+ /**
47
+ * A union of the payment action types.
48
+ */
49
+ type DaffPaymentActions<T extends DaffPaymentResponse = DaffPaymentResponse> = DaffPaymentGenerateTokenSuccess<T> | DaffPaymentGenerateTokenFailure;
50
+
51
+ /**
52
+ * The main payment state.
53
+ * Contains info about the current or most recent payment operation.
54
+ */
55
+ interface DaffPaymentReducerState {
56
+ /**
57
+ * Whether there is a pending payment operation.
58
+ */
59
+ loading: boolean;
60
+ /**
61
+ * A list of payment errors, if any.
62
+ */
63
+ errors: DaffStateError[];
64
+ }
65
+
66
+ /**
67
+ * Manages {@link DaffPaymentReducerState}.
68
+ */
69
+ declare class DaffPaymentStateReducerAdapter {
70
+ /**
71
+ * Begins the payment operation flow.
72
+ * Sets loading to true.
73
+ */
74
+ generateToken(state: DaffPaymentReducerState): DaffPaymentReducerState;
75
+ /**
76
+ * Sets loading to false and resets errors.
77
+ */
78
+ tokenGenerated(state: DaffPaymentReducerState): DaffPaymentReducerState;
79
+ /**
80
+ * Stores the from a failed payment.
81
+ * Also sets loading to false.
82
+ */
83
+ storeError(errors: DaffStateError[], state: DaffPaymentReducerState): DaffPaymentReducerState;
84
+ }
85
+
86
+ /**
87
+ * The initial state for the main payment state, see {@link DaffPaymentReducerState}.
88
+ */
89
+ declare const daffPaymentInitialState: DaffPaymentReducerState;
90
+
91
+ /**
92
+ * The reducer for the payment page state, see {@link DaffPaymentReducerState}.
93
+ */
94
+ declare const daffPaymentReducerFactory: <T extends DaffPaymentResponse = DaffPaymentResponse>(actions: DaffPaymentGenerateToken["type"][]) => (state: DaffPaymentReducerState, action: DaffPaymentActions<T>) => DaffPaymentReducerState;
95
+
96
+ /**
97
+ * The key under which the payment feature state will be stored.
98
+ */
99
+ declare const DAFF_PAYMENT_STORE_FEATURE_KEY = "daffPayment";
100
+
101
+ /**
102
+ * The feature state for payment.
103
+ */
104
+ interface DaffPaymentReducersState {
105
+ payment: DaffPaymentReducerState;
106
+ }
107
+ /**
108
+ * The footprint of payment feature state in the root application state.
109
+ */
110
+ interface DaffPaymentStateRootSlice {
111
+ [DAFF_PAYMENT_STORE_FEATURE_KEY]: DaffPaymentReducersState;
112
+ }
113
+
114
+ declare const DAFF_PAYMENT_EXTRA_REDUCERS: _angular_core.InjectionToken<ActionReducer<DaffPaymentReducersState, _ngrx_store.Action<string>>[]>;
115
+ declare const daffPaymentProvideExtraReducers: <R extends ActionReducer<DaffPaymentReducersState, _ngrx_store.Action<string>> = ActionReducer<DaffPaymentReducersState, _ngrx_store.Action<string>>>(...values: R[]) => Array<_angular_core.ValueProvider>;
116
+
117
+ /**
118
+ * Selectors for the main part of payment state.
119
+ */
120
+ interface DaffPaymentSelectors {
121
+ /**
122
+ * Selects whether there is a pending payment operation.
123
+ */
124
+ selectPaymentLoading: MemoizedSelector<DaffPaymentStateRootSlice, boolean>;
125
+ /**
126
+ * Selects the list of payment errors, if any.
127
+ */
128
+ selectPaymentErrors: MemoizedSelector<DaffPaymentStateRootSlice, DaffStateError[]>;
129
+ }
130
+ declare const daffPaymentGetSelectors: () => DaffPaymentSelectors;
131
+
132
+ /**
133
+ * Exposes the payment state selectors.
134
+ */
135
+ interface DaffPaymentPageFacadeInterface extends DaffStoreFacade<Action> {
136
+ /**
137
+ * Whether there is a pending payment operation.
138
+ */
139
+ loading$: Observable<boolean>;
140
+ /**
141
+ * A list of payment errors, if any.
142
+ */
143
+ errors$: Observable<DaffStateError[]>;
144
+ }
145
+
146
+ /**
147
+ * @inheritdoc
148
+ *
149
+ * Serves as the base for a payment facade.
150
+ * Extend this class and pass in the selectors for the specific state you wish to target.
151
+ */
152
+ declare class DaffPaymentPageFacade implements DaffPaymentPageFacadeInterface {
153
+ private store;
154
+ loading$: Observable<boolean>;
155
+ errors$: Observable<DaffStateError[]>;
156
+ constructor(store: Store<DaffPaymentStateRootSlice>);
157
+ dispatch(action: Action): void;
158
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DaffPaymentPageFacade, never>;
159
+ static ɵprov: _angular_core.ɵɵInjectableDeclaration<DaffPaymentPageFacade>;
160
+ }
161
+
162
+ /**
163
+ * A representation of an available payment processor.
164
+ */
165
+ interface DaffPaymentAvailableProcessor {
166
+ /**
167
+ * The processor kind.
168
+ */
169
+ kind: DaffPaymentRequest['kind'];
170
+ /**
171
+ * The action type string that triggers token generation.
172
+ */
173
+ action: string;
174
+ /**
175
+ * An injection token of the driver that can perform token generation
176
+ * for this specific payment processor.
177
+ */
178
+ driver: InjectionToken<DaffPaymentDriverInterface>;
179
+ }
180
+
181
+ /**
182
+ * A collection of {@link DaffPaymentAvailableProcessor}s.
183
+ */
184
+ type DaffPaymentProcessorCollection = Record<DaffPaymentAvailableProcessor['kind'], DaffPaymentAvailableProcessor>;
185
+
186
+ declare const DAFF_PAYMENT_AVAILABLE_PROCESSORS: _angular_core.InjectionToken<DaffPaymentAvailableProcessor[]>;
187
+ declare const daffPaymentProvideAvailableProcessors: <R extends DaffPaymentAvailableProcessor = DaffPaymentAvailableProcessor>(...values: R[]) => Array<_angular_core.ValueProvider>;
188
+
189
+ declare const DAFF_PAYMENT_PROCESSOR_COLLECTION: _angular_core.InjectionToken<DaffPaymentProcessorCollection>;
190
+
191
+ declare const DAFF_PAYMENT_ERROR_MATCHER: _angular_core.InjectionToken<typeof daffTransformErrorToStateError>;
192
+ declare const provideDaffPaymentErrorMatcher: <R extends typeof daffTransformErrorToStateError = typeof daffTransformErrorToStateError>(value: R) => _angular_core.ValueProvider;
193
+
194
+ /**
195
+ * Creates the payment feature store.
196
+ */
197
+ declare class DaffPaymentStateModule {
198
+ static ɵfac: _angular_core.ɵɵFactoryDeclaration<DaffPaymentStateModule, never>;
199
+ static ɵmod: _angular_core.ɵɵNgModuleDeclaration<DaffPaymentStateModule, never, [typeof _ngrx_store.StoreFeatureModule], never>;
200
+ static ɵinj: _angular_core.ɵɵInjectorDeclaration<DaffPaymentStateModule>;
201
+ }
202
+
203
+ export { DAFF_PAYMENT_AVAILABLE_PROCESSORS, DAFF_PAYMENT_ERROR_MATCHER, DAFF_PAYMENT_EXTRA_REDUCERS, DAFF_PAYMENT_PROCESSOR_COLLECTION, DAFF_PAYMENT_STORE_FEATURE_KEY, DaffPaymentActionTypes, DaffPaymentGenerateTokenFailure, DaffPaymentGenerateTokenSuccess, DaffPaymentPageFacade, DaffPaymentStateModule, DaffPaymentStateReducerAdapter, daffPaymentGetSelectors, daffPaymentInitialState, daffPaymentProvideAvailableProcessors, daffPaymentProvideExtraReducers, daffPaymentReducerFactory, provideDaffPaymentErrorMatcher };
204
+ export type { DaffPaymentActions, DaffPaymentAvailableProcessor, DaffPaymentGenerateToken, DaffPaymentGenerateTokenPayload, DaffPaymentPageFacadeInterface, DaffPaymentProcessorCollection, DaffPaymentReducerState, DaffPaymentReducersState, DaffPaymentSelectors, DaffPaymentStateRootSlice };
@@ -1 +1,29 @@
1
- export * from './public_api';
1
+ import { Action } from '@ngrx/store';
2
+ import { BehaviorSubject } from 'rxjs';
3
+ import { DaffStateError } from '@daffodil/core/state';
4
+ import { DaffPaymentPageFacadeInterface } from '@daffodil/payment/state';
5
+ import * as i0 from '@angular/core';
6
+
7
+ /**
8
+ * Mocks out facade fields and methods for testing purposes.
9
+ *
10
+ * @inheritdoc
11
+ */
12
+ declare class MockDaffPaymentPageFacade implements DaffPaymentPageFacadeInterface {
13
+ loading$: BehaviorSubject<boolean>;
14
+ errors$: BehaviorSubject<DaffStateError[]>;
15
+ dispatch(action: Action): void;
16
+ static ɵfac: i0.ɵɵFactoryDeclaration<MockDaffPaymentPageFacade, never>;
17
+ static ɵprov: i0.ɵɵInjectableDeclaration<MockDaffPaymentPageFacade>;
18
+ }
19
+
20
+ /**
21
+ * Provides the {@link MockDaffPaymentPageFacade} for {@link DaffPaymentPageFacade}.
22
+ */
23
+ declare class DaffPaymentStateTestingModule {
24
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentStateTestingModule, never>;
25
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentStateTestingModule, never, never, never>;
26
+ static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentStateTestingModule>;
27
+ }
28
+
29
+ export { DaffPaymentStateTestingModule, MockDaffPaymentPageFacade };
@@ -1 +1,64 @@
1
- export * from './public_api';
1
+ import { DaffModelFactory } from '@daffodil/core/testing';
2
+ import { DaffPaymentResponse, DaffPaymentRequest } from '@daffodil/payment';
3
+ import * as i0 from '@angular/core';
4
+ import * as _daffodil_core from '@daffodil/core';
5
+
6
+ /**
7
+ * Mock class for {@link DaffPaymentResponse}.
8
+ */
9
+ declare class MockPaymentResponse implements DaffPaymentResponse {
10
+ method: string;
11
+ }
12
+ /**
13
+ * Model factory for {@link DaffPaymentResponse}.
14
+ */
15
+ declare class DaffPaymentResponseFactory extends DaffModelFactory<DaffPaymentResponse, typeof MockPaymentResponse> {
16
+ constructor();
17
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentResponseFactory, never>;
18
+ static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentResponseFactory>;
19
+ }
20
+
21
+ /**
22
+ * Mock class for {@link DaffPaymentRequest}.
23
+ */
24
+ declare class MockPaymentRequest implements DaffPaymentRequest {
25
+ kind: string;
26
+ }
27
+ /**
28
+ * Model factory for {@link DaffPaymentRequest}.
29
+ */
30
+ declare class DaffPaymentRequestFactory extends DaffModelFactory<DaffPaymentRequest> {
31
+ constructor();
32
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentRequestFactory, never>;
33
+ static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentRequestFactory>;
34
+ }
35
+
36
+ /**
37
+ * Factory for creating DaffPaymentResponses.
38
+ * This will create a payment response of random kind.
39
+ */
40
+ declare class DaffPaymentResponseKindFactory extends DaffModelFactory<DaffPaymentResponse> {
41
+ private kindFactories;
42
+ constructor(kindFactories: DaffModelFactory<DaffPaymentResponse>[]);
43
+ private get _randomFactory();
44
+ /**
45
+ * Creates a payment result of random kind.
46
+ */
47
+ create(partial?: {}): DaffPaymentResponse;
48
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentResponseKindFactory, never>;
49
+ static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentResponseKindFactory>;
50
+ }
51
+
52
+ declare const DAFF_PAYMENT_RESPONSE_KIND_FACTORIES: i0.InjectionToken<DaffModelFactory<DaffPaymentResponse<unknown>, _daffodil_core.Constructable<DaffPaymentResponse<unknown>>>[]>;
53
+ declare const provideDaffPaymentResponseKindFactories: <R extends DaffModelFactory<DaffPaymentResponse<unknown>, _daffodil_core.Constructable<DaffPaymentResponse<unknown>>> = DaffModelFactory<DaffPaymentResponse<unknown>, _daffodil_core.Constructable<DaffPaymentResponse<unknown>>>>(...classes: i0.Type<R>[]) => Array<i0.ExistingProvider>;
54
+
55
+ /**
56
+ * Provides the default payment result factory as a payment result type factory.
57
+ */
58
+ declare class DaffPaymentTestingModule {
59
+ static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentTestingModule, never>;
60
+ static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentTestingModule, never, never, never>;
61
+ static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentTestingModule>;
62
+ }
63
+
64
+ export { DAFF_PAYMENT_RESPONSE_KIND_FACTORIES, DaffPaymentRequestFactory, DaffPaymentResponseFactory, DaffPaymentResponseKindFactory, DaffPaymentTestingModule, MockPaymentRequest, MockPaymentResponse, provideDaffPaymentResponseKindFactories };
@@ -1,10 +0,0 @@
1
- import { DaffError, DaffInheritableError } from '@daffodil/core';
2
- export declare const DAFF_PAYMENT_INVALID_API_RESPONSE_ERROR_CODE = "DAFF_PAYMENT_INVALID_API_RESPONSE";
3
- /**
4
- * A general error indicating that the platform returned a response which cannot be processed.
5
- */
6
- export declare class DaffPaymentInvalidAPIResponseError extends DaffInheritableError implements DaffError {
7
- message: string;
8
- readonly code: string;
9
- constructor(message: string);
10
- }
@@ -1,7 +0,0 @@
1
- import { DaffPaymentInvalidAPIResponseError } from './invalid-api-response';
2
- /**
3
- * A mapping from error codes to error class constructors.
4
- */
5
- export declare const DaffPaymentDriverErrorMap: {
6
- DAFF_PAYMENT_INVALID_API_RESPONSE: typeof DaffPaymentInvalidAPIResponseError;
7
- };
@@ -1,2 +0,0 @@
1
- export { DaffPaymentInvalidAPIResponseError, DAFF_PAYMENT_INVALID_API_RESPONSE_ERROR_CODE, } from './invalid-api-response';
2
- export { DaffPaymentDriverErrorMap } from './map';
@@ -1,35 +0,0 @@
1
- import { InMemoryDbService, RequestInfoUtilities, ParsedRequestUrl, RequestInfo } from 'angular-in-memory-web-api';
2
- import { DaffInMemorySingleRouteableBackend } from '@daffodil/driver/in-memory';
3
- import { DaffPaymentResponseKindFactory } from '@daffodil/payment/testing';
4
- import * as i0 from "@angular/core";
5
- /**
6
- * An in-memory service that delegates payment queries to child backends
7
- * via the {@link DAFF_PAYMENT_IN_MEMORY_BACKENDS}.
8
- */
9
- export declare class DaffPaymentInMemoryBackendService implements InMemoryDbService, DaffInMemorySingleRouteableBackend {
10
- private factory;
11
- readonly collectionName = "payment";
12
- constructor(factory: DaffPaymentResponseKindFactory);
13
- /**
14
- * Automatically called as part of the InMemoryDbService to parse incoming urls to match the InMemory backend urls.
15
- *
16
- * @param url initial url
17
- * @param utils utility to parse url
18
- * @returns ParsedRequestUrl
19
- * @docs-private
20
- */
21
- parseRequestUrl(url: string, utils: RequestInfoUtilities): ParsedRequestUrl;
22
- /**
23
- * @docs-private
24
- */
25
- createDb(): any;
26
- /**
27
- * Generates a token from a processor backend.
28
- *
29
- * @param reqInfo request object
30
- * @returns An http response object
31
- */
32
- get(reqInfo: RequestInfo): import("rxjs").Observable<any>;
33
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentInMemoryBackendService, never>;
34
- static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentInMemoryBackendService>;
35
- }
@@ -1 +0,0 @@
1
- export declare const DAFF_PAYMENT_IN_MEMORY_COLLECTION_NAME = "payment";
@@ -1,13 +0,0 @@
1
- import { ModuleWithProviders } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- import * as i1 from "@angular/common";
4
- import * as i2 from "@daffodil/payment/testing";
5
- /**
6
- * Provides the {@link DaffPaymentInMemoryDriver} as the {@link DaffPaymentDriver}.
7
- */
8
- export declare class DaffPaymentInMemoryDriverModule {
9
- static forRoot(): ModuleWithProviders<DaffPaymentInMemoryDriverModule>;
10
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentInMemoryDriverModule, never>;
11
- static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentInMemoryDriverModule, never, [typeof i1.CommonModule, typeof i2.DaffPaymentTestingModule], never>;
12
- static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentInMemoryDriverModule>;
13
- }
@@ -1,19 +0,0 @@
1
- import { HttpClient } from '@angular/common/http';
2
- import { InMemoryBackendConfig } from 'angular-in-memory-web-api';
3
- import { Observable } from 'rxjs';
4
- import { DaffInMemoryDriverBase } from '@daffodil/driver/in-memory';
5
- import { DaffPaymentRequest, DaffPaymentResponse } from '@daffodil/payment';
6
- import { DaffPaymentDriverInterface } from '@daffodil/payment/driver';
7
- import * as i0 from "@angular/core";
8
- /**
9
- * The payment inmemory driver to mock the payment backend service.
10
- *
11
- * @inheritdoc
12
- */
13
- export declare class DaffPaymentInMemoryDriver extends DaffInMemoryDriverBase implements DaffPaymentDriverInterface {
14
- private http;
15
- constructor(http: HttpClient, config: InMemoryBackendConfig);
16
- generateToken(request: DaffPaymentRequest): Observable<DaffPaymentResponse>;
17
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentInMemoryDriver, never>;
18
- static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentInMemoryDriver>;
19
- }
@@ -1,3 +0,0 @@
1
- export { DaffPaymentInMemoryBackendService } from './backend/payment.service';
2
- export { DaffPaymentInMemoryDriver } from './driver/payment.service';
3
- export { DaffPaymentInMemoryDriverModule } from './driver/payment-driver.module';
@@ -1,12 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { DaffPaymentRequest, DaffPaymentResponse } from '@daffodil/payment';
3
- export declare const DaffPaymentDriver: import("@angular/core").InjectionToken<DaffPaymentDriverInterface<DaffPaymentResponse<unknown>>>, provideDaffPaymentDriver: <R extends DaffPaymentDriverInterface<DaffPaymentResponse<unknown>> = DaffPaymentDriverInterface<DaffPaymentResponse<unknown>>>(klass: import("@angular/core").Type<R>) => import("@angular/core").ExistingProvider;
4
- /**
5
- * The payment driver is responsible for taking user payment input and generating a token for use with the platform.
6
- */
7
- export interface DaffPaymentDriverInterface<T extends DaffPaymentResponse = DaffPaymentResponse> {
8
- /**
9
- * Generate a payment token.
10
- */
11
- generateToken(request: DaffPaymentRequest): Observable<T>;
12
- }
@@ -1,2 +0,0 @@
1
- export { DaffPaymentDriverInterface, DaffPaymentDriver, provideDaffPaymentDriver, } from './interfaces/payment-service.interface';
2
- export * from './errors/public_api';
@@ -1,12 +0,0 @@
1
- import { ModuleWithProviders } from '@angular/core';
2
- import * as i0 from "@angular/core";
3
- import * as i1 from "@angular/common";
4
- /**
5
- * Provides the {@link DaffPaymentTestingDriver} as the {@link DaffPaymentDriver}.
6
- */
7
- export declare class DaffPaymentTestingDriverModule {
8
- static forRoot(): ModuleWithProviders<DaffPaymentTestingDriverModule>;
9
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentTestingDriverModule, never>;
10
- static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentTestingDriverModule, never, [typeof i1.CommonModule], never>;
11
- static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentTestingDriverModule>;
12
- }
@@ -1,18 +0,0 @@
1
- import { Observable } from 'rxjs';
2
- import { DaffPaymentRequest, DaffPaymentResponse } from '@daffodil/payment';
3
- import { DaffPaymentDriverInterface } from '@daffodil/payment/driver';
4
- import { DaffPaymentResponseKindFactory } from '@daffodil/payment/testing';
5
- import * as i0 from "@angular/core";
6
- /**
7
- * A basic payment driver that creates mock payment results of different kinds.
8
- * For testing purposes.
9
- *
10
- * @inheritdoc
11
- */
12
- export declare class DaffPaymentTestingDriver implements DaffPaymentDriverInterface {
13
- private paymentResponseFactory;
14
- constructor(paymentResponseFactory: DaffPaymentResponseKindFactory);
15
- generateToken(request: DaffPaymentRequest): Observable<DaffPaymentResponse>;
16
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentTestingDriver, never>;
17
- static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentTestingDriver>;
18
- }
@@ -1,2 +0,0 @@
1
- export { DaffPaymentTestingDriverModule } from './payment-driver.module';
2
- export { DaffPaymentTestingDriver } from './payment.service';
@@ -1 +0,0 @@
1
- export * from './drivers/public_api';
@@ -1,2 +0,0 @@
1
- export { DaffPaymentRequest } from './request.type';
2
- export { DaffPaymentResponse } from './response.type';
@@ -1,13 +0,0 @@
1
- /**
2
- * A payment request that can be used to generate a token or additional data for use with an ecommerce platform.
3
- */
4
- export interface DaffPaymentRequest<T = unknown> {
5
- /**
6
- * The payment kind. A constant identifying the payment processor and payment method.
7
- */
8
- kind: string;
9
- /**
10
- * The payment data that will be used to generate a payment token or additional data.
11
- */
12
- data?: T;
13
- }
@@ -1,14 +0,0 @@
1
- /**
2
- * A payment response that can be sent to an ecommerce platform to set payment information for the provided method.
3
- */
4
- export interface DaffPaymentResponse<T = unknown> {
5
- /**
6
- * The payment method.
7
- * This can be specific to the platform in use and should not be considered a constant.
8
- */
9
- method: string;
10
- /**
11
- * The payment data that represents validated payment information.
12
- */
13
- data?: T;
14
- }
package/public_api.d.ts DELETED
@@ -1 +0,0 @@
1
- export * from './models/public_api';
@@ -1,43 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
- import { DaffIdentifiable } from '@daffodil/core';
3
- import { DaffStateError } from '@daffodil/core/state';
4
- import { DaffPersonalAddress } from '@daffodil/geography';
5
- import { DaffPaymentRequest, DaffPaymentResponse } from '@daffodil/payment';
6
- /**
7
- * The payment action types enum.
8
- */
9
- export declare enum DaffPaymentActionTypes {
10
- GenerateTokenSuccessAction = "[@daffodil/payment] Generate Token Success Action",
11
- GenerateTokenFailureAction = "[@daffodil/payment] Generate Token Failure Action"
12
- }
13
- /**
14
- * Generates a payment token.
15
- *
16
- * @param query The payment query.
17
- */
18
- export interface DaffPaymentGenerateTokenPayload<T extends DaffPaymentRequest = DaffPaymentRequest> {
19
- readonly request: T;
20
- readonly address?: DaffPersonalAddress | DaffIdentifiable;
21
- }
22
- export interface DaffPaymentGenerateToken<T extends DaffPaymentRequest = DaffPaymentRequest> extends DaffPaymentGenerateTokenPayload<T>, Action {
23
- }
24
- /**
25
- * Indicates a successful generation of a payment token.
26
- */
27
- export declare class DaffPaymentGenerateTokenSuccess<T extends DaffPaymentResponse = DaffPaymentResponse> implements Action {
28
- payload: T;
29
- readonly type = DaffPaymentActionTypes.GenerateTokenSuccessAction;
30
- constructor(payload: T);
31
- }
32
- /**
33
- * A failed payment with the error message.
34
- */
35
- export declare class DaffPaymentGenerateTokenFailure implements Action {
36
- payload: DaffStateError;
37
- readonly type = DaffPaymentActionTypes.GenerateTokenFailureAction;
38
- constructor(payload: DaffStateError);
39
- }
40
- /**
41
- * A union of the payment action types.
42
- */
43
- export type DaffPaymentActions<T extends DaffPaymentResponse = DaffPaymentResponse> = DaffPaymentGenerateTokenSuccess<T> | DaffPaymentGenerateTokenFailure;
@@ -1,21 +0,0 @@
1
- import { Action, Store } from '@ngrx/store';
2
- import { Observable } from 'rxjs';
3
- import { DaffStateError } from '@daffodil/core/state';
4
- import { DaffPaymentPageFacadeInterface } from './interface';
5
- import { DaffPaymentStateRootSlice } from '../../reducers/public_api';
6
- import * as i0 from "@angular/core";
7
- /**
8
- * @inheritdoc
9
- *
10
- * Serves as the base for a payment facade.
11
- * Extend this class and pass in the selectors for the specific state you wish to target.
12
- */
13
- export declare class DaffPaymentPageFacade implements DaffPaymentPageFacadeInterface {
14
- private store;
15
- loading$: Observable<boolean>;
16
- errors$: Observable<DaffStateError[]>;
17
- constructor(store: Store<DaffPaymentStateRootSlice>);
18
- dispatch(action: Action): void;
19
- static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentPageFacade, never>;
20
- static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentPageFacade>;
21
- }
@@ -1,16 +0,0 @@
1
- import { Action } from '@ngrx/store';
2
- import { Observable } from 'rxjs';
3
- import { DaffStoreFacade, DaffStateError } from '@daffodil/core/state';
4
- /**
5
- * Exposes the payment state selectors.
6
- */
7
- export interface DaffPaymentPageFacadeInterface extends DaffStoreFacade<Action> {
8
- /**
9
- * Whether there is a pending payment operation.
10
- */
11
- loading$: Observable<boolean>;
12
- /**
13
- * A list of payment errors, if any.
14
- */
15
- errors$: Observable<DaffStateError[]>;
16
- }
@@ -1,2 +0,0 @@
1
- export { DaffPaymentPageFacadeInterface } from './payment/interface';
2
- export { DaffPaymentPageFacade } from './payment/facade';
@@ -1,2 +0,0 @@
1
- import { DaffPaymentAvailableProcessor } from '../models/public_api';
2
- export declare const DAFF_PAYMENT_AVAILABLE_PROCESSORS: import("@angular/core").InjectionToken<DaffPaymentAvailableProcessor[]>, daffPaymentProvideAvailableProcessors: <R extends DaffPaymentAvailableProcessor = DaffPaymentAvailableProcessor>(...values: R[]) => Array<import("@angular/core").ValueProvider>;
@@ -1,2 +0,0 @@
1
- import { daffTransformErrorToStateError } from '@daffodil/core/state';
2
- export declare const DAFF_PAYMENT_ERROR_MATCHER: import("@angular/core").InjectionToken<typeof daffTransformErrorToStateError>, provideDaffPaymentErrorMatcher: <R extends typeof daffTransformErrorToStateError = typeof daffTransformErrorToStateError>(value: R) => import("@angular/core").ValueProvider;
@@ -1,2 +0,0 @@
1
- import { DaffPaymentProcessorCollection } from '../models/public_api';
2
- export declare const DAFF_PAYMENT_PROCESSOR_COLLECTION: import("@angular/core").InjectionToken<DaffPaymentProcessorCollection>, provideDaffPaymentProcessorCollection: <R extends DaffPaymentProcessorCollection = DaffPaymentProcessorCollection>(value: R) => import("@angular/core").ValueProvider;