@owlmeans/payment 0.1.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 (88) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +524 -0
  3. package/build/.gitkeep +0 -0
  4. package/build/consts.d.ts +62 -0
  5. package/build/consts.d.ts.map +1 -0
  6. package/build/consts.js +87 -0
  7. package/build/consts.js.map +1 -0
  8. package/build/errors.d.ts +42 -0
  9. package/build/errors.d.ts.map +1 -0
  10. package/build/errors.js +81 -0
  11. package/build/errors.js.map +1 -0
  12. package/build/helper.d.ts +3 -0
  13. package/build/helper.d.ts.map +1 -0
  14. package/build/helper.js +3 -0
  15. package/build/helper.js.map +1 -0
  16. package/build/i18n/en.json +39 -0
  17. package/build/i18n.d.ts +2 -0
  18. package/build/i18n.d.ts.map +1 -0
  19. package/build/i18n.js +4 -0
  20. package/build/i18n.js.map +1 -0
  21. package/build/index.d.ts +9 -0
  22. package/build/index.d.ts.map +1 -0
  23. package/build/index.js +8 -0
  24. package/build/index.js.map +1 -0
  25. package/build/model/index.d.ts +6 -0
  26. package/build/model/index.d.ts.map +1 -0
  27. package/build/model/index.js +6 -0
  28. package/build/model/index.js.map +1 -0
  29. package/build/model/localization.d.ts +4 -0
  30. package/build/model/localization.d.ts.map +1 -0
  31. package/build/model/localization.js +19 -0
  32. package/build/model/localization.js.map +1 -0
  33. package/build/model/plan.d.ts +4 -0
  34. package/build/model/plan.d.ts.map +1 -0
  35. package/build/model/plan.js +43 -0
  36. package/build/model/plan.js.map +1 -0
  37. package/build/model/product.d.ts +4 -0
  38. package/build/model/product.d.ts.map +1 -0
  39. package/build/model/product.js +17 -0
  40. package/build/model/product.js.map +1 -0
  41. package/build/model/subscription.d.ts +5 -0
  42. package/build/model/subscription.d.ts.map +1 -0
  43. package/build/model/subscription.js +46 -0
  44. package/build/model/subscription.js.map +1 -0
  45. package/build/model/utils.d.ts +5 -0
  46. package/build/model/utils.d.ts.map +1 -0
  47. package/build/model/utils.js +28 -0
  48. package/build/model/utils.js.map +1 -0
  49. package/build/modules.d.ts +2 -0
  50. package/build/modules.d.ts.map +1 -0
  51. package/build/modules.js +9 -0
  52. package/build/modules.js.map +1 -0
  53. package/build/service.d.ts +5 -0
  54. package/build/service.d.ts.map +1 -0
  55. package/build/service.js +71 -0
  56. package/build/service.js.map +1 -0
  57. package/build/types.d.ts +116 -0
  58. package/build/types.d.ts.map +1 -0
  59. package/build/types.js +2 -0
  60. package/build/types.js.map +1 -0
  61. package/build/utils/index.d.ts +2 -0
  62. package/build/utils/index.d.ts.map +1 -0
  63. package/build/utils/index.js +2 -0
  64. package/build/utils/index.js.map +1 -0
  65. package/build/utils/types.d.ts +7 -0
  66. package/build/utils/types.d.ts.map +1 -0
  67. package/build/utils/types.js +2 -0
  68. package/build/utils/types.js.map +1 -0
  69. package/package.json +52 -0
  70. package/src/consts.ts +100 -0
  71. package/src/errors.ts +102 -0
  72. package/src/helper.ts +5 -0
  73. package/src/i18n/en.json +39 -0
  74. package/src/i18n.ts +6 -0
  75. package/src/index.ts +9 -0
  76. package/src/model/index.ts +6 -0
  77. package/src/model/localization.ts +24 -0
  78. package/src/model/plan.ts +51 -0
  79. package/src/model/product.ts +21 -0
  80. package/src/model/subscription.ts +49 -0
  81. package/src/model/utils.ts +32 -0
  82. package/src/modules.ts +15 -0
  83. package/src/service.ts +95 -0
  84. package/src/types.ts +119 -0
  85. package/src/utils/index.ts +2 -0
  86. package/src/utils/types.ts +9 -0
  87. package/tsconfig.json +15 -0
  88. package/tsconfig.tsbuildinfo +1 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"consts.js","sourceRoot":"","sources":["../src/consts.ts"],"names":[],"mappings":"AAEA,MAAM,CAAN,IAAY,WAGX;AAHD,WAAY,WAAW;IACrB,gCAAiB,CAAA;IACjB,kCAAmB,CAAA;AACrB,CAAC,EAHW,WAAW,KAAX,WAAW,QAGtB;AAED,MAAM,CAAN,IAAY,iBAIX;AAJ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,MAAM,kBAAkB,GAAiC;IAC9D,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;CAClC,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAAuC;IAC1E,IAAI,EAAE,QAAQ;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,CAAC,kBAAkB,CAAC;CACxC,CAAA;AAED,MAAM,CAAC,MAAM,kBAAkB,GAA2B;IACxD,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,GAAG;CAC7C,CAAA;AAED,MAAM,CAAC,MAAM,wBAAwB,GAA2B;IAC9D,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI;CAC9D,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAA2B;IAC3D,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,CAAC,EAAE,SAAS,EAAE,CAAC;CAC3C,CAAA;AAED,MAAM,CAAC,MAAM,mBAAmB,GAAG,SAAS,CAAA;AAC5C,MAAM,CAAC,MAAM,qBAAqB,GAAG,mBAAmB,CAAA;AAExD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;AAElD,MAAM,CAAC,MAAM,gBAAgB,GAAG,MAAM,CAAA;AACtC,MAAM,CAAC,MAAM,kBAAkB,GAAG,gBAAgB,CAAA;AAElD,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAA;AAEtC,MAAM,CAAC,MAAM,UAAU,GAAG;IACxB,YAAY,EAAE;QACZ,IAAI,EAAE,0BAA0B;QAChC,SAAS,EAAE,oCAAoC;KAChD;CACF,CAAA"}
@@ -0,0 +1,42 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ export declare class PaymentError extends ResilientError {
3
+ static typeName: string;
4
+ constructor(message?: string);
5
+ }
6
+ export declare class PaygateError extends PaymentError {
7
+ static typeName: string;
8
+ constructor(message?: string);
9
+ }
10
+ export declare class UnknownPaygate extends PaygateError {
11
+ static typeName: string;
12
+ constructor(message?: string);
13
+ }
14
+ export declare class PaygateMappingError extends PaygateError {
15
+ static typeName: string;
16
+ constructor(message?: string);
17
+ }
18
+ export declare class ProductError extends PaymentError {
19
+ static typeName: string;
20
+ constructor(message?: string);
21
+ }
22
+ export declare class UnknownProduct extends ProductError {
23
+ static typeName: string;
24
+ constructor(message?: string);
25
+ }
26
+ export declare class UnknownPlan extends ProductError {
27
+ static typeName: string;
28
+ constructor(message?: string);
29
+ }
30
+ export declare class PaymentIdentificationError extends PaymentError {
31
+ static typeName: string;
32
+ constructor(message?: string);
33
+ }
34
+ export declare class SubscriptionError extends PaymentError {
35
+ static typeName: string;
36
+ constructor(message?: string);
37
+ }
38
+ export declare class UnknownSubscription extends SubscriptionError {
39
+ static typeName: string;
40
+ constructor(message?: string);
41
+ }
42
+ //# sourceMappingURL=errors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAEhD,qBAAa,YAAa,SAAQ,cAAc;IAC9C,OAAuB,QAAQ,EAAE,MAAM,CAAiB;gBAE5C,OAAO,GAAE,MAAgB;CAGtC;AAED,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAuB,QAAQ,EAAE,MAAM,CAAoC;gBAE/D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAuB,QAAQ,EAAE,MAAM,CAAoC;gBAE/D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,mBAAoB,SAAQ,YAAY;IACnD,OAAuB,QAAQ,EAAE,MAAM,CAAoC;gBAE/D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,YAAa,SAAQ,YAAY;IAC5C,OAAuB,QAAQ,EAAE,MAAM,CAAoC;gBAE/D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,cAAe,SAAQ,YAAY;IAC9C,OAAuB,QAAQ,EAAE,MAAM,CAAoC;gBAE/D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,WAAY,SAAQ,YAAY;IAC3C,OAAuB,QAAQ,EAAE,MAAM,CAAiC;gBAE5D,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,0BAA2B,SAAQ,YAAY;IAC1D,OAAuB,QAAQ,EAAE,MAAM,CAA2C;gBAEtE,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,iBAAkB,SAAQ,YAAY;IACjD,OAAuB,QAAQ,EAAE,MAAM,CAAyC;gBAEpE,OAAO,GAAE,MAAgB;CAItC;AAED,qBAAa,mBAAoB,SAAQ,iBAAiB;IACxD,OAAuB,QAAQ,EAAE,MAAM,CAAyC;gBAEpE,OAAO,GAAE,MAAgB;CAItC"}
@@ -0,0 +1,81 @@
1
+ import { ResilientError } from '@owlmeans/error';
2
+ export class PaymentError extends ResilientError {
3
+ static typeName = 'PaymentError';
4
+ constructor(message = 'error') {
5
+ super(PaymentError.typeName, `payment:${message}`);
6
+ }
7
+ }
8
+ export class PaygateError extends PaymentError {
9
+ static typeName = `${PaymentError.typeName}Paygate`;
10
+ constructor(message = 'error') {
11
+ super(`paygate:${message}`);
12
+ this.type = PaygateError.typeName;
13
+ }
14
+ }
15
+ export class UnknownPaygate extends PaygateError {
16
+ static typeName = `${PaygateError.typeName}Unknown`;
17
+ constructor(message = 'error') {
18
+ super(`unknown:${message}`);
19
+ this.type = UnknownPaygate.typeName;
20
+ }
21
+ }
22
+ export class PaygateMappingError extends PaygateError {
23
+ static typeName = `${PaygateError.typeName}Mapping`;
24
+ constructor(message = 'error') {
25
+ super(`mapping:${message}`);
26
+ this.type = PaygateMappingError.typeName;
27
+ }
28
+ }
29
+ export class ProductError extends PaymentError {
30
+ static typeName = `${PaymentError.typeName}Product`;
31
+ constructor(message = 'error') {
32
+ super(`product:${message}`);
33
+ this.type = ProductError.typeName;
34
+ }
35
+ }
36
+ export class UnknownProduct extends ProductError {
37
+ static typeName = `${ProductError.typeName}Unknown`;
38
+ constructor(message = 'error') {
39
+ super(`unknown:${message}`);
40
+ this.type = UnknownProduct.typeName;
41
+ }
42
+ }
43
+ export class UnknownPlan extends ProductError {
44
+ static typeName = `${ProductError.typeName}Plan`;
45
+ constructor(message = 'error') {
46
+ super(`unknown:${message}`);
47
+ this.type = UnknownPlan.typeName;
48
+ }
49
+ }
50
+ export class PaymentIdentificationError extends PaymentError {
51
+ static typeName = `${PaymentError.typeName}Identification`;
52
+ constructor(message = 'error') {
53
+ super(`identification:${message}`);
54
+ this.type = PaymentIdentificationError.typeName;
55
+ }
56
+ }
57
+ export class SubscriptionError extends PaymentError {
58
+ static typeName = `${PaymentError.typeName}Subscription`;
59
+ constructor(message = 'error') {
60
+ super(`subscription:${message}`);
61
+ this.type = SubscriptionError.typeName;
62
+ }
63
+ }
64
+ export class UnknownSubscription extends SubscriptionError {
65
+ static typeName = `${SubscriptionError.typeName}Unknown`;
66
+ constructor(message = 'error') {
67
+ super(`unknown:${message}`);
68
+ this.type = UnknownSubscription.typeName;
69
+ }
70
+ }
71
+ ResilientError.registerErrorClass(PaymentError);
72
+ ResilientError.registerErrorClass(PaygateError);
73
+ ResilientError.registerErrorClass(UnknownPaygate);
74
+ ResilientError.registerErrorClass(PaygateMappingError);
75
+ ResilientError.registerErrorClass(ProductError);
76
+ ResilientError.registerErrorClass(UnknownProduct);
77
+ ResilientError.registerErrorClass(UnknownPlan);
78
+ ResilientError.registerErrorClass(PaymentIdentificationError);
79
+ ResilientError.registerErrorClass(SubscriptionError);
80
+ ResilientError.registerErrorClass(UnknownSubscription);
81
+ //# sourceMappingURL=errors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"m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,IAAI,CAAC,IAAI,GAAG,mBAAmB,CAAC,QAAQ,CAAA;IAC1C,CAAC;;AAGH,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;AACjD,cAAc,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA;AACtD,cAAc,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAA;AAC/C,cAAc,CAAC,kBAAkB,CAAC,cAAc,CAAC,CAAA;AACjD,cAAc,CAAC,kBAAkB,CAAC,WAAW,CAAC,CAAA;AAC9C,cAAc,CAAC,kBAAkB,CAAC,0BAA0B,CAAC,CAAA;AAC7D,cAAc,CAAC,kBAAkB,CAAC,iBAAiB,CAAC,CAAA;AACpD,cAAc,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,CAAA"}
@@ -0,0 +1,3 @@
1
+ import type { Localization } from './types.js';
2
+ export declare const l10nToId: (l10n: Localization, prefix?: boolean) => string;
3
+ //# sourceMappingURL=helper.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.d.ts","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAE9C,eAAO,MAAM,QAAQ,SAAU,YAAY,WAAW,OAAO,KAAG,MACiB,CAAA"}
@@ -0,0 +1,3 @@
1
+ import { L10N_RECORD_PREFIX } from './consts.js';
2
+ export const l10nToId = (l10n, prefix) => `${prefix ? L10N_RECORD_PREFIX + ':' : ''}${l10n.type}:${l10n.sku}:${l10n.lng}`;
3
+ //# sourceMappingURL=helper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"helper.js","sourceRoot":"","sources":["../src/helper.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAA;AAGhD,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,IAAkB,EAAE,MAAgB,EAAU,EAAE,CACvE,GAAG,MAAM,CAAC,CAAC,CAAC,kBAAkB,GAAG,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,IAAI,IAAI,IAAI,CAAC,GAAG,IAAI,IAAI,CAAC,GAAG,EAAE,CAAA"}
@@ -0,0 +1,39 @@
1
+ {
2
+ "plan": {
3
+ "duration": {
4
+ "monthly": "Montly subscription",
5
+ "yearly": "Yerly subscription"
6
+ },
7
+ "trial": {
8
+ "gated": "Free trial — {{days}} days",
9
+ "open": "No card required — {{days}} free trial"
10
+ },
11
+ "highlight": {
12
+ "custom": "Tell us about your custom needs",
13
+ "comming-soon": "Required features comming soon!",
14
+ "best-value": "Best value!"
15
+ },
16
+ "label": {
17
+ "monthly": "a month",
18
+ "discount": "with discount: {{discount}}%"
19
+ }
20
+ },
21
+ "measurement": {
22
+ "yes": "Yes",
23
+ "no": "No",
24
+ "comming-soon": "Comming soon",
25
+ "custom": "custom",
26
+ "mb": "Mb"
27
+ },
28
+ "action": {
29
+ "start": "Start now",
30
+ "custom": "Contact us",
31
+ "active": "Try now",
32
+ "gated": "Subscribe now",
33
+ "best-value": "Start free trial",
34
+ "comming-soon": "Join now"
35
+ },
36
+ "success": {
37
+ "guideline": "Your payment is processing. You will be redirected to the service soon..."
38
+ }
39
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=i18n.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.d.ts","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":""}
package/build/i18n.js ADDED
@@ -0,0 +1,4 @@
1
+ import { addI18nLib } from '@owlmeans/i18n';
2
+ import en from './i18n/en.json' with { type: "json" };
3
+ addI18nLib('en', 'payment', en);
4
+ //# sourceMappingURL=i18n.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"i18n.js","sourceRoot":"","sources":["../src/i18n.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,OAAO,EAAE,MAAM,gBAAgB,CAAC,OAAM,IAAI,EAAE,MAAM,EAAC,CAAA;AAEnD,UAAU,CAAC,IAAI,EAAE,SAAS,EAAE,EAAE,CAAC,CAAA"}
@@ -0,0 +1,9 @@
1
+ export type * from './types.js';
2
+ export * from './model/index.js';
3
+ export * from './errors.js';
4
+ export * from './consts.js';
5
+ export * from './service.js';
6
+ export * from './i18n.js';
7
+ export * from './helper.js';
8
+ export * from './modules.js';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,mBAAmB,YAAY,CAAA;AAC/B,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
package/build/index.js ADDED
@@ -0,0 +1,8 @@
1
+ export * from './model/index.js';
2
+ export * from './errors.js';
3
+ export * from './consts.js';
4
+ export * from './service.js';
5
+ export * from './i18n.js';
6
+ export * from './helper.js';
7
+ export * from './modules.js';
8
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,aAAa,CAAA;AAC3B,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA;AAC5B,cAAc,WAAW,CAAA;AACzB,cAAc,aAAa,CAAA;AAC3B,cAAc,cAAc,CAAA"}
@@ -0,0 +1,6 @@
1
+ export * from './product.js';
2
+ export * from './localization.js';
3
+ export * from './subscription.js';
4
+ export * from './plan.js';
5
+ export * from './utils.js';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
@@ -0,0 +1,6 @@
1
+ export * from './product.js';
2
+ export * from './localization.js';
3
+ export * from './subscription.js';
4
+ export * from './plan.js';
5
+ export * from './utils.js';
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/model/index.ts"],"names":[],"mappings":"AACA,cAAc,cAAc,CAAA;AAC5B,cAAc,mBAAmB,CAAA;AACjC,cAAc,mBAAmB,CAAA;AACjC,cAAc,WAAW,CAAA;AACzB,cAAc,YAAY,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import type { Localization } from '../types.js';
3
+ export declare const LocalizationSchema: JSONSchemaType<Localization>;
4
+ //# sourceMappingURL=localization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization.d.ts","sourceRoot":"","sources":["../../src/model/localization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAA;AAO/C,eAAO,MAAM,kBAAkB,EAAE,cAAc,CAAC,YAAY,CAe3D,CAAA"}
@@ -0,0 +1,19 @@
1
+ import { ProductDescriptionSchema, ProductTitleSchema, PaymentEntityTypeSchema, LocalizationLngSchema } from '../consts.js';
2
+ import { IdValueSchema } from '@owlmeans/auth';
3
+ export const LocalizationSchema = {
4
+ type: 'object',
5
+ properties: {
6
+ type: PaymentEntityTypeSchema,
7
+ sku: IdValueSchema,
8
+ lng: LocalizationLngSchema,
9
+ title: { ...ProductTitleSchema, nullable: true },
10
+ description: { ...ProductDescriptionSchema, nullable: true },
11
+ keywords: {
12
+ type: 'object', required: [], nullable: true,
13
+ additionalProperties: { type: 'string' }
14
+ }
15
+ },
16
+ required: ['type', 'sku', 'lng'],
17
+ additionalProperties: false,
18
+ };
19
+ //# sourceMappingURL=localization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"localization.js","sourceRoot":"","sources":["../../src/model/localization.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,wBAAwB,EAAE,kBAAkB,EAAE,uBAAuB,EACrE,qBAAqB,EACtB,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AAE9C,MAAM,CAAC,MAAM,kBAAkB,GAAiC;IAC9D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,IAAI,EAAE,uBAAuB;QAC7B,GAAG,EAAE,aAAa;QAClB,GAAG,EAAE,qBAAqB;QAC1B,KAAK,EAAE,EAAE,GAAG,kBAAkB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAChD,WAAW,EAAE,EAAE,GAAG,wBAAwB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC5D,QAAQ,EAAE;YACR,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI;YAC5C,oBAAoB,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;SACzC;KACF;IACD,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC;IAChC,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
@@ -0,0 +1,4 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import type { ProductPlan } from '../types.js';
3
+ export declare const ProductPlanSchema: JSONSchemaType<ProductPlan>;
4
+ //# sourceMappingURL=plan.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plan.d.ts","sourceRoot":"","sources":["../../src/model/plan.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAQ9C,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CAyCzD,CAAA"}
@@ -0,0 +1,43 @@
1
+ import { ResourceValueSchema, PermissionSetSchema, DateSchema } from '@owlmeans/auth';
2
+ import { PlanDurationSchema, ProductDescriptionSchema, ProductTitleSchema, SubscriptionStatusSchema } from '../consts.js';
3
+ import { LimitConfigSchema } from './utils.js';
4
+ export const ProductPlanSchema = {
5
+ type: 'object',
6
+ properties: {
7
+ productSku: ResourceValueSchema,
8
+ sku: ResourceValueSchema,
9
+ status: SubscriptionStatusSchema,
10
+ payagateAliases: {
11
+ type: 'object', required: [], nullable: true,
12
+ additionalProperties: { type: 'string' },
13
+ },
14
+ duration: PlanDurationSchema,
15
+ trial: { type: 'number', nullable: true },
16
+ gatedTrial: { type: 'boolean', nullable: true },
17
+ price: { type: 'number', minimum: 0 },
18
+ order: { type: 'number', nullable: true },
19
+ highlight: { type: 'string', minLength: 1, maxLength: 32, nullable: true },
20
+ currency: { type: 'string', minLength: 2, maxLength: 3, nullable: true },
21
+ originalPrice: { type: 'number', minimum: 0, nullable: true },
22
+ discount: { type: 'number', minimum: 0, nullable: true },
23
+ awaitingInterval: { type: 'number', minimum: 0, nullable: true },
24
+ title: ProductTitleSchema,
25
+ description: { ...ProductDescriptionSchema, nullable: true },
26
+ customUrl: { type: 'string', maxLength: 256, nullable: true },
27
+ createdAt: { ...DateSchema, nullable: true },
28
+ archivedAt: { ...DateSchema, nullable: true },
29
+ deprecatedAt: { ...DateSchema, nullable: true },
30
+ supsendedAt: { ...DateSchema, nullable: true },
31
+ capabilities: { type: 'array', items: PermissionSetSchema, nullable: true },
32
+ limits: {
33
+ type: 'object', required: [], nullable: true,
34
+ additionalProperties: LimitConfigSchema
35
+ },
36
+ },
37
+ required: [
38
+ 'productSku', 'sku', 'status', 'duration',
39
+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type { Product } from '../types.js';
3
+ export declare const ProductSchema: JSONSchemaType<Product>;
4
+ //# sourceMappingURL=product.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.d.ts","sourceRoot":"","sources":["../../src/model/product.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,aAAa,CAAA;AAM1C,eAAO,MAAM,aAAa,EAAE,cAAc,CAAC,OAAO,CAajD,CAAA"}
@@ -0,0 +1,17 @@
1
+ import { LocalizationLngSchema, ProductDescriptionSchema, ProductTitleSchema, ProductTypeSchema } from '../consts.js';
2
+ import { ResourceValueSchema, PermissionSetSchema } from '@owlmeans/auth';
3
+ export const ProductSchema = {
4
+ type: 'object',
5
+ properties: {
6
+ type: ProductTypeSchema,
7
+ sku: ResourceValueSchema,
8
+ title: ProductTitleSchema,
9
+ description: { ...ProductDescriptionSchema, nullable: true },
10
+ defaultLng: { ...LocalizationLngSchema, nullable: true },
11
+ services: { type: 'array', items: ResourceValueSchema, nullable: true },
12
+ capabilities: { type: 'array', items: PermissionSetSchema, nullable: true }
13
+ },
14
+ required: ['type', 'sku', 'title'],
15
+ additionalProperties: false,
16
+ };
17
+ //# sourceMappingURL=product.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"product.js","sourceRoot":"","sources":["../../src/model/product.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,qBAAqB,EAAE,wBAAwB,EAAE,kBAAkB,EAAE,iBAAiB,EACvF,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAA;AAEzE,MAAM,CAAC,MAAM,aAAa,GAA4B;IACpD,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,IAAI,EAAE,iBAAiB;QACvB,GAAG,EAAE,mBAAmB;QACxB,KAAK,EAAE,kBAAkB;QACzB,WAAW,EAAE,EAAE,GAAG,wBAAwB,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC5D,UAAU,EAAE,EAAE,GAAG,qBAAqB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACxD,QAAQ,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;QACvE,YAAY,EAAE,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,IAAI,EAAE;KAC5E;IACD,QAAQ,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,OAAO,CAAC;IAClC,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import type { PlanSubscription, SubscriptionPropogateBody } from '../types.js';
3
+ export declare const PlanSubscriptionSchema: JSONSchemaType<PlanSubscription>;
4
+ export declare const SubscriptionPropogateBodySchema: JSONSchemaType<SubscriptionPropogateBody>;
5
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../../src/model/subscription.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,gBAAgB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAA;AAK9E,eAAO,MAAM,sBAAsB,EAAE,cAAc,CAAC,gBAAgB,CA+BnE,CAAA;AAED,eAAO,MAAM,+BAA+B,EAAE,cAAc,CAAC,yBAAyB,CASrF,CAAA"}
@@ -0,0 +1,46 @@
1
+ import { ResourceValueSchema, PermissionSetSchema, DateSchema, EntityValueSchema, IdValueSchema } from '@owlmeans/auth';
2
+ import { SubscriptionStatusSchema } from '../consts.js';
3
+ import { CapabilityUsageSchema, LimitConfigSchema } from './utils.js';
4
+ export const PlanSubscriptionSchema = {
5
+ type: 'object',
6
+ properties: {
7
+ sku: ResourceValueSchema,
8
+ entityId: EntityValueSchema,
9
+ paymentMethod: { ...IdValueSchema, nullable: true },
10
+ externalId: { ...IdValueSchema, nullable: true },
11
+ createdAt: DateSchema,
12
+ lastPaymentAt: { ...DateSchema, nullable: true },
13
+ trialUntil: { ...DateSchema, nullable: true },
14
+ startsdAt: DateSchema,
15
+ expirationAt: { ...DateSchema, nullable: true },
16
+ endsAt: { ...DateSchema, nullable: true },
17
+ archiveAt: { ...DateSchema, nullable: true },
18
+ suspendedAt: { ...DateSchema, nullable: true },
19
+ canceledAt: { ...DateSchema, nullable: true },
20
+ blockedAt: { ...DateSchema, nullable: true },
21
+ suspendedUntil: { ...DateSchema, nullable: true },
22
+ status: SubscriptionStatusSchema,
23
+ capabilities: { type: 'array', items: PermissionSetSchema, nullable: true },
24
+ limits: {
25
+ type: 'object', required: [], nullable: true,
26
+ additionalProperties: LimitConfigSchema
27
+ },
28
+ consumptions: {
29
+ type: 'object', required: [], nullable: true,
30
+ additionalProperties: CapabilityUsageSchema
31
+ }
32
+ },
33
+ required: ['sku', 'entityId', 'createdAt', 'startsdAt', 'status'],
34
+ additionalProperties: false,
35
+ };
36
+ export const SubscriptionPropogateBodySchema = {
37
+ type: 'object',
38
+ properties: {
39
+ ...PlanSubscriptionSchema.properties,
40
+ service: { ...ResourceValueSchema, minLength: 2 },
41
+ externalId: IdValueSchema,
42
+ }, // @TODO Figure out why it doesn't work (probably different version of ajv)
43
+ required: ['externalId', 'service', ...PlanSubscriptionSchema.required],
44
+ additionalProperties: false,
45
+ };
46
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../../src/model/subscription.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,UAAU,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAA;AACvH,OAAO,EAAE,wBAAwB,EAAE,MAAM,cAAc,CAAA;AAC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AAE,iBAAiB;SACxC;QACD,YAAY,EAAE;YACZ,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE,IAAI;YAC5C,oBAAoB,EAAE,qBAAqB;SAC5C;KACF;IACD,QAAQ,EAAE,CAAC,KAAK,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,CAAC;IACjE,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,+BAA+B,GAA8C;IACxF,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,GAAG,sBAAsB,CAAC,UAAU;QACpC,OAAO,EAAE,EAAE,GAAG,mBAAmB,EAAE,SAAS,EAAE,CAAC,EAAE;QACjD,UAAU,EAAE,aAAa;KACnB,EAAE,2EAA2E;IACrF,QAAQ,EAAE,CAAC,YAAY,EAAE,SAAS,EAAE,GAAG,sBAAsB,CAAC,QAAQ,CAAC;IACvE,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { JSONSchemaType } from 'ajv';
2
+ import type { LimitConfig, CapabilityUsage } from '../types.js';
3
+ export declare const LimitConfigSchema: JSONSchemaType<LimitConfig>;
4
+ export declare const CapabilityUsageSchema: JSONSchemaType<CapabilityUsage>;
5
+ //# sourceMappingURL=utils.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/model/utils.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,KAAK,CAAA;AACzC,OAAO,KAAK,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAA;AAI/D,eAAO,MAAM,iBAAiB,EAAE,cAAc,CAAC,WAAW,CASzD,CAAA;AAED,eAAO,MAAM,qBAAqB,EAAE,cAAc,CAAC,eAAe,CAcjE,CAAA"}
@@ -0,0 +1,28 @@
1
+ import { PlanDurationSchema } from '../consts.js';
2
+ import { DateSchema } from '@owlmeans/auth';
3
+ export const LimitConfigSchema = {
4
+ type: 'object',
5
+ properties: {
6
+ interval: PlanDurationSchema,
7
+ measurment: { type: 'string', nullable: true, maxLength: 16 },
8
+ limit: { type: 'number' }
9
+ },
10
+ required: ['interval', 'limit'],
11
+ additionalProperties: false,
12
+ };
13
+ export const CapabilityUsageSchema = {
14
+ type: 'object',
15
+ properties: {
16
+ interval: PlanDurationSchema,
17
+ measurment: { type: 'string', nullable: true, maxLength: 16 },
18
+ startedAt: DateSchema,
19
+ limit: { type: 'number' },
20
+ refreshedAt: { ...DateSchema, nullable: true },
21
+ refreshAt: { ...DateSchema, nullable: true },
22
+ lastConsumedAt: { ...DateSchema, nullable: true },
23
+ consumption: { type: 'number' }
24
+ },
25
+ required: ['interval', 'limit', 'startedAt', 'consumption'],
26
+ additionalProperties: false,
27
+ };
28
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/model/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAA;AACjD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AAE3C,MAAM,CAAC,MAAM,iBAAiB,GAAgC;IAC5D,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,kBAAkB;QAC5B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;QAC7D,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAC1B;IACD,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,CAAC;IAC/B,oBAAoB,EAAE,KAAK;CAC5B,CAAA;AAED,MAAM,CAAC,MAAM,qBAAqB,GAAoC;IACpE,IAAI,EAAE,QAAQ;IACd,UAAU,EAAE;QACV,QAAQ,EAAE,kBAAkB;QAC5B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,EAAE;QAC7D,SAAS,EAAE,UAAU;QACrB,KAAK,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QACzB,WAAW,EAAE,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC9C,SAAS,EAAE,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QAC5C,cAAc,EAAE,EAAE,GAAG,UAAU,EAAE,QAAQ,EAAE,IAAI,EAAE;QACjD,WAAW,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KAChC;IACD,QAAQ,EAAE,CAAC,UAAU,EAAE,OAAO,EAAE,WAAW,EAAE,aAAa,CAAC;IAC3D,oBAAoB,EAAE,KAAK;CAC5B,CAAA"}
@@ -0,0 +1,2 @@
1
+ export declare const modules: import("@owlmeans/module").CommonModule[];
2
+ //# sourceMappingURL=modules.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.d.ts","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAKA,eAAO,MAAM,OAAO,2CASnB,CAAA"}
@@ -0,0 +1,9 @@
1
+ import { body, filter, module } from '@owlmeans/module';
2
+ import { route, backend, RouteMethod } from '@owlmeans/route';
3
+ import { paymentApi } from './consts.js';
4
+ import { SubscriptionPropogateBodySchema } from './model/subscription.js';
5
+ export const modules = [
6
+ module(route(paymentApi.subscription.base, '/subscription', backend())),
7
+ module(route(paymentApi.subscription.propogate, '/propogate', backend(paymentApi.subscription.base, RouteMethod.POST)), filter(body(SubscriptionPropogateBodySchema)))
8
+ ];
9
+ //# sourceMappingURL=modules.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modules.js","sourceRoot":"","sources":["../src/modules.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAA;AAC7D,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAA;AACxC,OAAO,EAAE,+BAA+B,EAAE,MAAM,yBAAyB,CAAA;AAEzE,MAAM,CAAC,MAAM,OAAO,GAAG;IACrB,MAAM,CAAC,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,IAAI,EAAE,eAAe,EAAE,OAAO,EAAE,CAAC,CAAC;IACvE,MAAM,CACJ,KAAK,CAAC,UAAU,CAAC,YAAY,CAAC,SAAS,EAAE,YAAY,EAAE,OAAO,CAC5D,UAAU,CAAC,YAAY,CAAC,IAAI,EAC5B,WAAW,CAAC,IAAI,CACjB,CAAC,EACF,MAAM,CAAC,IAAI,CAAC,+BAA+B,CAAC,CAAC,CAC9C;CACF,CAAA"}
@@ -0,0 +1,5 @@
1
+ import type { PaymentService } from './types.js';
2
+ import type { Config, Context } from './utils/types.js';
3
+ export declare const makePaymentService: (alias?: string) => PaymentService;
4
+ export declare const appendPaymentService: <C extends Config, T extends Context<C>>(context: T, alias?: string) => T;
5
+ //# sourceMappingURL=service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../src/service.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAgB,cAAc,EAAE,MAAM,YAAY,CAAA;AAC9D,OAAO,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,kBAAkB,CAAA;AAWvD,eAAO,MAAM,kBAAkB,WAAW,MAAM,KAAmB,cA2ElE,CAAA;AAED,eAAO,MAAM,oBAAoB,GAAI,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,OAAO,CAAC,CAAC,CAAC,WAChE,CAAC,UAAS,MAAM,KACxB,CAAuD,CAAA"}
@@ -0,0 +1,71 @@
1
+ import { createService, assertContext } from '@owlmeans/context';
2
+ import { DEFAULT_ALIAS, PaymentEntityType } from './consts.js';
3
+ import { PLAN_RECORD_TYPE, PRODUCT_RECORD_PREFIX } from './consts.js';
4
+ import { PaymentIdentificationError, UnknownProduct } from './errors.js';
5
+ import { fromConfigRecord } from '@owlmeans/config';
6
+ import { l10nToId } from './helper.js';
7
+ import { DEFAULT_LNG } from '@owlmeans/i18n';
8
+ import { EnvelopeKind, makeEnvelopeModel } from '@owlmeans/basic-envelope';
9
+ export const makePaymentService = (alias = DEFAULT_ALIAS) => {
10
+ const service = createService(alias, {
11
+ product: async (sku) => {
12
+ const context = assertContext(service.ctx);
13
+ const configRes = context.getConfigResource();
14
+ const result = fromConfigRecord(await configRes.get(`${PRODUCT_RECORD_PREFIX}:${sku}`));
15
+ if (result == null) {
16
+ throw new UnknownProduct(sku);
17
+ }
18
+ return result;
19
+ },
20
+ plans: async (productSku, duration) => {
21
+ const context = assertContext(service.ctx);
22
+ const configRes = context.getConfigResource();
23
+ const result = await configRes.list({
24
+ productSku, duration, recordType: PLAN_RECORD_TYPE
25
+ });
26
+ return result.items.map(item => fromConfigRecord(item));
27
+ },
28
+ localize: async (lng, entity) => {
29
+ const context = assertContext(service.ctx);
30
+ const configRes = context.getConfigResource();
31
+ const idsToCheck = [];
32
+ if ("productSku" in entity) {
33
+ idsToCheck.push(l10nToId({ lng, type: PaymentEntityType.Plan, sku: entity.sku }, true));
34
+ idsToCheck.push(l10nToId({ lng: DEFAULT_LNG, type: PaymentEntityType.Plan, sku: entity.sku }, true));
35
+ idsToCheck.push(l10nToId({ lng, type: PaymentEntityType.Product, sku: entity.productSku }, true));
36
+ idsToCheck.push(l10nToId({ lng: DEFAULT_LNG, type: PaymentEntityType.Product, sku: entity.productSku }, true));
37
+ }
38
+ else if ("sku" in entity) {
39
+ idsToCheck.push(l10nToId({ lng, type: PaymentEntityType.Product, sku: entity.sku }, true));
40
+ idsToCheck.push(l10nToId({ lng: DEFAULT_LNG, type: PaymentEntityType.Product, sku: entity.sku }, true));
41
+ }
42
+ else {
43
+ idsToCheck.push(l10nToId({ lng, type: PaymentEntityType.CapabilitySet, sku: entity.scope }, true));
44
+ idsToCheck.push(l10nToId({ lng: DEFAULT_LNG, type: PaymentEntityType.CapabilitySet, sku: entity.scope }, true));
45
+ }
46
+ for (let id of idsToCheck) {
47
+ const l10n = await configRes.load(id);
48
+ if (l10n != null) {
49
+ return fromConfigRecord(l10n);
50
+ }
51
+ }
52
+ return null;
53
+ },
54
+ shallowAuthentication: async (token) => {
55
+ if (token == null) {
56
+ throw new PaymentIdentificationError('token');
57
+ }
58
+ const envelope = makeEnvelopeModel(token, EnvelopeKind.Token);
59
+ const auth = envelope.message();
60
+ if (auth.profileId == null) {
61
+ throw new PaymentIdentificationError('profileId');
62
+ }
63
+ return auth.profileId;
64
+ }
65
+ }, service => async () => {
66
+ service.initialized = true;
67
+ });
68
+ return service;
69
+ };
70
+ export const appendPaymentService = (context, alias = DEFAULT_ALIAS) => context.registerService(makePaymentService(alias));
71
+ //# sourceMappingURL=service.js.map