@vendure/payments-plugin 2.0.0-next.8 → 2.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 (71) hide show
  1. package/README.md +36 -0
  2. package/package/braintree/braintree-common.d.ts +4 -2
  3. package/package/braintree/braintree-common.js +11 -5
  4. package/package/braintree/braintree-common.js.map +1 -1
  5. package/package/braintree/braintree.handler.js +14 -7
  6. package/package/braintree/braintree.handler.js.map +1 -1
  7. package/package/braintree/braintree.plugin.d.ts +52 -4
  8. package/package/braintree/braintree.plugin.js +53 -5
  9. package/package/braintree/braintree.plugin.js.map +1 -1
  10. package/package/braintree/braintree.resolver.d.ts +2 -1
  11. package/package/braintree/braintree.resolver.js +27 -6
  12. package/package/braintree/braintree.resolver.js.map +1 -1
  13. package/package/braintree/index.js +5 -1
  14. package/package/braintree/index.js.map +1 -1
  15. package/package/braintree/types.d.ts +62 -4
  16. package/package/braintree/types.js.map +1 -1
  17. package/package/mollie/graphql/generated-shop-types.d.ts +489 -338
  18. package/package/mollie/graphql/generated-shop-types.js +25 -2
  19. package/package/mollie/graphql/generated-shop-types.js.map +1 -1
  20. package/package/mollie/index.js +5 -1
  21. package/package/mollie/index.js.map +1 -1
  22. package/package/mollie/mollie-shop-schema.js +25 -0
  23. package/package/mollie/mollie-shop-schema.js.map +1 -1
  24. package/package/mollie/mollie.controller.d.ts +2 -1
  25. package/package/mollie/mollie.controller.js +14 -8
  26. package/package/mollie/mollie.controller.js.map +1 -1
  27. package/package/mollie/mollie.handler.d.ts +14 -0
  28. package/package/mollie/mollie.handler.js +53 -15
  29. package/package/mollie/mollie.handler.js.map +1 -1
  30. package/package/mollie/mollie.helpers.d.ts +33 -0
  31. package/package/mollie/mollie.helpers.js +142 -0
  32. package/package/mollie/mollie.helpers.js.map +1 -0
  33. package/package/mollie/mollie.plugin.d.ts +75 -21
  34. package/package/mollie/mollie.plugin.js +61 -19
  35. package/package/mollie/mollie.plugin.js.map +1 -1
  36. package/package/mollie/mollie.resolver.d.ts +3 -4
  37. package/package/mollie/mollie.resolver.js +13 -1
  38. package/package/mollie/mollie.resolver.js.map +1 -1
  39. package/package/mollie/mollie.service.d.ts +21 -10
  40. package/package/mollie/mollie.service.js +188 -71
  41. package/package/mollie/mollie.service.js.map +1 -1
  42. package/package/stripe/index.js +5 -1
  43. package/package/stripe/index.js.map +1 -1
  44. package/package/stripe/metadata-sanitize.d.ts +13 -0
  45. package/package/stripe/metadata-sanitize.js +33 -0
  46. package/package/stripe/metadata-sanitize.js.map +1 -0
  47. package/package/stripe/raw-body.middleware.js.map +1 -1
  48. package/package/stripe/stripe-client.d.ts +9 -0
  49. package/package/stripe/stripe-client.js +21 -0
  50. package/package/stripe/stripe-client.js.map +1 -0
  51. package/package/stripe/stripe-utils.d.ts +19 -0
  52. package/package/stripe/stripe-utils.js +43 -0
  53. package/package/stripe/stripe-utils.js.map +1 -0
  54. package/package/stripe/stripe.controller.d.ts +5 -5
  55. package/package/stripe/stripe.controller.js +27 -26
  56. package/package/stripe/stripe.controller.js.map +1 -1
  57. package/package/stripe/stripe.handler.d.ts +27 -2
  58. package/package/stripe/stripe.handler.js +56 -25
  59. package/package/stripe/stripe.handler.js.map +1 -1
  60. package/package/stripe/stripe.plugin.d.ts +91 -14
  61. package/package/stripe/stripe.plugin.js +92 -15
  62. package/package/stripe/stripe.plugin.js.map +1 -1
  63. package/package/stripe/stripe.resolver.d.ts +1 -1
  64. package/package/stripe/stripe.resolver.js +7 -5
  65. package/package/stripe/stripe.resolver.js.map +1 -1
  66. package/package/stripe/stripe.service.d.ts +14 -6
  67. package/package/stripe/stripe.service.js +74 -41
  68. package/package/stripe/stripe.service.js.map +1 -1
  69. package/package/stripe/types.d.ts +12 -13
  70. package/package/stripe/types.js.map +1 -1
  71. package/package.json +28 -9
@@ -2,20 +2,32 @@
2
2
  * @description
3
3
  * Configuration options for the Mollie payments plugin.
4
4
  *
5
- * @docsCategory payments-plugin
5
+ * @docsCategory core plugins/PaymentsPlugin
6
6
  * @docsPage MolliePlugin
7
7
  */
8
8
  export interface MolliePluginOptions {
9
9
  /**
10
10
  * @description
11
- * The host of your storefront application, e.g. `'https://my-shop.com'`
11
+ * The host of your Vendure server, e.g. `'https://my-vendure.io'`.
12
+ * This is used by Mollie to send webhook events to the Vendure server
12
13
  */
13
14
  vendureHost: string;
15
+ /**
16
+ * @description
17
+ * For backwards compatibility, by default set to false.
18
+ * This option will be deprecated in a future version.
19
+ * When enabled, the `redirectUrl` can be passed via the `createPaymentIntent` mutation
20
+ * instead of being configured in the Payment Method.
21
+ *
22
+ * @default false
23
+ * @since 2.0.0
24
+ */
25
+ useDynamicRedirectUrl?: boolean;
14
26
  }
15
27
  /**
16
28
  * @description
17
29
  * Plugin to enable payments through the [Mollie platform](https://docs.mollie.com/).
18
- * This plugin uses the Payments API from Mollie, not the Orders API.
30
+ * This plugin uses the Order API from Mollie, not the Payments API.
19
31
  *
20
32
  * ## Requirements
21
33
  *
@@ -37,50 +49,91 @@ export interface MolliePluginOptions {
37
49
  * // ...
38
50
  *
39
51
  * plugins: [
40
- * MolliePlugin.init({ vendureHost: 'https://yourhost.io/' }),
52
+ * MolliePlugin.init({ vendureHost: 'https://yourhost.io/', useDynamicRedirectUrl: true }),
41
53
  * ]
42
54
  * ```
43
55
  * 2. Create a new PaymentMethod in the Admin UI, and select "Mollie payments" as the handler.
44
- * 3. Set the Redirect URL. This is the url that is used to redirect the end-user, e.g. `https://storefront/order`
45
- * 4. Set your Mollie apiKey in the `API Key` field.
56
+ * 3. Set your Mollie apiKey in the `API Key` field.
57
+ *
58
+ * ## Specifying the redirectUrl
46
59
  *
60
+ * Currently, there are two ways to specify the `redirectUrl` to which the customer is redirected after completing the payment:
61
+ * 1. Configure the `redirectUrl` in the PaymentMethod.
62
+ * 2. Pass the `redirectUrl` as an argument to the `createPaymentIntent` mutation.
63
+ *
64
+ * Which method is used depends on the value of the `useDynamicRedirectUrl` option while initializing the plugin.
65
+ * By default, this option is set to `false` for backwards compatibility. In a future version, this option will be deprecated.
66
+ * Upon deprecation, the `redirectUrl` will always be passed as an argument to the `createPaymentIntent` mutation.
67
+ *
68
+ * TODO toevoegen van /code weggehaald..!
47
69
  * ## Storefront usage
48
70
  *
49
71
  * In your storefront you add a payment to an order using the `createMolliePaymentIntent` mutation. In this example, our Mollie
50
- * PaymentMethod was given the code "mollie-payment-method".
72
+ * PaymentMethod was given the code "mollie-payment-method". The `redirectUrl``is the url that is used to redirect the end-user
73
+ * back to your storefront after completing the payment. When using the first method specified in `Specifying the redirectUrl`,
74
+ * the order code is appened to the `redirectUrl`. For the second method, the order code is not appended to the specified `redirectUrl`.
51
75
  *
52
76
  * ```GraphQL
53
77
  * mutation CreateMolliePaymentIntent {
54
78
  * createMolliePaymentIntent(input: {
79
+ * redirectUrl: "https://storefront/order"
55
80
  * paymentMethodCode: "mollie-payment-method"
81
+ * molliePaymentMethodCode: "ideal"
56
82
  * }) {
57
83
  * ... on MolliePaymentIntent {
58
- url
59
- }
60
- ... on MolliePaymentIntentError {
61
- errorCode
62
- message
63
- }
84
+ * url
85
+ * }
86
+ * ... on MolliePaymentIntentError {
87
+ * errorCode
88
+ * message
89
+ * }
64
90
  * }
65
91
  * }
66
92
  * ```
93
+ *
67
94
  * The response will contain
68
95
  * a redirectUrl, which can be used to redirect your customer to the Mollie
69
96
  * platform.
70
97
  *
98
+ * 'molliePaymentMethodCode' is an optional parameter that can be passed to skip Mollie's hosted payment method selection screen
99
+ * You can get available Mollie payment methods with the following query:
100
+ *
101
+ * ```GraphQL
102
+ * {
103
+ * molliePaymentMethods(input: { paymentMethodCode: "mollie-payment-method" }) {
104
+ * id
105
+ * code
106
+ * description
107
+ * minimumAmount {
108
+ * value
109
+ * currency
110
+ * }
111
+ * maximumAmount {
112
+ * value
113
+ * currency
114
+ * }
115
+ * image {
116
+ * size1x
117
+ * size2x
118
+ * svg
119
+ * }
120
+ * }
121
+ * }
122
+ * ```
123
+ * You can pass `MolliePaymentMethod.code` to the `createMolliePaymentIntent` mutation to skip the method selection.
124
+ *
71
125
  * After completing payment on the Mollie platform,
72
126
  * the user is redirected to the configured redirect url + orderCode: `https://storefront/order/CH234X5`
73
127
  *
74
- * ## Local development
75
- *
76
- * Use something like [localtunnel](https://github.com/localtunnel/localtunnel) to test on localhost.
128
+ * ## Pay later methods
129
+ * Mollie supports pay-later methods like 'Klarna Pay Later'. For pay-later methods, the status of an order is
130
+ * 'PaymentAuthorized' after the Mollie hosted checkout. You need to manually settle the payment via the admin ui to capture the payment!
131
+ * Make sure you capture a payment within 28 days, because this is the Klarna expiry time
77
132
  *
78
- * ```bash
79
- * npx localtunnel --port 3000 --subdomain my-shop-local-dev
80
- * > your url is: https://my-shop-local-dev.loca.lt <- use this as the vendureHost for local dev.
81
- * ```
133
+ * If you don't want this behaviour (Authorized first), you can set 'autoCapture=true' on the payment method. This option will immediately
134
+ * capture the payment after a customer authorizes the payment.
82
135
  *
83
- * @docsCategory payments-plugin
136
+ * @docsCategory core plugins/PaymentsPlugin
84
137
  * @docsPage MolliePlugin
85
138
  * @docsWeight 0
86
139
  */
@@ -90,6 +143,7 @@ export declare class MolliePlugin {
90
143
  * @description
91
144
  * Initialize the mollie payment plugin
92
145
  * @param vendureHost is needed to pass to mollie for callback
146
+ * @param useDynamicRedirectUrl to indicate if the redirectUrl can be passed via the `createPaymentIntent` mutation, versus being configured in the Payment Method.
93
147
  */
94
148
  static init(options: MolliePluginOptions): typeof MolliePlugin;
95
149
  }
@@ -18,7 +18,7 @@ const mollie_service_1 = require("./mollie.service");
18
18
  /**
19
19
  * @description
20
20
  * Plugin to enable payments through the [Mollie platform](https://docs.mollie.com/).
21
- * This plugin uses the Payments API from Mollie, not the Orders API.
21
+ * This plugin uses the Order API from Mollie, not the Payments API.
22
22
  *
23
23
  * ## Requirements
24
24
  *
@@ -40,50 +40,91 @@ const mollie_service_1 = require("./mollie.service");
40
40
  * // ...
41
41
  *
42
42
  * plugins: [
43
- * MolliePlugin.init({ vendureHost: 'https://yourhost.io/' }),
43
+ * MolliePlugin.init({ vendureHost: 'https://yourhost.io/', useDynamicRedirectUrl: true }),
44
44
  * ]
45
45
  * ```
46
46
  * 2. Create a new PaymentMethod in the Admin UI, and select "Mollie payments" as the handler.
47
- * 3. Set the Redirect URL. This is the url that is used to redirect the end-user, e.g. `https://storefront/order`
48
- * 4. Set your Mollie apiKey in the `API Key` field.
47
+ * 3. Set your Mollie apiKey in the `API Key` field.
49
48
  *
49
+ * ## Specifying the redirectUrl
50
+ *
51
+ * Currently, there are two ways to specify the `redirectUrl` to which the customer is redirected after completing the payment:
52
+ * 1. Configure the `redirectUrl` in the PaymentMethod.
53
+ * 2. Pass the `redirectUrl` as an argument to the `createPaymentIntent` mutation.
54
+ *
55
+ * Which method is used depends on the value of the `useDynamicRedirectUrl` option while initializing the plugin.
56
+ * By default, this option is set to `false` for backwards compatibility. In a future version, this option will be deprecated.
57
+ * Upon deprecation, the `redirectUrl` will always be passed as an argument to the `createPaymentIntent` mutation.
58
+ *
59
+ * TODO toevoegen van /code weggehaald..!
50
60
  * ## Storefront usage
51
61
  *
52
62
  * In your storefront you add a payment to an order using the `createMolliePaymentIntent` mutation. In this example, our Mollie
53
- * PaymentMethod was given the code "mollie-payment-method".
63
+ * PaymentMethod was given the code "mollie-payment-method". The `redirectUrl``is the url that is used to redirect the end-user
64
+ * back to your storefront after completing the payment. When using the first method specified in `Specifying the redirectUrl`,
65
+ * the order code is appened to the `redirectUrl`. For the second method, the order code is not appended to the specified `redirectUrl`.
54
66
  *
55
67
  * ```GraphQL
56
68
  * mutation CreateMolliePaymentIntent {
57
69
  * createMolliePaymentIntent(input: {
70
+ * redirectUrl: "https://storefront/order"
58
71
  * paymentMethodCode: "mollie-payment-method"
72
+ * molliePaymentMethodCode: "ideal"
59
73
  * }) {
60
74
  * ... on MolliePaymentIntent {
61
- url
62
- }
63
- ... on MolliePaymentIntentError {
64
- errorCode
65
- message
66
- }
75
+ * url
76
+ * }
77
+ * ... on MolliePaymentIntentError {
78
+ * errorCode
79
+ * message
80
+ * }
67
81
  * }
68
82
  * }
69
83
  * ```
84
+ *
70
85
  * The response will contain
71
86
  * a redirectUrl, which can be used to redirect your customer to the Mollie
72
87
  * platform.
73
88
  *
89
+ * 'molliePaymentMethodCode' is an optional parameter that can be passed to skip Mollie's hosted payment method selection screen
90
+ * You can get available Mollie payment methods with the following query:
91
+ *
92
+ * ```GraphQL
93
+ * {
94
+ * molliePaymentMethods(input: { paymentMethodCode: "mollie-payment-method" }) {
95
+ * id
96
+ * code
97
+ * description
98
+ * minimumAmount {
99
+ * value
100
+ * currency
101
+ * }
102
+ * maximumAmount {
103
+ * value
104
+ * currency
105
+ * }
106
+ * image {
107
+ * size1x
108
+ * size2x
109
+ * svg
110
+ * }
111
+ * }
112
+ * }
113
+ * ```
114
+ * You can pass `MolliePaymentMethod.code` to the `createMolliePaymentIntent` mutation to skip the method selection.
115
+ *
74
116
  * After completing payment on the Mollie platform,
75
117
  * the user is redirected to the configured redirect url + orderCode: `https://storefront/order/CH234X5`
76
118
  *
77
- * ## Local development
119
+ * ## Pay later methods
120
+ * Mollie supports pay-later methods like 'Klarna Pay Later'. For pay-later methods, the status of an order is
121
+ * 'PaymentAuthorized' after the Mollie hosted checkout. You need to manually settle the payment via the admin ui to capture the payment!
122
+ * Make sure you capture a payment within 28 days, because this is the Klarna expiry time
78
123
  *
79
- * Use something like [localtunnel](https://github.com/localtunnel/localtunnel) to test on localhost.
80
- *
81
- * ```bash
82
- * npx localtunnel --port 3000 --subdomain my-shop-local-dev
83
- * > your url is: https://my-shop-local-dev.loca.lt <- use this as the vendureHost for local dev.
84
- * ```
124
+ * If you don't want this behaviour (Authorized first), you can set 'autoCapture=true' on the payment method. This option will immediately
125
+ * capture the payment after a customer authorizes the payment.
85
126
  *
86
- * @docsCategory payments-plugin
127
+ * @docsCategory core plugins/PaymentsPlugin
87
128
  * @docsPage MolliePlugin
88
129
  * @docsWeight 0
89
130
  */
@@ -92,6 +133,7 @@ let MolliePlugin = MolliePlugin_1 = class MolliePlugin {
92
133
  * @description
93
134
  * Initialize the mollie payment plugin
94
135
  * @param vendureHost is needed to pass to mollie for callback
136
+ * @param useDynamicRedirectUrl to indicate if the redirectUrl can be passed via the `createPaymentIntent` mutation, versus being configured in the Payment Method.
95
137
  */
96
138
  static init(options) {
97
139
  this.options = options;
@@ -1 +1 @@
1
- {"version":3,"file":"mollie.plugin.js","sourceRoot":"","sources":["../../src/mollie/mollie.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAwF;AAGxF,2CAAkD;AAClD,6DAAkD;AAClD,2DAAuD;AACvD,qDAAwD;AACxD,uDAAmD;AACnD,qDAAiD;AAiBjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuEG;AAcH,IAAa,YAAY,oBAAzB,MAAa,YAAY;IAGrB;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAC,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACxB,CAAC;CACJ,CAAA;AAZY,YAAY;IAbxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,EAAE,EAAE,OAAO,EAAE,+BAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,cAAY,CAAC,OAAO,EAAE,CAAC;QACpG,aAAa,EAAE,CAAC,MAA4B,EAAE,EAAE;YAC5C,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,qCAAoB,CAAC,CAAC;YACvE,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,iBAAiB,EAAE;YACf,MAAM,EAAE,+BAAU;YAClB,SAAS,EAAE,CAAC,gCAAc,CAAC;SAC9B;KACJ,CAAC;GACW,YAAY,CAYxB;AAZY,oCAAY"}
1
+ {"version":3,"file":"mollie.plugin.js","sourceRoot":"","sources":["../../src/mollie/mollie.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAwF;AAExF,2CAAkD;AAClD,6DAAkD;AAClD,2DAAuD;AACvD,qDAAwD;AACxD,uDAAmD;AACnD,qDAAiD;AA8BjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgHG;AAcI,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAGrB;;;;;OAKG;IACH,MAAM,CAAC,IAAI,CAAC,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACxB,CAAC;CACJ,CAAA;AAbY,YAAY;IAbxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,8BAAa,EAAE,EAAE,OAAO,EAAE,+BAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,cAAY,CAAC,OAAO,EAAE,CAAC;QACpG,aAAa,EAAE,CAAC,MAA4B,EAAE,EAAE;YAC5C,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,qCAAoB,CAAC,CAAC;YACvE,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,iBAAiB,EAAE;YACf,MAAM,EAAE,+BAAU;YAClB,SAAS,EAAE,CAAC,gCAAc,CAAC;SAC9B;KACJ,CAAC;GACW,YAAY,CAaxB;AAbY,oCAAY"}
@@ -1,11 +1,10 @@
1
1
  import { RequestContext } from '@vendure/core';
2
- import { MolliePaymentIntent, MolliePaymentIntentError, MolliePaymentIntentResult } from './graphql/generated-shop-types';
2
+ import { MolliePaymentIntent, MolliePaymentIntentError, MolliePaymentIntentInput, MolliePaymentIntentResult, MolliePaymentMethod, MolliePaymentMethodsInput } from './graphql/generated-shop-types';
3
3
  import { MollieService } from './mollie.service';
4
4
  export declare class MollieResolver {
5
5
  private mollieService;
6
6
  constructor(mollieService: MollieService);
7
- createMolliePaymentIntent(ctx: RequestContext, input: {
8
- paymentMethodCode: string;
9
- }): Promise<MolliePaymentIntentResult>;
7
+ createMolliePaymentIntent(ctx: RequestContext, input: MolliePaymentIntentInput): Promise<MolliePaymentIntentResult>;
10
8
  __resolveType(value: MolliePaymentIntentError | MolliePaymentIntent): string;
9
+ molliePaymentMethods(ctx: RequestContext, { paymentMethodCode }: MolliePaymentMethodsInput): Promise<MolliePaymentMethod[]>;
11
10
  }
@@ -21,7 +21,7 @@ let MollieResolver = class MollieResolver {
21
21
  this.mollieService = mollieService;
22
22
  }
23
23
  async createMolliePaymentIntent(ctx, input) {
24
- return this.mollieService.createPaymentIntent(ctx, input.paymentMethodCode);
24
+ return this.mollieService.createPaymentIntent(ctx, input);
25
25
  }
26
26
  __resolveType(value) {
27
27
  if (value.errorCode) {
@@ -31,6 +31,9 @@ let MollieResolver = class MollieResolver {
31
31
  return 'MolliePaymentIntent';
32
32
  }
33
33
  }
34
+ async molliePaymentMethods(ctx, { paymentMethodCode }) {
35
+ return this.mollieService.getEnabledPaymentMethods(ctx, paymentMethodCode);
36
+ }
34
37
  };
35
38
  __decorate([
36
39
  (0, graphql_1.Mutation)(),
@@ -48,6 +51,15 @@ __decorate([
48
51
  __metadata("design:paramtypes", [Object]),
49
52
  __metadata("design:returntype", String)
50
53
  ], MollieResolver.prototype, "__resolveType", null);
54
+ __decorate([
55
+ (0, graphql_1.Query)(),
56
+ (0, core_1.Allow)(core_1.Permission.Public),
57
+ __param(0, (0, core_1.Ctx)()),
58
+ __param(1, (0, graphql_1.Args)('input')),
59
+ __metadata("design:type", Function),
60
+ __metadata("design:paramtypes", [core_1.RequestContext, Object]),
61
+ __metadata("design:returntype", Promise)
62
+ ], MollieResolver.prototype, "molliePaymentMethods", null);
51
63
  MollieResolver = __decorate([
52
64
  (0, graphql_1.Resolver)(),
53
65
  __metadata("design:paramtypes", [mollie_service_1.MollieService])
@@ -1 +1 @@
1
- {"version":3,"file":"mollie.resolver.js","sourceRoot":"","sources":["../../src/mollie/mollie.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAyE;AACzE,wCAAuE;AAOvE,qDAAiD;AAGjD,IAAa,cAAc,GAA3B,MAAa,cAAc;IACvB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAIpD,KAAK,CAAC,yBAAyB,CACpB,GAAmB,EACX,KAAoC;QAEnD,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,GAAG,EAAE,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAChF,CAAC;IAID,aAAa,CAAC,KAAqD;QAC/D,IAAK,KAAkC,CAAC,SAAS,EAAE;YAC/C,OAAO,0BAA0B,CAAC;SACrC;aAAM;YACH,OAAO,qBAAqB,CAAC;SAChC;IACL,CAAC;CACJ,CAAA;AAhBG;IAFC,IAAA,kBAAQ,GAAE;IACV,IAAA,YAAK,EAAC,iBAAU,CAAC,KAAK,CAAC;IAEnB,WAAA,IAAA,UAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAI,EAAC,OAAO,CAAC,CAAA;;qCADF,qBAAc;;+DAI7B;AAID;IAFC,IAAA,sBAAY,GAAE;IACd,IAAA,kBAAQ,EAAC,2BAA2B,CAAC;;;;mDAOrC;AApBQ,cAAc;IAD1B,IAAA,kBAAQ,GAAE;qCAE4B,8BAAa;GADvC,cAAc,CAqB1B;AArBY,wCAAc"}
1
+ {"version":3,"file":"mollie.resolver.js","sourceRoot":"","sources":["../../src/mollie/mollie.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAgF;AAChF,wCAAuE;AAUvE,qDAAiD;AAG1C,IAAM,cAAc,GAApB,MAAM,cAAc;IACvB,YAAoB,aAA4B;QAA5B,kBAAa,GAAb,aAAa,CAAe;IAAG,CAAC;IAI9C,AAAN,KAAK,CAAC,yBAAyB,CACpB,GAAmB,EACX,KAA+B;QAE9C,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC;IAC9D,CAAC;IAID,aAAa,CAAC,KAAqD;QAC/D,IAAK,KAAkC,CAAC,SAAS,EAAE;YAC/C,OAAO,0BAA0B,CAAC;SACrC;aAAM;YACH,OAAO,qBAAqB,CAAC;SAChC;IACL,CAAC;IAIK,AAAN,KAAK,CAAC,oBAAoB,CACf,GAAmB,EACX,EAAE,iBAAiB,EAA6B;QAE/D,OAAO,IAAI,CAAC,aAAa,CAAC,wBAAwB,CAAC,GAAG,EAAE,iBAAiB,CAAC,CAAC;IAC/E,CAAC;CACJ,CAAA;AAzBS;IAFL,IAAA,kBAAQ,GAAE;IACV,IAAA,YAAK,EAAC,iBAAU,CAAC,KAAK,CAAC;IAEnB,WAAA,IAAA,UAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAI,EAAC,OAAO,CAAC,CAAA;;qCADF,qBAAc;;+DAI7B;AAED;IAAC,IAAA,sBAAY,GAAE;IACd,IAAA,kBAAQ,EAAC,2BAA2B,CAAC;;;;mDAOrC;AAIK;IAFL,IAAA,eAAK,GAAE;IACP,IAAA,YAAK,EAAC,iBAAU,CAAC,MAAM,CAAC;IAEpB,WAAA,IAAA,UAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAI,EAAC,OAAO,CAAC,CAAA;;qCADF,qBAAc;;0DAI7B;AA7BQ,cAAc;IAD1B,IAAA,kBAAQ,GAAE;qCAE4B,8BAAa;GADvC,cAAc,CA8B1B;AA9BY,wCAAc"}
@@ -1,27 +1,38 @@
1
- import { ActiveOrderService, ChannelService, EntityHydrator, OrderService, PaymentMethodService, RequestContext } from '@vendure/core';
2
- import { MolliePaymentIntentResult } from './graphql/generated-shop-types';
1
+ import { Order as MollieOrder } from '@mollie/api-client';
2
+ import { ActiveOrderService, EntityHydrator, Order, OrderService, PaymentMethodService, ProductVariant, ProductVariantService, RequestContext } from '@vendure/core';
3
+ import { MolliePaymentIntentInput, MolliePaymentIntentResult, MolliePaymentMethod } from './graphql/generated-shop-types';
3
4
  import { MolliePluginOptions } from './mollie.plugin';
4
- interface SettlePaymentInput {
5
+ interface OrderStatusInput {
5
6
  channelToken: string;
6
7
  paymentMethodId: string;
7
- paymentId: string;
8
+ orderId: string;
8
9
  }
9
10
  export declare class MollieService {
10
11
  private paymentMethodService;
11
12
  private options;
12
13
  private activeOrderService;
13
14
  private orderService;
14
- private channelService;
15
15
  private entityHydrator;
16
- constructor(paymentMethodService: PaymentMethodService, options: MolliePluginOptions, activeOrderService: ActiveOrderService, orderService: OrderService, channelService: ChannelService, entityHydrator: EntityHydrator);
16
+ private variantService;
17
+ constructor(paymentMethodService: PaymentMethodService, options: MolliePluginOptions, activeOrderService: ActiveOrderService, orderService: OrderService, entityHydrator: EntityHydrator, variantService: ProductVariantService);
17
18
  /**
18
19
  * Creates a redirectUrl to Mollie for the given paymentMethod and current activeOrder
19
20
  */
20
- createPaymentIntent(ctx: RequestContext, paymentMethodCode: string): Promise<MolliePaymentIntentResult>;
21
+ createPaymentIntent(ctx: RequestContext, input: MolliePaymentIntentInput): Promise<MolliePaymentIntentResult>;
21
22
  /**
22
- * Makes a request to Mollie to verify the given payment by id
23
+ * Update Vendure payments and order status based on the incoming Mollie order
23
24
  */
24
- settlePayment({ channelToken, paymentMethodId, paymentId }: SettlePaymentInput): Promise<void>;
25
- private createContext;
25
+ handleMollieStatusUpdate(ctx: RequestContext, { channelToken, paymentMethodId, orderId }: OrderStatusInput): Promise<void>;
26
+ /**
27
+ * Add payment to order. Can be settled or authorized depending on the payment method.
28
+ */
29
+ addPayment(ctx: RequestContext, order: Order, mollieOrder: MollieOrder, paymentMethodCode: string, status: 'Authorized' | 'Settled'): Promise<Order>;
30
+ /**
31
+ * Settle an existing payment based on the given mollieOrder
32
+ */
33
+ settleExistingPayment(ctx: RequestContext, order: Order, mollieOrderId: string): Promise<void>;
34
+ getEnabledPaymentMethods(ctx: RequestContext, paymentMethodCode: string): Promise<MolliePaymentMethod[]>;
35
+ getVariantsWithInsufficientStock(ctx: RequestContext, order: Order): Promise<ProductVariant[]>;
36
+ private getPaymentMethod;
26
37
  }
27
38
  export {};