@daffodil/payment 0.47.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.
- package/README.md +11 -0
- package/daffodil-payment.d.ts +5 -0
- package/driver/daffodil-payment-driver.d.ts +5 -0
- package/driver/errors/invalid-api-response.d.ts +10 -0
- package/driver/errors/map.d.ts +7 -0
- package/driver/errors/public_api.d.ts +2 -0
- package/driver/in-memory/backend/payment.service.d.ts +33 -0
- package/driver/in-memory/daffodil-payment-driver-in-memory.d.ts +5 -0
- package/driver/in-memory/driver/payment-driver.module.d.ts +13 -0
- package/driver/in-memory/driver/payment.service.d.ts +21 -0
- package/driver/in-memory/index.d.ts +1 -0
- package/driver/in-memory/package.json +10 -0
- package/driver/in-memory/public_api.d.ts +3 -0
- package/driver/index.d.ts +1 -0
- package/driver/interfaces/payment-service.interface.d.ts +16 -0
- package/driver/package.json +10 -0
- package/driver/public_api.d.ts +2 -0
- package/driver/testing/daffodil-payment-driver-testing.d.ts +5 -0
- package/driver/testing/drivers/payment-driver.module.d.ts +12 -0
- package/driver/testing/drivers/payment.service.d.ts +18 -0
- package/driver/testing/drivers/public_api.d.ts +2 -0
- package/driver/testing/index.d.ts +1 -0
- package/driver/testing/package.json +10 -0
- package/driver/testing/public_api.d.ts +1 -0
- package/esm2020/daffodil-payment.mjs +5 -0
- package/esm2020/driver/daffodil-payment-driver.mjs +5 -0
- package/esm2020/driver/errors/invalid-api-response.mjs +13 -0
- package/esm2020/driver/errors/map.mjs +8 -0
- package/esm2020/driver/errors/public_api.mjs +3 -0
- package/esm2020/driver/in-memory/backend/payment.service.mjs +52 -0
- package/esm2020/driver/in-memory/daffodil-payment-driver-in-memory.mjs +5 -0
- package/esm2020/driver/in-memory/driver/payment-driver.module.mjs +39 -0
- package/esm2020/driver/in-memory/driver/payment.service.mjs +30 -0
- package/esm2020/driver/in-memory/index.mjs +2 -0
- package/esm2020/driver/in-memory/public_api.mjs +4 -0
- package/esm2020/driver/index.mjs +2 -0
- package/esm2020/driver/interfaces/payment-service.interface.mjs +6 -0
- package/esm2020/driver/public_api.mjs +3 -0
- package/esm2020/driver/testing/daffodil-payment-driver-testing.mjs +5 -0
- package/esm2020/driver/testing/drivers/payment-driver.module.mjs +35 -0
- package/esm2020/driver/testing/drivers/payment.service.mjs +28 -0
- package/esm2020/driver/testing/drivers/public_api.mjs +3 -0
- package/esm2020/driver/testing/index.mjs +2 -0
- package/esm2020/driver/testing/public_api.mjs +2 -0
- package/esm2020/index.mjs +2 -0
- package/esm2020/injection-tokens/error-matcher.token.mjs +8 -0
- package/esm2020/injection-tokens/public_api.mjs +2 -0
- package/esm2020/models/public_api.mjs +2 -0
- package/esm2020/models/request.type.mjs +2 -0
- package/esm2020/models/response.type.mjs +2 -0
- package/esm2020/public_api.mjs +3 -0
- package/esm2020/state/actions/payment.actions.mjs +27 -0
- package/esm2020/state/daffodil-payment-state.mjs +5 -0
- package/esm2020/state/facades/payment/facade.mjs +31 -0
- package/esm2020/state/facades/payment/interface.mjs +2 -0
- package/esm2020/state/facades/public_api.mjs +2 -0
- package/esm2020/state/index.mjs +2 -0
- package/esm2020/state/injection-tokens/available-processors.token.mjs +19 -0
- package/esm2020/state/injection-tokens/processor-collection.token.mjs +13 -0
- package/esm2020/state/injection-tokens/public_api.mjs +3 -0
- package/esm2020/state/models/available-processor.type.mjs +2 -0
- package/esm2020/state/models/processor-collection.type.mjs +2 -0
- package/esm2020/state/models/public_api.mjs +2 -0
- package/esm2020/state/payment.module.mjs +25 -0
- package/esm2020/state/public_api.mjs +8 -0
- package/esm2020/state/reducers/payment/adapter.mjs +40 -0
- package/esm2020/state/reducers/payment/initial-state.mjs +8 -0
- package/esm2020/state/reducers/payment/interface.mjs +2 -0
- package/esm2020/state/reducers/payment/public_api.mjs +4 -0
- package/esm2020/state/reducers/payment/reducer.mjs +20 -0
- package/esm2020/state/reducers/public_api.mjs +4 -0
- package/esm2020/state/reducers/reducers.interface.mjs +2 -0
- package/esm2020/state/reducers/store-feature-key.mjs +5 -0
- package/esm2020/state/reducers/token/extra.token.mjs +30 -0
- package/esm2020/state/reducers/token/public_api.mjs +2 -0
- package/esm2020/state/reducers/token/reducers.token.mjs +22 -0
- package/esm2020/state/selectors/feature.selector.mjs +9 -0
- package/esm2020/state/selectors/payment.selector.mjs +20 -0
- package/esm2020/state/selectors/public_api.mjs +2 -0
- package/esm2020/state/testing/daffodil-payment-state-testing.mjs +5 -0
- package/esm2020/state/testing/index.mjs +2 -0
- package/esm2020/state/testing/mock-payment-facade.mjs +23 -0
- package/esm2020/state/testing/payment-testing.module.mjs +23 -0
- package/esm2020/state/testing/public_api.mjs +3 -0
- package/esm2020/testing/daffodil-payment-testing.mjs +5 -0
- package/esm2020/testing/factories/kind.factory.mjs +37 -0
- package/esm2020/testing/factories/payment-request.factory.mjs +31 -0
- package/esm2020/testing/factories/payment-response.factory.mjs +31 -0
- package/esm2020/testing/factories/public_api.mjs +4 -0
- package/esm2020/testing/index.mjs +2 -0
- package/esm2020/testing/injection-tokens/factories/kind.token.mjs +30 -0
- package/esm2020/testing/injection-tokens/public_api.mjs +2 -0
- package/esm2020/testing/public_api.mjs +4 -0
- package/esm2020/testing/testing.module.mjs +31 -0
- package/fesm2015/daffodil-payment-driver-in-memory.mjs +121 -0
- package/fesm2015/daffodil-payment-driver-in-memory.mjs.map +1 -0
- package/fesm2015/daffodil-payment-driver-testing.mjs +66 -0
- package/fesm2015/daffodil-payment-driver-testing.mjs.map +1 -0
- package/fesm2015/daffodil-payment-driver.mjs +33 -0
- package/fesm2015/daffodil-payment-driver.mjs.map +1 -0
- package/fesm2015/daffodil-payment-state-testing.mjs +50 -0
- package/fesm2015/daffodil-payment-state-testing.mjs.map +1 -0
- package/fesm2015/daffodil-payment-state.mjs +242 -0
- package/fesm2015/daffodil-payment-state.mjs.map +1 -0
- package/fesm2015/daffodil-payment-testing.mjs +154 -0
- package/fesm2015/daffodil-payment-testing.mjs.map +1 -0
- package/fesm2015/daffodil-payment.mjs +15 -0
- package/fesm2015/daffodil-payment.mjs.map +1 -0
- package/fesm2020/daffodil-payment-driver-in-memory.mjs +121 -0
- package/fesm2020/daffodil-payment-driver-in-memory.mjs.map +1 -0
- package/fesm2020/daffodil-payment-driver-testing.mjs +66 -0
- package/fesm2020/daffodil-payment-driver-testing.mjs.map +1 -0
- package/fesm2020/daffodil-payment-driver.mjs +33 -0
- package/fesm2020/daffodil-payment-driver.mjs.map +1 -0
- package/fesm2020/daffodil-payment-state-testing.mjs +50 -0
- package/fesm2020/daffodil-payment-state-testing.mjs.map +1 -0
- package/fesm2020/daffodil-payment-state.mjs +253 -0
- package/fesm2020/daffodil-payment-state.mjs.map +1 -0
- package/fesm2020/daffodil-payment-testing.mjs +152 -0
- package/fesm2020/daffodil-payment-testing.mjs.map +1 -0
- package/fesm2020/daffodil-payment.mjs +15 -0
- package/fesm2020/daffodil-payment.mjs.map +1 -0
- package/index.d.ts +1 -0
- package/injection-tokens/error-matcher.token.d.ts +7 -0
- package/injection-tokens/public_api.d.ts +1 -0
- package/models/public_api.d.ts +2 -0
- package/models/request.type.d.ts +13 -0
- package/models/response.type.d.ts +14 -0
- package/package.json +100 -0
- package/public_api.d.ts +2 -0
- package/state/actions/payment.actions.d.ts +40 -0
- package/state/daffodil-payment-state.d.ts +5 -0
- package/state/facades/payment/facade.d.ts +21 -0
- package/state/facades/payment/interface.d.ts +16 -0
- package/state/facades/public_api.d.ts +2 -0
- package/state/index.d.ts +1 -0
- package/state/injection-tokens/available-processors.token.d.ts +12 -0
- package/state/injection-tokens/processor-collection.token.d.ts +6 -0
- package/state/injection-tokens/public_api.d.ts +2 -0
- package/state/models/available-processor.type.d.ts +21 -0
- package/state/models/processor-collection.type.d.ts +5 -0
- package/state/models/public_api.d.ts +2 -0
- package/state/package.json +10 -0
- package/state/payment.module.d.ts +10 -0
- package/state/public_api.d.ts +7 -0
- package/state/reducers/payment/adapter.d.ts +21 -0
- package/state/reducers/payment/initial-state.d.ts +5 -0
- package/state/reducers/payment/interface.d.ts +15 -0
- package/state/reducers/payment/public_api.d.ts +4 -0
- package/state/reducers/payment/reducer.d.ts +7 -0
- package/state/reducers/public_api.d.ts +4 -0
- package/state/reducers/reducers.interface.d.ts +14 -0
- package/state/reducers/store-feature-key.d.ts +4 -0
- package/state/reducers/token/extra.token.d.ts +22 -0
- package/state/reducers/token/public_api.d.ts +1 -0
- package/state/reducers/token/reducers.token.d.ts +10 -0
- package/state/selectors/feature.selector.d.ts +9 -0
- package/state/selectors/payment.selector.d.ts +17 -0
- package/state/selectors/public_api.d.ts +1 -0
- package/state/testing/daffodil-payment-state-testing.d.ts +5 -0
- package/state/testing/index.d.ts +1 -0
- package/state/testing/mock-payment-facade.d.ts +17 -0
- package/state/testing/package.json +10 -0
- package/state/testing/payment-testing.module.d.ts +9 -0
- package/state/testing/public_api.d.ts +2 -0
- package/testing/daffodil-payment-testing.d.ts +5 -0
- package/testing/factories/kind.factory.d.ts +18 -0
- package/testing/factories/payment-request.factory.d.ts +18 -0
- package/testing/factories/payment-response.factory.d.ts +18 -0
- package/testing/factories/public_api.d.ts +3 -0
- package/testing/index.d.ts +1 -0
- package/testing/injection-tokens/factories/kind.token.d.ts +24 -0
- package/testing/injection-tokens/public_api.d.ts +1 -0
- package/testing/package.json +10 -0
- package/testing/public_api.d.ts +3 -0
- package/testing/testing.module.d.ts +9 -0
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { daffTransformErrorToStateError } from '@daffodil/core/state';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
|
|
6
|
+
* Can be used to further refine Daffodil errors into more specific app errors.
|
|
7
|
+
*/
|
|
8
|
+
const DAFF_PAYMENT_ERROR_MATCHER = new InjectionToken('DAFF_PAYMENT_ERROR_MATCHER', { factory: () => daffTransformErrorToStateError });
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Generated bundle index. Do not edit.
|
|
12
|
+
*/
|
|
13
|
+
|
|
14
|
+
export { DAFF_PAYMENT_ERROR_MATCHER };
|
|
15
|
+
//# sourceMappingURL=daffodil-payment.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"daffodil-payment.mjs","sources":["../../../libs/payment/src/injection-tokens/error-matcher.token.ts","../../../libs/payment/src/daffodil-payment.ts"],"sourcesContent":["import { InjectionToken } from '@angular/core';\n\nimport { daffTransformErrorToStateError } from '@daffodil/core/state';\n\n/**\n * Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.\n * Can be used to further refine Daffodil errors into more specific app errors.\n */\nexport const DAFF_PAYMENT_ERROR_MATCHER = new InjectionToken<typeof daffTransformErrorToStateError>(\n 'DAFF_PAYMENT_ERROR_MATCHER',\n { factory: () => daffTransformErrorToStateError },\n);\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './index';\n"],"names":[],"mappings":";;;AAIA;;;AAGG;AACU,MAAA,0BAA0B,GAAG,IAAI,cAAc,CAC1D,4BAA4B,EAC5B,EAAE,OAAO,EAAE,MAAM,8BAA8B,EAAE;;ACVnD;;AAEG;;;;"}
|
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public_api';
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { daffTransformErrorToStateError } from '@daffodil/core/state';
|
|
3
|
+
/**
|
|
4
|
+
* Transforms `DaffError`s into `DaffStateError`s before they are serialized into state.
|
|
5
|
+
* Can be used to further refine Daffodil errors into more specific app errors.
|
|
6
|
+
*/
|
|
7
|
+
export declare const DAFF_PAYMENT_ERROR_MATCHER: InjectionToken<typeof daffTransformErrorToStateError>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { DAFF_PAYMENT_ERROR_MATCHER } from './error-matcher.token';
|
|
@@ -0,0 +1,13 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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/package.json
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daffodil/payment",
|
|
3
|
+
"version": "0.47.1",
|
|
4
|
+
"description": "A client-side Angular package for managing ecommerce payments agnostic to the ecommerce platform.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "https://github.com/graycoreio/daffodil"
|
|
8
|
+
},
|
|
9
|
+
"author": "Graycore LLC",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/graycoreio/daffodil/issues"
|
|
13
|
+
},
|
|
14
|
+
"homepage": "https://github.com/graycoreio/daffodil",
|
|
15
|
+
"peerDependencies": {
|
|
16
|
+
"@angular/common": "^13.0.0",
|
|
17
|
+
"@angular/core": "^13.0.0",
|
|
18
|
+
"@daffodil/core": "0.47.1",
|
|
19
|
+
"@ngrx/effects": "^13.0.0",
|
|
20
|
+
"@ngrx/store": "^13.0.0",
|
|
21
|
+
"rxjs": "7.5.5"
|
|
22
|
+
},
|
|
23
|
+
"optionalDependencies": {
|
|
24
|
+
"@apollo/client": "^3.0.0",
|
|
25
|
+
"@daffodil/driver": "0.47.1",
|
|
26
|
+
"apollo-angular": "^3.0.1",
|
|
27
|
+
"@faker-js/faker": "^5.5.3"
|
|
28
|
+
},
|
|
29
|
+
"module": "fesm2015/daffodil-payment.mjs",
|
|
30
|
+
"es2020": "fesm2020/daffodil-payment.mjs",
|
|
31
|
+
"esm2020": "esm2020/daffodil-payment.mjs",
|
|
32
|
+
"fesm2020": "fesm2020/daffodil-payment.mjs",
|
|
33
|
+
"fesm2015": "fesm2015/daffodil-payment.mjs",
|
|
34
|
+
"typings": "daffodil-payment.d.ts",
|
|
35
|
+
"exports": {
|
|
36
|
+
"./package.json": {
|
|
37
|
+
"default": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
".": {
|
|
40
|
+
"types": "./daffodil-payment.d.ts",
|
|
41
|
+
"esm2020": "./esm2020/daffodil-payment.mjs",
|
|
42
|
+
"es2020": "./fesm2020/daffodil-payment.mjs",
|
|
43
|
+
"es2015": "./fesm2015/daffodil-payment.mjs",
|
|
44
|
+
"node": "./fesm2015/daffodil-payment.mjs",
|
|
45
|
+
"default": "./fesm2020/daffodil-payment.mjs"
|
|
46
|
+
},
|
|
47
|
+
"./driver/in-memory": {
|
|
48
|
+
"types": "./driver/in-memory/daffodil-payment-driver-in-memory.d.ts",
|
|
49
|
+
"esm2020": "./esm2020/driver/in-memory/daffodil-payment-driver-in-memory.mjs",
|
|
50
|
+
"es2020": "./fesm2020/daffodil-payment-driver-in-memory.mjs",
|
|
51
|
+
"es2015": "./fesm2015/daffodil-payment-driver-in-memory.mjs",
|
|
52
|
+
"node": "./fesm2015/daffodil-payment-driver-in-memory.mjs",
|
|
53
|
+
"default": "./fesm2020/daffodil-payment-driver-in-memory.mjs"
|
|
54
|
+
},
|
|
55
|
+
"./driver": {
|
|
56
|
+
"types": "./driver/daffodil-payment-driver.d.ts",
|
|
57
|
+
"esm2020": "./esm2020/driver/daffodil-payment-driver.mjs",
|
|
58
|
+
"es2020": "./fesm2020/daffodil-payment-driver.mjs",
|
|
59
|
+
"es2015": "./fesm2015/daffodil-payment-driver.mjs",
|
|
60
|
+
"node": "./fesm2015/daffodil-payment-driver.mjs",
|
|
61
|
+
"default": "./fesm2020/daffodil-payment-driver.mjs"
|
|
62
|
+
},
|
|
63
|
+
"./driver/testing": {
|
|
64
|
+
"types": "./driver/testing/daffodil-payment-driver-testing.d.ts",
|
|
65
|
+
"esm2020": "./esm2020/driver/testing/daffodil-payment-driver-testing.mjs",
|
|
66
|
+
"es2020": "./fesm2020/daffodil-payment-driver-testing.mjs",
|
|
67
|
+
"es2015": "./fesm2015/daffodil-payment-driver-testing.mjs",
|
|
68
|
+
"node": "./fesm2015/daffodil-payment-driver-testing.mjs",
|
|
69
|
+
"default": "./fesm2020/daffodil-payment-driver-testing.mjs"
|
|
70
|
+
},
|
|
71
|
+
"./state": {
|
|
72
|
+
"types": "./state/daffodil-payment-state.d.ts",
|
|
73
|
+
"esm2020": "./esm2020/state/daffodil-payment-state.mjs",
|
|
74
|
+
"es2020": "./fesm2020/daffodil-payment-state.mjs",
|
|
75
|
+
"es2015": "./fesm2015/daffodil-payment-state.mjs",
|
|
76
|
+
"node": "./fesm2015/daffodil-payment-state.mjs",
|
|
77
|
+
"default": "./fesm2020/daffodil-payment-state.mjs"
|
|
78
|
+
},
|
|
79
|
+
"./state/testing": {
|
|
80
|
+
"types": "./state/testing/daffodil-payment-state-testing.d.ts",
|
|
81
|
+
"esm2020": "./esm2020/state/testing/daffodil-payment-state-testing.mjs",
|
|
82
|
+
"es2020": "./fesm2020/daffodil-payment-state-testing.mjs",
|
|
83
|
+
"es2015": "./fesm2015/daffodil-payment-state-testing.mjs",
|
|
84
|
+
"node": "./fesm2015/daffodil-payment-state-testing.mjs",
|
|
85
|
+
"default": "./fesm2020/daffodil-payment-state-testing.mjs"
|
|
86
|
+
},
|
|
87
|
+
"./testing": {
|
|
88
|
+
"types": "./testing/daffodil-payment-testing.d.ts",
|
|
89
|
+
"esm2020": "./esm2020/testing/daffodil-payment-testing.mjs",
|
|
90
|
+
"es2020": "./fesm2020/daffodil-payment-testing.mjs",
|
|
91
|
+
"es2015": "./fesm2015/daffodil-payment-testing.mjs",
|
|
92
|
+
"node": "./fesm2015/daffodil-payment-testing.mjs",
|
|
93
|
+
"default": "./fesm2020/daffodil-payment-testing.mjs"
|
|
94
|
+
}
|
|
95
|
+
},
|
|
96
|
+
"sideEffects": false,
|
|
97
|
+
"dependencies": {
|
|
98
|
+
"tslib": "^2.3.0"
|
|
99
|
+
}
|
|
100
|
+
}
|
package/public_api.d.ts
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Action } from '@ngrx/store';
|
|
2
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
3
|
+
import { DaffPersonalAddress } from '@daffodil/geography';
|
|
4
|
+
import { DaffPaymentRequest, DaffPaymentResponse } from '@daffodil/payment';
|
|
5
|
+
/**
|
|
6
|
+
* The payment action types enum.
|
|
7
|
+
*/
|
|
8
|
+
export declare enum DaffPaymentActionTypes {
|
|
9
|
+
GenerateTokenSuccessAction = "[@daffodil/payment] Generate Token Success Action",
|
|
10
|
+
GenerateTokenFailureAction = "[@daffodil/payment] Generate Token Failure Action"
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Generates a payment token.
|
|
14
|
+
*
|
|
15
|
+
* @param query The payment query.
|
|
16
|
+
*/
|
|
17
|
+
export interface DaffPaymentGenerateToken<T extends DaffPaymentRequest = DaffPaymentRequest> extends Action {
|
|
18
|
+
readonly request: T;
|
|
19
|
+
readonly address?: DaffPersonalAddress;
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Indicates a successful generation of a payment token.
|
|
23
|
+
*/
|
|
24
|
+
export declare class DaffPaymentGenerateTokenSuccess<T extends DaffPaymentResponse = DaffPaymentResponse> implements Action {
|
|
25
|
+
payload: T;
|
|
26
|
+
readonly type = DaffPaymentActionTypes.GenerateTokenSuccessAction;
|
|
27
|
+
constructor(payload: T);
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* A failed payment with the error message.
|
|
31
|
+
*/
|
|
32
|
+
export declare class DaffPaymentGenerateTokenFailure implements Action {
|
|
33
|
+
payload: DaffStateError;
|
|
34
|
+
readonly type = DaffPaymentActionTypes.GenerateTokenFailureAction;
|
|
35
|
+
constructor(payload: DaffStateError);
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* A union of the payment action types.
|
|
39
|
+
*/
|
|
40
|
+
export declare type DaffPaymentActions<T extends DaffPaymentResponse = DaffPaymentResponse, R extends DaffPaymentRequest = DaffPaymentRequest> = DaffPaymentGenerateToken<R> | DaffPaymentGenerateTokenSuccess<T> | DaffPaymentGenerateTokenFailure;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { Action, Store } from '@ngrx/store';
|
|
2
|
+
import { Observable } from 'rxjs';
|
|
3
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
4
|
+
import { DaffPaymentStateRootSlice } from '../../reducers/public_api';
|
|
5
|
+
import { DaffPaymentPageFacadeInterface } from './interface';
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
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
|
+
}
|
package/state/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public_api';
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { InjectionToken, ValueProvider } from '@angular/core';
|
|
2
|
+
import { DaffPaymentAvailableProcessor } from '../models/public_api';
|
|
3
|
+
/**
|
|
4
|
+
* A multi-provider injection token for registering payment processors.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DAFF_PAYMENT_AVAILABLE_PROCESSORS: InjectionToken<DaffPaymentAvailableProcessor[]>;
|
|
7
|
+
/**
|
|
8
|
+
* Provides a payment processor registration.
|
|
9
|
+
*
|
|
10
|
+
* See {@link DaffPaymentAvailableProcessor}.
|
|
11
|
+
*/
|
|
12
|
+
export declare const daffPaymentProvideAvailableProcessors: (...processors: DaffPaymentAvailableProcessor[]) => ValueProvider[];
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { DaffPaymentProcessorCollection } from '../models/public_api';
|
|
3
|
+
/**
|
|
4
|
+
* An internal token to combine the available payment processors into a single collection.
|
|
5
|
+
*/
|
|
6
|
+
export declare const DAFF_PAYMENT_PROCESSOR_COLLECTION: InjectionToken<DaffPaymentProcessorCollection>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { DaffPaymentRequest } from '@daffodil/payment';
|
|
3
|
+
import { DaffPaymentDriverInterface } from '@daffodil/payment/driver';
|
|
4
|
+
/**
|
|
5
|
+
* A representation of an available payment processor.
|
|
6
|
+
*/
|
|
7
|
+
export interface DaffPaymentAvailableProcessor {
|
|
8
|
+
/**
|
|
9
|
+
* The processor kind.
|
|
10
|
+
*/
|
|
11
|
+
kind: DaffPaymentRequest['kind'];
|
|
12
|
+
/**
|
|
13
|
+
* The action type string that triggers token generation.
|
|
14
|
+
*/
|
|
15
|
+
action: string;
|
|
16
|
+
/**
|
|
17
|
+
* An injection token of the driver that can perform token generation
|
|
18
|
+
* for this specific payment processor.
|
|
19
|
+
*/
|
|
20
|
+
driver: InjectionToken<DaffPaymentDriverInterface>;
|
|
21
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { DaffPaymentAvailableProcessor } from './available-processor.type';
|
|
2
|
+
/**
|
|
3
|
+
* A collection of {@link DaffPaymentAvailableProcessor}s.
|
|
4
|
+
*/
|
|
5
|
+
export declare type DaffPaymentProcessorCollection = Record<DaffPaymentAvailableProcessor['kind'], DaffPaymentAvailableProcessor>;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daffodil/payment/state",
|
|
3
|
+
"module": "../fesm2015/daffodil-payment-state.mjs",
|
|
4
|
+
"es2020": "../fesm2020/daffodil-payment-state.mjs",
|
|
5
|
+
"esm2020": "../esm2020/state/daffodil-payment-state.mjs",
|
|
6
|
+
"fesm2020": "../fesm2020/daffodil-payment-state.mjs",
|
|
7
|
+
"fesm2015": "../fesm2015/daffodil-payment-state.mjs",
|
|
8
|
+
"typings": "daffodil-payment-state.d.ts",
|
|
9
|
+
"sideEffects": false
|
|
10
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
import * as i1 from "@ngrx/store";
|
|
3
|
+
/**
|
|
4
|
+
* Creates the payment feature store.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DaffPaymentStateModule {
|
|
7
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentStateModule, never>;
|
|
8
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentStateModule, never, [typeof i1.StoreFeatureModule], never>;
|
|
9
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentStateModule>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
export * from './actions/payment.actions';
|
|
2
|
+
export * from './reducers/public_api';
|
|
3
|
+
export * from './selectors/public_api';
|
|
4
|
+
export * from './facades/public_api';
|
|
5
|
+
export * from './injection-tokens/public_api';
|
|
6
|
+
export * from './models/public_api';
|
|
7
|
+
export * from './payment.module';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
2
|
+
import { DaffPaymentReducerState } from './interface';
|
|
3
|
+
/**
|
|
4
|
+
* Manages {@link DaffPaymentReducerState}.
|
|
5
|
+
*/
|
|
6
|
+
export declare class DaffPaymentStateReducerAdapter {
|
|
7
|
+
/**
|
|
8
|
+
* Begins the payment operation flow.
|
|
9
|
+
* Sets loading to true.
|
|
10
|
+
*/
|
|
11
|
+
generateToken(state: DaffPaymentReducerState): DaffPaymentReducerState;
|
|
12
|
+
/**
|
|
13
|
+
* Sets loading to false and resets errors.
|
|
14
|
+
*/
|
|
15
|
+
tokenGenerated(state: DaffPaymentReducerState): DaffPaymentReducerState;
|
|
16
|
+
/**
|
|
17
|
+
* Stores the from a failed payment.
|
|
18
|
+
* Also sets loading to false.
|
|
19
|
+
*/
|
|
20
|
+
storeError(error: DaffStateError, state: DaffPaymentReducerState): DaffPaymentReducerState;
|
|
21
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
2
|
+
/**
|
|
3
|
+
* The main payment state.
|
|
4
|
+
* Contains info about the current or most recent payment operation.
|
|
5
|
+
*/
|
|
6
|
+
export interface DaffPaymentReducerState {
|
|
7
|
+
/**
|
|
8
|
+
* Whether there is a pending payment operation.
|
|
9
|
+
*/
|
|
10
|
+
loading: boolean;
|
|
11
|
+
/**
|
|
12
|
+
* A list of payment errors, if any.
|
|
13
|
+
*/
|
|
14
|
+
errors: DaffStateError[];
|
|
15
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { DaffPaymentResponse } from '@daffodil/payment';
|
|
2
|
+
import { DaffPaymentGenerateToken, DaffPaymentActions } from '../../actions/payment.actions';
|
|
3
|
+
import { DaffPaymentReducerState } from './interface';
|
|
4
|
+
/**
|
|
5
|
+
* The reducer for the payment page state, see {@link DaffPaymentReducerState}.
|
|
6
|
+
*/
|
|
7
|
+
export declare const daffPaymentReducerFactory: <T extends DaffPaymentResponse<unknown> = DaffPaymentResponse<unknown>>(actions: DaffPaymentGenerateToken['type'][]) => (state: DaffPaymentReducerState, action: DaffPaymentActions<T, import("@daffodil/payment").DaffPaymentRequest<unknown>>) => DaffPaymentReducerState;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { DaffPaymentReducerState } from './payment/public_api';
|
|
2
|
+
import { DAFF_PAYMENT_STORE_FEATURE_KEY } from './store-feature-key';
|
|
3
|
+
/**
|
|
4
|
+
* The feature state for payment.
|
|
5
|
+
*/
|
|
6
|
+
export interface DaffPaymentReducersState {
|
|
7
|
+
payment: DaffPaymentReducerState;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The footprint of payment feature state in the root application state.
|
|
11
|
+
*/
|
|
12
|
+
export interface DaffPaymentStateRootSlice {
|
|
13
|
+
[DAFF_PAYMENT_STORE_FEATURE_KEY]: DaffPaymentReducersState;
|
|
14
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { InjectionToken, Provider } from '@angular/core';
|
|
2
|
+
import { ActionReducer } from '@ngrx/store';
|
|
3
|
+
import { DaffPaymentReducersState } from '../reducers.interface';
|
|
4
|
+
/**
|
|
5
|
+
* A token to hold the injectable extra reducers.
|
|
6
|
+
*
|
|
7
|
+
* Prefer using {@link daffPaymentProvideExtraReducers}.
|
|
8
|
+
*/
|
|
9
|
+
export declare const DAFF_PAYMENT_EXTRA_REDUCERS: InjectionToken<ActionReducer<DaffPaymentReducersState, import("@ngrx/store").Action>[]>;
|
|
10
|
+
/**
|
|
11
|
+
* Provides additional reducers that run after the standard Daffodil cart reducers.
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* providers: [
|
|
15
|
+
* ...daffPaymentProvideExtraReducers(
|
|
16
|
+
* myReducer1,
|
|
17
|
+
* myReducer2
|
|
18
|
+
* )
|
|
19
|
+
* ]
|
|
20
|
+
* ```
|
|
21
|
+
*/
|
|
22
|
+
export declare function daffPaymentProvideExtraReducers(...reducers: ActionReducer<DaffPaymentReducersState>[]): Provider[];
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { daffPaymentProvideExtraReducers, DAFF_PAYMENT_EXTRA_REDUCERS, } from './extra.token';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { InjectionToken } from '@angular/core';
|
|
2
|
+
import { ActionReducer } from '@ngrx/store';
|
|
3
|
+
import { DaffPaymentReducersState } from '../reducers.interface';
|
|
4
|
+
/**
|
|
5
|
+
* An internal token to hold the Daffodil payment reducers.
|
|
6
|
+
* Includes the extra and standard reducers.
|
|
7
|
+
*
|
|
8
|
+
* @docs-private
|
|
9
|
+
*/
|
|
10
|
+
export declare const DAFF_PAYMENT_REDUCERS: InjectionToken<ActionReducer<DaffPaymentReducersState, import("@ngrx/store").Action>>;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { MemoizedSelector } from '@ngrx/store';
|
|
2
|
+
import { DaffPaymentStateRootSlice, DaffPaymentReducersState } from '../reducers/public_api';
|
|
3
|
+
/**
|
|
4
|
+
* Selector for the payment feature state.
|
|
5
|
+
*/
|
|
6
|
+
export interface DaffPaymentFeatureSelector {
|
|
7
|
+
selectPaymentFeatureState: MemoizedSelector<DaffPaymentStateRootSlice, DaffPaymentReducersState>;
|
|
8
|
+
}
|
|
9
|
+
export declare const getDaffPaymentReducersStateSelector: () => DaffPaymentFeatureSelector;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MemoizedSelector } from '@ngrx/store';
|
|
2
|
+
import { DaffStateError } from '@daffodil/core/state';
|
|
3
|
+
import { DaffPaymentStateRootSlice } from '../reducers/public_api';
|
|
4
|
+
/**
|
|
5
|
+
* Selectors for the main part of payment state.
|
|
6
|
+
*/
|
|
7
|
+
export interface DaffPaymentSelectors {
|
|
8
|
+
/**
|
|
9
|
+
* Selects whether there is a pending payment operation.
|
|
10
|
+
*/
|
|
11
|
+
selectPaymentLoading: MemoizedSelector<DaffPaymentStateRootSlice, boolean>;
|
|
12
|
+
/**
|
|
13
|
+
* Selects the list of payment errors, if any.
|
|
14
|
+
*/
|
|
15
|
+
selectPaymentErrors: MemoizedSelector<DaffPaymentStateRootSlice, DaffStateError[]>;
|
|
16
|
+
}
|
|
17
|
+
export declare const daffPaymentGetSelectors: () => DaffPaymentSelectors;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './payment.selector';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './public_api';
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
* Mocks out facade fields and methods for testing purposes.
|
|
8
|
+
*
|
|
9
|
+
* @inheritdoc
|
|
10
|
+
*/
|
|
11
|
+
export declare class MockDaffPaymentPageFacade implements DaffPaymentPageFacadeInterface {
|
|
12
|
+
loading$: BehaviorSubject<boolean>;
|
|
13
|
+
errors$: BehaviorSubject<DaffStateError[]>;
|
|
14
|
+
dispatch(action: Action): void;
|
|
15
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<MockDaffPaymentPageFacade, never>;
|
|
16
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<MockDaffPaymentPageFacade>;
|
|
17
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@daffodil/payment/state/testing",
|
|
3
|
+
"module": "../../fesm2015/daffodil-payment-state-testing.mjs",
|
|
4
|
+
"es2020": "../../fesm2020/daffodil-payment-state-testing.mjs",
|
|
5
|
+
"esm2020": "../../esm2020/state/testing/daffodil-payment-state-testing.mjs",
|
|
6
|
+
"fesm2020": "../../fesm2020/daffodil-payment-state-testing.mjs",
|
|
7
|
+
"fesm2015": "../../fesm2015/daffodil-payment-state-testing.mjs",
|
|
8
|
+
"typings": "daffodil-payment-state-testing.d.ts",
|
|
9
|
+
"sideEffects": false
|
|
10
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import * as i0 from "@angular/core";
|
|
2
|
+
/**
|
|
3
|
+
* Provides the {@link MockDaffPaymentPageFacade} for {@link DaffPaymentPageFacade}.
|
|
4
|
+
*/
|
|
5
|
+
export declare class DaffPaymentStateTestingModule {
|
|
6
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentStateTestingModule, never>;
|
|
7
|
+
static ɵmod: i0.ɵɵNgModuleDeclaration<DaffPaymentStateTestingModule, never, never, never>;
|
|
8
|
+
static ɵinj: i0.ɵɵInjectorDeclaration<DaffPaymentStateTestingModule>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DaffModelFactory } from '@daffodil/core/testing';
|
|
2
|
+
import { DaffPaymentResponse } from '@daffodil/payment';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Factory for creating DaffPaymentResponses.
|
|
6
|
+
* This will create a payment response of random kind.
|
|
7
|
+
*/
|
|
8
|
+
export declare class DaffPaymentResponseKindFactory extends DaffModelFactory<DaffPaymentResponse> {
|
|
9
|
+
private kindFactories;
|
|
10
|
+
constructor(kindFactories: DaffModelFactory<DaffPaymentResponse>[]);
|
|
11
|
+
private get _randomFactory();
|
|
12
|
+
/**
|
|
13
|
+
* Creates a payment result of random kind.
|
|
14
|
+
*/
|
|
15
|
+
create(partial?: {}): DaffPaymentResponse;
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentResponseKindFactory, never>;
|
|
17
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentResponseKindFactory>;
|
|
18
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { DaffModelFactory } from '@daffodil/core/testing';
|
|
2
|
+
import { DaffPaymentRequest } from '@daffodil/payment';
|
|
3
|
+
import * as i0 from "@angular/core";
|
|
4
|
+
/**
|
|
5
|
+
* Mock class for {@link DaffPaymentRequest}.
|
|
6
|
+
*/
|
|
7
|
+
export declare class MockPaymentRequest implements DaffPaymentRequest {
|
|
8
|
+
kind: any;
|
|
9
|
+
data: any;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Model factory for {@link DaffPaymentRequest}.
|
|
13
|
+
*/
|
|
14
|
+
export declare class DaffPaymentRequestFactory extends DaffModelFactory<DaffPaymentRequest> {
|
|
15
|
+
constructor();
|
|
16
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<DaffPaymentRequestFactory, never>;
|
|
17
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<DaffPaymentRequestFactory>;
|
|
18
|
+
}
|