@deenruv/payments-plugin 1.0.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 (102) hide show
  1. package/LICENSE +23 -0
  2. package/README.md +157 -0
  3. package/package/braintree/braintree-common.d.ts +11 -0
  4. package/package/braintree/braintree-common.js +79 -0
  5. package/package/braintree/braintree-common.js.map +1 -0
  6. package/package/braintree/braintree.handler.d.ts +28 -0
  7. package/package/braintree/braintree.handler.js +147 -0
  8. package/package/braintree/braintree.handler.js.map +1 -0
  9. package/package/braintree/braintree.plugin.d.ts +238 -0
  10. package/package/braintree/braintree.plugin.js +294 -0
  11. package/package/braintree/braintree.plugin.js.map +1 -0
  12. package/package/braintree/braintree.resolver.d.ts +14 -0
  13. package/package/braintree/braintree.resolver.js +109 -0
  14. package/package/braintree/braintree.resolver.js.map +1 -0
  15. package/package/braintree/constants.d.ts +2 -0
  16. package/package/braintree/constants.js +6 -0
  17. package/package/braintree/constants.js.map +1 -0
  18. package/package/braintree/index.d.ts +5 -0
  19. package/package/braintree/index.js +22 -0
  20. package/package/braintree/index.js.map +1 -0
  21. package/package/braintree/types.d.ts +94 -0
  22. package/package/braintree/types.js +4 -0
  23. package/package/braintree/types.js.map +1 -0
  24. package/package/index.d.ts +4 -0
  25. package/package/index.js +8 -0
  26. package/package/index.js.map +1 -0
  27. package/package/mollie/api-extensions.d.ts +2 -0
  28. package/package/mollie/api-extensions.js +88 -0
  29. package/package/mollie/api-extensions.js.map +1 -0
  30. package/package/mollie/constants.d.ts +2 -0
  31. package/package/mollie/constants.js +6 -0
  32. package/package/mollie/constants.js.map +1 -0
  33. package/package/mollie/custom-fields.d.ts +7 -0
  34. package/package/mollie/custom-fields.js +12 -0
  35. package/package/mollie/custom-fields.js.map +1 -0
  36. package/package/mollie/extended-mollie-client.d.ts +51 -0
  37. package/package/mollie/extended-mollie-client.js +39 -0
  38. package/package/mollie/extended-mollie-client.js.map +1 -0
  39. package/package/mollie/graphql/generated-shop-types.d.ts +3212 -0
  40. package/package/mollie/graphql/generated-shop-types.js +977 -0
  41. package/package/mollie/graphql/generated-shop-types.js.map +1 -0
  42. package/package/mollie/index.d.ts +3 -0
  43. package/package/mollie/index.js +23 -0
  44. package/package/mollie/index.js.map +1 -0
  45. package/package/mollie/mollie.common-resolver.d.ts +9 -0
  46. package/package/mollie/mollie.common-resolver.js +55 -0
  47. package/package/mollie/mollie.common-resolver.js.map +1 -0
  48. package/package/mollie/mollie.controller.d.ts +10 -0
  49. package/package/mollie/mollie.controller.js +71 -0
  50. package/package/mollie/mollie.controller.js.map +1 -0
  51. package/package/mollie/mollie.handler.d.ts +36 -0
  52. package/package/mollie/mollie.handler.js +141 -0
  53. package/package/mollie/mollie.handler.js.map +1 -0
  54. package/package/mollie/mollie.helpers.d.ts +33 -0
  55. package/package/mollie/mollie.helpers.js +147 -0
  56. package/package/mollie/mollie.helpers.js.map +1 -0
  57. package/package/mollie/mollie.plugin.d.ts +176 -0
  58. package/package/mollie/mollie.plugin.js +167 -0
  59. package/package/mollie/mollie.plugin.js.map +1 -0
  60. package/package/mollie/mollie.service.d.ts +64 -0
  61. package/package/mollie/mollie.service.js +438 -0
  62. package/package/mollie/mollie.service.js.map +1 -0
  63. package/package/mollie/mollie.shop-resolver.d.ts +8 -0
  64. package/package/mollie/mollie.shop-resolver.js +40 -0
  65. package/package/mollie/mollie.shop-resolver.js.map +1 -0
  66. package/package/stripe/constants.d.ts +2 -0
  67. package/package/stripe/constants.js +6 -0
  68. package/package/stripe/constants.js.map +1 -0
  69. package/package/stripe/index.d.ts +1 -0
  70. package/package/stripe/index.js +6 -0
  71. package/package/stripe/index.js.map +1 -0
  72. package/package/stripe/metadata-sanitize.d.ts +13 -0
  73. package/package/stripe/metadata-sanitize.js +33 -0
  74. package/package/stripe/metadata-sanitize.js.map +1 -0
  75. package/package/stripe/raw-body.middleware.d.ts +6 -0
  76. package/package/stripe/raw-body.middleware.js +18 -0
  77. package/package/stripe/raw-body.middleware.js.map +1 -0
  78. package/package/stripe/stripe-client.d.ts +9 -0
  79. package/package/stripe/stripe-client.js +21 -0
  80. package/package/stripe/stripe-client.js.map +1 -0
  81. package/package/stripe/stripe-utils.d.ts +19 -0
  82. package/package/stripe/stripe-utils.js +40 -0
  83. package/package/stripe/stripe-utils.js.map +1 -0
  84. package/package/stripe/stripe.controller.d.ts +15 -0
  85. package/package/stripe/stripe.controller.js +135 -0
  86. package/package/stripe/stripe.controller.js.map +1 -0
  87. package/package/stripe/stripe.handler.d.ts +30 -0
  88. package/package/stripe/stripe.handler.js +103 -0
  89. package/package/stripe/stripe.handler.js.map +1 -0
  90. package/package/stripe/stripe.plugin.d.ts +158 -0
  91. package/package/stripe/stripe.plugin.js +218 -0
  92. package/package/stripe/stripe.plugin.js.map +1 -0
  93. package/package/stripe/stripe.resolver.d.ts +8 -0
  94. package/package/stripe/stripe.resolver.js +48 -0
  95. package/package/stripe/stripe.resolver.js.map +1 -0
  96. package/package/stripe/stripe.service.d.ts +28 -0
  97. package/package/stripe/stripe.service.js +149 -0
  98. package/package/stripe/stripe.service.js.map +1 -0
  99. package/package/stripe/types.d.ts +137 -0
  100. package/package/stripe/types.js +4 -0
  101. package/package/stripe/types.js.map +1 -0
  102. package/package.json +73 -0
@@ -0,0 +1,176 @@
1
+ import type { ListParameters } from "@mollie/api-client/dist/types/src/binders/methods/parameters";
2
+ import { Injector, Order, RequestContext } from "@deenruv/core";
3
+ export type AdditionalEnabledPaymentMethodsParams = Partial<Omit<ListParameters, "resource">>;
4
+ /**
5
+ * @description
6
+ * Configuration options for the Mollie payments plugin.
7
+ *
8
+ * @docsCategory core plugins/PaymentsPlugin
9
+ * @docsPage MolliePlugin
10
+ */
11
+ export interface MolliePluginOptions {
12
+ /**
13
+ * @description
14
+ * The host of your Deenruv server, e.g. `'https://my-deenruv.io'`.
15
+ * This is used by Mollie to send webhook events to the Deenruv server
16
+ */
17
+ deenruvHost: string;
18
+ /**
19
+ * @description
20
+ * Provide additional parameters to the Mollie enabled payment methods API call. By default,
21
+ * the plugin will already pass the `resource` parameter.
22
+ *
23
+ * For example, if you want to provide a `locale` and `billingCountry` for the API call, you can do so like this:
24
+ *
25
+ * **Note:** The `order` argument is possibly `null`, this could happen when you fetch the available payment methods
26
+ * before the order is created.
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { DeenruvConfig } from '\@deenruv/core';
31
+ * import { MolliePlugin, getLocale } from '\@deenruv/payments-plugin/package/mollie';
32
+ *
33
+ * export const config: DeenruvConfig = {
34
+ * // ...
35
+ * plugins: [
36
+ * MolliePlugin.init({
37
+ * enabledPaymentMethodsParams: (injector, ctx, order) => {
38
+ * const locale = order?.billingAddress?.countryCode
39
+ * ? getLocale(order.billingAddress.countryCode, ctx.languageCode)
40
+ * : undefined;
41
+ *
42
+ * return {
43
+ * locale,
44
+ * billingCountry: order?.billingAddress?.countryCode,
45
+ * },
46
+ * }
47
+ * }),
48
+ * ],
49
+ * };
50
+ * ```
51
+ *
52
+ * @since 2.2.0
53
+ */
54
+ enabledPaymentMethodsParams?: (injector: Injector, ctx: RequestContext, order: Order | null) => AdditionalEnabledPaymentMethodsParams | Promise<AdditionalEnabledPaymentMethodsParams>;
55
+ }
56
+ /**
57
+ * @description
58
+ * Plugin to enable payments through the [Mollie platform](https://docs.mollie.com/).
59
+ * This plugin uses the Order API from Mollie, not the Payments API.
60
+ *
61
+ * ## Requirements
62
+ *
63
+ * 1. You will need to create a Mollie account and get your apiKey in the dashboard.
64
+ * 2. Install the Payments plugin and the Mollie client:
65
+ *
66
+ * `yarn add \@deenruv/payments-plugin \@mollie/api-client`
67
+ *
68
+ * or
69
+ *
70
+ * `npm install \@deenruv/payments-plugin \@mollie/api-client`
71
+ *
72
+ * ## Setup
73
+ *
74
+ * 1. Add the plugin to your DeenruvConfig `plugins` array:
75
+ * ```ts
76
+ * import { MolliePlugin } from '\@deenruv/payments-plugin/package/mollie';
77
+ *
78
+ * // ...
79
+ *
80
+ * plugins: [
81
+ * MolliePlugin.init({ deenruvHost: 'https://yourhost.io/' }),
82
+ * ]
83
+ * ```
84
+ * 2. Run a database migration to add the `mollieOrderId` custom field to the order entity.
85
+ * 3. Create a new PaymentMethod in the Admin UI, and select "Mollie payments" as the handler.
86
+ * 4. Set your Mollie apiKey in the `API Key` field.
87
+ * 5. Set the `Fallback redirectUrl` to the url that the customer should be redirected to after completing the payment.
88
+ * You can override this url by passing the `redirectUrl` as an argument to the `createMolliePaymentIntent` mutation.
89
+ *
90
+ * ## Storefront usage
91
+ *
92
+ * In your storefront you add a payment to an order using the `createMolliePaymentIntent` mutation. In this example, our Mollie
93
+ * PaymentMethod was given the code "mollie-payment-method". The `redirectUrl``is the url that is used to redirect the end-user
94
+ * back to your storefront after completing the payment.
95
+ *
96
+ * ```GraphQL
97
+ * mutation CreateMolliePaymentIntent {
98
+ * createMolliePaymentIntent(input: {
99
+ * redirectUrl: "https://storefront/order/1234XYZ"
100
+ * paymentMethodCode: "mollie-payment-method"
101
+ * molliePaymentMethodCode: "ideal"
102
+ * }) {
103
+ * ... on MolliePaymentIntent {
104
+ * url
105
+ * }
106
+ * ... on MolliePaymentIntentError {
107
+ * errorCode
108
+ * message
109
+ * }
110
+ * }
111
+ * }
112
+ * ```
113
+ *
114
+ * The response will contain
115
+ * a redirectUrl, which can be used to redirect your customer to the Mollie
116
+ * platform.
117
+ *
118
+ * 'molliePaymentMethodCode' is an optional parameter that can be passed to skip Mollie's hosted payment method selection screen
119
+ * You can get available Mollie payment methods with the following query:
120
+ *
121
+ * ```GraphQL
122
+ * {
123
+ * molliePaymentMethods(input: { paymentMethodCode: "mollie-payment-method" }) {
124
+ * id
125
+ * code
126
+ * description
127
+ * minimumAmount {
128
+ * value
129
+ * currency
130
+ * }
131
+ * maximumAmount {
132
+ * value
133
+ * currency
134
+ * }
135
+ * image {
136
+ * size1x
137
+ * size2x
138
+ * svg
139
+ * }
140
+ * }
141
+ * }
142
+ * ```
143
+ * You can pass `creditcard` for example, to the `createMolliePaymentIntent` mutation to skip the method selection.
144
+ *
145
+ * After completing payment on the Mollie platform,
146
+ * the user is redirected to the given redirect url, e.g. `https://storefront/order/CH234X5`
147
+ *
148
+ * ## Pay later methods
149
+ * Mollie supports pay-later methods like 'Klarna Pay Later'. For pay-later methods, the status of an order is
150
+ * 'PaymentAuthorized' after the Mollie hosted checkout. You need to manually settle the payment via the admin ui to capture the payment!
151
+ * Make sure you capture a payment within 28 days, because this is the Klarna expiry time
152
+ *
153
+ * If you don't want this behaviour (Authorized first), you can set 'autoCapture=true' on the payment method. This option will immediately
154
+ * capture the payment after a customer authorizes the payment.
155
+ *
156
+ * ## ArrangingAdditionalPayment state
157
+ *
158
+ * In some rare cases, a customer can add items to the active order, while a Mollie payment is still open,
159
+ * for example by opening your storefront in another browser tab.
160
+ * This could result in an order being in `ArrangingAdditionalPayment` status after the customer finished payment.
161
+ * You should check if there is still an active order with status `ArrangingAdditionalPayment` on your order confirmation page,
162
+ * and if so, allow your customer to pay for the additional items by creating another Mollie payment.
163
+ *
164
+ * @docsCategory core plugins/PaymentsPlugin
165
+ * @docsPage MolliePlugin
166
+ * @docsWeight 0
167
+ */
168
+ export declare class MolliePlugin {
169
+ static options: MolliePluginOptions;
170
+ /**
171
+ * @description
172
+ * Initialize the mollie payment plugin
173
+ * @param deenruvHost is needed to pass to mollie for callback
174
+ */
175
+ static init(options: MolliePluginOptions): typeof MolliePlugin;
176
+ }
@@ -0,0 +1,167 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var MolliePlugin_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MolliePlugin = void 0;
11
+ const core_1 = require("@deenruv/core");
12
+ const api_extensions_1 = require("./api-extensions");
13
+ const constants_1 = require("./constants");
14
+ const custom_fields_1 = require("./custom-fields");
15
+ const mollie_common_resolver_1 = require("./mollie.common-resolver");
16
+ const mollie_controller_1 = require("./mollie.controller");
17
+ const mollie_handler_1 = require("./mollie.handler");
18
+ const mollie_service_1 = require("./mollie.service");
19
+ const mollie_shop_resolver_1 = require("./mollie.shop-resolver");
20
+ /**
21
+ * @description
22
+ * Plugin to enable payments through the [Mollie platform](https://docs.mollie.com/).
23
+ * This plugin uses the Order API from Mollie, not the Payments API.
24
+ *
25
+ * ## Requirements
26
+ *
27
+ * 1. You will need to create a Mollie account and get your apiKey in the dashboard.
28
+ * 2. Install the Payments plugin and the Mollie client:
29
+ *
30
+ * `yarn add \@deenruv/payments-plugin \@mollie/api-client`
31
+ *
32
+ * or
33
+ *
34
+ * `npm install \@deenruv/payments-plugin \@mollie/api-client`
35
+ *
36
+ * ## Setup
37
+ *
38
+ * 1. Add the plugin to your DeenruvConfig `plugins` array:
39
+ * ```ts
40
+ * import { MolliePlugin } from '\@deenruv/payments-plugin/package/mollie';
41
+ *
42
+ * // ...
43
+ *
44
+ * plugins: [
45
+ * MolliePlugin.init({ deenruvHost: 'https://yourhost.io/' }),
46
+ * ]
47
+ * ```
48
+ * 2. Run a database migration to add the `mollieOrderId` custom field to the order entity.
49
+ * 3. Create a new PaymentMethod in the Admin UI, and select "Mollie payments" as the handler.
50
+ * 4. Set your Mollie apiKey in the `API Key` field.
51
+ * 5. Set the `Fallback redirectUrl` to the url that the customer should be redirected to after completing the payment.
52
+ * You can override this url by passing the `redirectUrl` as an argument to the `createMolliePaymentIntent` mutation.
53
+ *
54
+ * ## Storefront usage
55
+ *
56
+ * In your storefront you add a payment to an order using the `createMolliePaymentIntent` mutation. In this example, our Mollie
57
+ * PaymentMethod was given the code "mollie-payment-method". The `redirectUrl``is the url that is used to redirect the end-user
58
+ * back to your storefront after completing the payment.
59
+ *
60
+ * ```GraphQL
61
+ * mutation CreateMolliePaymentIntent {
62
+ * createMolliePaymentIntent(input: {
63
+ * redirectUrl: "https://storefront/order/1234XYZ"
64
+ * paymentMethodCode: "mollie-payment-method"
65
+ * molliePaymentMethodCode: "ideal"
66
+ * }) {
67
+ * ... on MolliePaymentIntent {
68
+ * url
69
+ * }
70
+ * ... on MolliePaymentIntentError {
71
+ * errorCode
72
+ * message
73
+ * }
74
+ * }
75
+ * }
76
+ * ```
77
+ *
78
+ * The response will contain
79
+ * a redirectUrl, which can be used to redirect your customer to the Mollie
80
+ * platform.
81
+ *
82
+ * 'molliePaymentMethodCode' is an optional parameter that can be passed to skip Mollie's hosted payment method selection screen
83
+ * You can get available Mollie payment methods with the following query:
84
+ *
85
+ * ```GraphQL
86
+ * {
87
+ * molliePaymentMethods(input: { paymentMethodCode: "mollie-payment-method" }) {
88
+ * id
89
+ * code
90
+ * description
91
+ * minimumAmount {
92
+ * value
93
+ * currency
94
+ * }
95
+ * maximumAmount {
96
+ * value
97
+ * currency
98
+ * }
99
+ * image {
100
+ * size1x
101
+ * size2x
102
+ * svg
103
+ * }
104
+ * }
105
+ * }
106
+ * ```
107
+ * You can pass `creditcard` for example, to the `createMolliePaymentIntent` mutation to skip the method selection.
108
+ *
109
+ * After completing payment on the Mollie platform,
110
+ * the user is redirected to the given redirect url, e.g. `https://storefront/order/CH234X5`
111
+ *
112
+ * ## Pay later methods
113
+ * Mollie supports pay-later methods like 'Klarna Pay Later'. For pay-later methods, the status of an order is
114
+ * 'PaymentAuthorized' after the Mollie hosted checkout. You need to manually settle the payment via the admin ui to capture the payment!
115
+ * Make sure you capture a payment within 28 days, because this is the Klarna expiry time
116
+ *
117
+ * If you don't want this behaviour (Authorized first), you can set 'autoCapture=true' on the payment method. This option will immediately
118
+ * capture the payment after a customer authorizes the payment.
119
+ *
120
+ * ## ArrangingAdditionalPayment state
121
+ *
122
+ * In some rare cases, a customer can add items to the active order, while a Mollie payment is still open,
123
+ * for example by opening your storefront in another browser tab.
124
+ * This could result in an order being in `ArrangingAdditionalPayment` status after the customer finished payment.
125
+ * You should check if there is still an active order with status `ArrangingAdditionalPayment` on your order confirmation page,
126
+ * and if so, allow your customer to pay for the additional items by creating another Mollie payment.
127
+ *
128
+ * @docsCategory core plugins/PaymentsPlugin
129
+ * @docsPage MolliePlugin
130
+ * @docsWeight 0
131
+ */
132
+ let MolliePlugin = exports.MolliePlugin = MolliePlugin_1 = class MolliePlugin {
133
+ /**
134
+ * @description
135
+ * Initialize the mollie payment plugin
136
+ * @param deenruvHost is needed to pass to mollie for callback
137
+ */
138
+ static init(options) {
139
+ this.options = options;
140
+ return MolliePlugin_1;
141
+ }
142
+ };
143
+ exports.MolliePlugin = MolliePlugin = MolliePlugin_1 = __decorate([
144
+ (0, core_1.DeenruvPlugin)({
145
+ imports: [core_1.PluginCommonModule],
146
+ controllers: [mollie_controller_1.MollieController],
147
+ providers: [
148
+ mollie_service_1.MollieService,
149
+ { provide: constants_1.PLUGIN_INIT_OPTIONS, useFactory: () => MolliePlugin_1.options },
150
+ ],
151
+ configuration: (config) => {
152
+ config.paymentOptions.paymentMethodHandlers.push(mollie_handler_1.molliePaymentHandler);
153
+ config.customFields.Order.push(...custom_fields_1.orderCustomFields);
154
+ return config;
155
+ },
156
+ shopApiExtensions: {
157
+ schema: api_extensions_1.shopApiExtensions,
158
+ resolvers: [mollie_common_resolver_1.MollieCommonResolver, mollie_shop_resolver_1.MollieShopResolver],
159
+ },
160
+ adminApiExtensions: {
161
+ schema: api_extensions_1.adminApiExtensions,
162
+ resolvers: [mollie_common_resolver_1.MollieCommonResolver],
163
+ },
164
+ compatibility: "^0.0.1",
165
+ })
166
+ ], MolliePlugin);
167
+ //# sourceMappingURL=mollie.plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"mollie.plugin.js","sourceRoot":"","sources":["../../src/mollie/mollie.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AACA,wCAOuB;AAEvB,qDAAyE;AACzE,2CAAkD;AAClD,mDAAoD;AACpD,qEAAgE;AAChE,2DAAuD;AACvD,qDAAwD;AACxD,qDAAiD;AACjD,iEAA4D;AAkE5D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+GG;AAuBI,IAAM,YAAY,2CAAlB,MAAM,YAAY;IAGvB;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,OAA4B;QACtC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACtB,CAAC;CACF,CAAA;uBAZY,YAAY;IAtBxB,IAAA,oBAAa,EAAC;QACb,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE;YACT,8BAAa;YACb,EAAE,OAAO,EAAE,+BAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,cAAY,CAAC,OAAO,EAAE;SACzE;QACD,aAAa,EAAE,CAAC,MAA4B,EAAE,EAAE;YAC9C,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,qCAAoB,CAAC,CAAC;YACvE,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,iCAAiB,CAAC,CAAC;YACrD,OAAO,MAAM,CAAC;QAChB,CAAC;QACD,iBAAiB,EAAE;YACjB,MAAM,EAAE,kCAAiB;YACzB,SAAS,EAAE,CAAC,6CAAoB,EAAE,yCAAkB,CAAC;SACtD;QACD,kBAAkB,EAAE;YAClB,MAAM,EAAE,mCAAkB;YAC1B,SAAS,EAAE,CAAC,6CAAoB,CAAC;SAClC;QACD,aAAa,EAAE,QAAQ;KACxB,CAAC;GACW,YAAY,CAYxB"}
@@ -0,0 +1,64 @@
1
+ import { Order as MollieOrder } from "@mollie/api-client";
2
+ import { CreateParameters } from "@mollie/api-client/dist/types/src/binders/orders/parameters";
3
+ import { ModuleRef } from "@nestjs/core";
4
+ import { ActiveOrderService, EntityHydrator, Order, OrderService, PaymentMethodService, ProductVariant, ProductVariantService, RequestContext } from "@deenruv/core";
5
+ import { ExtendedMollieClient } from "./extended-mollie-client";
6
+ import { MolliePaymentIntentInput, MolliePaymentIntentResult, MolliePaymentMethod } from "./graphql/generated-shop-types";
7
+ import { MolliePluginOptions } from "./mollie.plugin";
8
+ interface OrderStatusInput {
9
+ paymentMethodId: string;
10
+ orderId: string;
11
+ }
12
+ export declare class MollieService {
13
+ private paymentMethodService;
14
+ private options;
15
+ private activeOrderService;
16
+ private orderService;
17
+ private entityHydrator;
18
+ private variantService;
19
+ private moduleRef;
20
+ private readonly injector;
21
+ constructor(paymentMethodService: PaymentMethodService, options: MolliePluginOptions, activeOrderService: ActiveOrderService, orderService: OrderService, entityHydrator: EntityHydrator, variantService: ProductVariantService, moduleRef: ModuleRef);
22
+ /**
23
+ * Creates a redirectUrl to Mollie for the given paymentMethod and current activeOrder
24
+ */
25
+ createPaymentIntent(ctx: RequestContext, input: MolliePaymentIntentInput): Promise<MolliePaymentIntentResult>;
26
+ /**
27
+ * Update Deenruv payments and order status based on the incoming Mollie order
28
+ */
29
+ handleMollieStatusUpdate(ctx: RequestContext, { paymentMethodId, orderId }: OrderStatusInput): Promise<void>;
30
+ /**
31
+ * Add payment to order. Can be settled or authorized depending on the payment method.
32
+ */
33
+ addPayment(ctx: RequestContext, order: Order, amount: number, mollieMetadata: Partial<MollieOrder>, paymentMethodCode: string, status: "Authorized" | "Settled"): Promise<Order>;
34
+ /**
35
+ * Settle an existing payment based on the given mollieOrder
36
+ */
37
+ settleExistingPayment(ctx: RequestContext, order: Order, mollieOrderId: string): Promise<void>;
38
+ getEnabledPaymentMethods(ctx: RequestContext, paymentMethodCode: string): Promise<MolliePaymentMethod[]>;
39
+ getVariantsWithInsufficientStock(ctx: RequestContext, order: Order): Promise<ProductVariant[]>;
40
+ /**
41
+ * Update an existing Mollie order based on the given Deenruv order.
42
+ */
43
+ updateMollieOrder(mollieClient: ExtendedMollieClient, newMollieOrderInput: CreateParameters, mollieOrderId: string): Promise<MollieOrder>;
44
+ /**
45
+ * Update the Mollie Order data itself, excluding the order lines.
46
+ * So, addresses, redirect url etc
47
+ */
48
+ private updateMollieOrderData;
49
+ /**
50
+ * Delete all order lines of current Mollie order, and create new ones based on the new Deenruv order lines
51
+ */
52
+ private updateMollieOrderLines;
53
+ /**
54
+ * Dry run a transition to a given state.
55
+ * As long as we don't call 'finalize', the transition never completes.
56
+ */
57
+ private canTransitionTo;
58
+ private getPaymentMethod;
59
+ /**
60
+ * Get order by id, or active order if no orderId is given
61
+ */
62
+ private getOrder;
63
+ }
64
+ export {};