@vendure/payments-plugin 2.1.0-next.5 → 2.1.0-next.7

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.
@@ -1,2 +1 @@
1
- export * from './stripe.plugin';
2
- export * from './';
1
+ export { StripePlugin } from './stripe.plugin';
@@ -1,19 +1,6 @@
1
1
  "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
2
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./stripe.plugin"), exports);
18
- __exportStar(require("./"), exports);
3
+ exports.StripePlugin = void 0;
4
+ var stripe_plugin_1 = require("./stripe.plugin");
5
+ Object.defineProperty(exports, "StripePlugin", { enumerable: true, get: function () { return stripe_plugin_1.StripePlugin; } });
19
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stripe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,kDAAgC;AAChC,qCAAmB"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stripe/index.ts"],"names":[],"mappings":";;;AAAA,iDAA+C;AAAtC,6GAAA,YAAY,OAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"stripe-client.js","sourceRoot":"","sources":["../../src/stripe/stripe-client.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B;;GAEG;AACH,MAAa,mBAAoB,SAAQ,gBAAM;IAC3C,YAAoB,MAAc,EAAS,aAAqB;QAC5D,KAAK,CAAC,MAAM,EAAE;YACV,UAAU,EAAE,IAAW,EAAE,+BAA+B;SAC3D,CAAC,CAAC;QAHa,WAAM,GAAN,MAAM,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAQ;IAIhE,CAAC;CACJ;AAND,kDAMC"}
1
+ {"version":3,"file":"stripe-client.js","sourceRoot":"","sources":["../../src/stripe/stripe-client.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAE5B;;GAEG;AACH,MAAa,mBAAoB,SAAQ,gBAAM;IAC3C,YAAoB,MAAc,EAAS,aAAqB;QAC5D,KAAK,CAAC,MAAM,EAAE;YACV,UAAU,EAAE,IAA0C,EAAE,+BAA+B;SAC1F,CAAC,CAAC;QAHa,WAAM,GAAN,MAAM,CAAQ;QAAS,kBAAa,GAAb,aAAa,CAAQ;IAIhE,CAAC;CACJ;AAND,kDAMC"}
@@ -13,10 +13,9 @@ exports.getAmountFromStripeMinorUnits = exports.getAmountInStripeMinorUnits = vo
13
13
  * stores money amounts multiplied by 100). See https://github.com/vendure-ecommerce/vendure/issues/1630
14
14
  */
15
15
  function getAmountInStripeMinorUnits(order) {
16
- const amountInStripeMinorUnits = currencyHasFractionPart(order.currencyCode)
16
+ return currencyHasFractionPart(order.currencyCode)
17
17
  ? order.totalWithTax
18
18
  : Math.round(order.totalWithTax / 100);
19
- return amountInStripeMinorUnits;
20
19
  }
21
20
  exports.getAmountInStripeMinorUnits = getAmountInStripeMinorUnits;
22
21
  /**
@@ -25,10 +24,7 @@ exports.getAmountInStripeMinorUnits = getAmountInStripeMinorUnits;
25
24
  * used by Vendure.
26
25
  */
27
26
  function getAmountFromStripeMinorUnits(order, stripeAmount) {
28
- const amountInVendureMinorUnits = currencyHasFractionPart(order.currencyCode)
29
- ? stripeAmount
30
- : stripeAmount * 100;
31
- return amountInVendureMinorUnits;
27
+ return currencyHasFractionPart(order.currencyCode) ? stripeAmount : stripeAmount * 100;
32
28
  }
33
29
  exports.getAmountFromStripeMinorUnits = getAmountFromStripeMinorUnits;
34
30
  function currencyHasFractionPart(currencyCode) {
@@ -37,7 +33,6 @@ function currencyHasFractionPart(currencyCode) {
37
33
  currency: currencyCode,
38
34
  currencyDisplay: 'symbol',
39
35
  }).formatToParts(123.45);
40
- const hasFractionPart = !!parts.find(p => p.type === 'fraction');
41
- return hasFractionPart;
36
+ return !!parts.find(p => p.type === 'fraction');
42
37
  }
43
38
  //# sourceMappingURL=stripe-utils.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe-utils.js","sourceRoot":"","sources":["../../src/stripe/stripe-utils.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,2BAA2B,CAAC,KAAY;IACpD,MAAM,wBAAwB,GAAG,uBAAuB,CAAC,KAAK,CAAC,YAAY,CAAC;QACxE,CAAC,CAAC,KAAK,CAAC,YAAY;QACpB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC;IAC3C,OAAO,wBAAwB,CAAC;AACpC,CAAC;AALD,kEAKC;AAED;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,KAAY,EAAE,YAAoB;IAC5E,MAAM,yBAAyB,GAAG,uBAAuB,CAAC,KAAK,CAAC,YAAY,CAAC;QACzE,CAAC,CAAC,YAAY;QACd,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC;IACzB,OAAO,yBAAyB,CAAC;AACrC,CAAC;AALD,sEAKC;AAED,SAAS,uBAAuB,CAAC,YAA0B;IACvD,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;QAC3C,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,YAAY;QACtB,eAAe,EAAE,QAAQ;KAC5B,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IACzB,MAAM,eAAe,GAAG,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;IACjE,OAAO,eAAe,CAAC;AAC3B,CAAC"}
1
+ {"version":3,"file":"stripe-utils.js","sourceRoot":"","sources":["../../src/stripe/stripe-utils.ts"],"names":[],"mappings":";;;AAEA;;;;;;;;;;GAUG;AACH,SAAgB,2BAA2B,CAAC,KAAY;IACpD,OAAO,uBAAuB,CAAC,KAAK,CAAC,YAAY,CAAC;QAC9C,CAAC,CAAC,KAAK,CAAC,YAAY;QACpB,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,YAAY,GAAG,GAAG,CAAC,CAAC;AAC/C,CAAC;AAJD,kEAIC;AAED;;;;GAIG;AACH,SAAgB,6BAA6B,CAAC,KAAY,EAAE,YAAoB;IAC5E,OAAO,uBAAuB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,YAAY,GAAG,GAAG,CAAC;AAC3F,CAAC;AAFD,sEAEC;AAED,SAAS,uBAAuB,CAAC,YAA0B;IACvD,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,SAAS,EAAE;QAC3C,KAAK,EAAE,UAAU;QACjB,QAAQ,EAAE,YAAY;QACtB,eAAe,EAAE,QAAQ;KAC5B,CAAC,CAAC,aAAa,CAAC,MAAM,CAAC,CAAC;IAEzB,OAAO,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;AACpD,CAAC"}
@@ -1,5 +1,5 @@
1
- import { OrderService, PaymentMethodService, RequestContextService } from '@vendure/core';
2
- import { Response } from 'express';
1
+ import { OrderService, PaymentMethodService, RequestContextService, TransactionalConnection } from '@vendure/core';
2
+ import type { Response } from 'express';
3
3
  import { StripeService } from './stripe.service';
4
4
  import { RequestWithRawBody } from './types';
5
5
  export declare class StripeController {
@@ -7,7 +7,8 @@ export declare class StripeController {
7
7
  private orderService;
8
8
  private stripeService;
9
9
  private requestContextService;
10
- constructor(paymentMethodService: PaymentMethodService, orderService: OrderService, stripeService: StripeService, requestContextService: RequestContextService);
10
+ private connection;
11
+ constructor(paymentMethodService: PaymentMethodService, orderService: OrderService, stripeService: StripeService, requestContextService: RequestContextService, connection: TransactionalConnection);
11
12
  webhook(signature: string | undefined, request: RequestWithRawBody, response: Response): Promise<void>;
12
13
  private createContext;
13
14
  private getPaymentMethod;
@@ -23,14 +23,14 @@ const missingHeaderErrorMessage = 'Missing stripe-signature header';
23
23
  const signatureErrorMessage = 'Error verifying Stripe webhook signature';
24
24
  const noPaymentIntentErrorMessage = 'No payment intent in the event payload';
25
25
  let StripeController = class StripeController {
26
- constructor(paymentMethodService, orderService, stripeService, requestContextService) {
26
+ constructor(paymentMethodService, orderService, stripeService, requestContextService, connection) {
27
27
  this.paymentMethodService = paymentMethodService;
28
28
  this.orderService = orderService;
29
29
  this.stripeService = stripeService;
30
30
  this.requestContextService = requestContextService;
31
+ this.connection = connection;
31
32
  }
32
33
  async webhook(signature, request, response) {
33
- var _a, _b;
34
34
  if (!signature) {
35
35
  core_1.Logger.error(missingHeaderErrorMessage, constants_1.loggerCtx);
36
36
  response.status(common_1.HttpStatus.BAD_REQUEST).send(missingHeaderErrorMessage);
@@ -44,51 +44,53 @@ let StripeController = class StripeController {
44
44
  return;
45
45
  }
46
46
  const { metadata: { channelToken, orderCode, orderId } = {} } = paymentIntent;
47
- const ctx = await this.createContext(channelToken, request);
48
- const order = await this.orderService.findOneByCode(ctx, orderCode);
49
- if (!order) {
50
- throw Error(`Unable to find order ${orderCode}, unable to settle payment ${paymentIntent.id}!`);
51
- }
52
- try {
53
- // Throws an error if the signature is invalid
54
- await this.stripeService.constructEventFromPayload(ctx, order, request.rawBody, signature);
55
- }
56
- catch (e) {
57
- core_1.Logger.error(`${signatureErrorMessage} ${signature}: ${e === null || e === void 0 ? void 0 : e.message}`, constants_1.loggerCtx);
58
- response.status(common_1.HttpStatus.BAD_REQUEST).send(signatureErrorMessage);
59
- return;
60
- }
61
- if (event.type === 'payment_intent.payment_failed') {
62
- const message = (_b = (_a = paymentIntent.last_payment_error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'unknown error';
63
- core_1.Logger.warn(`Payment for order ${orderCode} failed: ${message}`, constants_1.loggerCtx);
64
- response.status(common_1.HttpStatus.OK).send('Ok');
65
- return;
66
- }
67
- if (event.type !== 'payment_intent.succeeded') {
68
- // This should never happen as the webhook is configured to receive
69
- // payment_intent.succeeded and payment_intent.payment_failed events only
70
- core_1.Logger.info(`Received ${event.type} status update for order ${orderCode}`, constants_1.loggerCtx);
71
- return;
72
- }
73
- if (order.state !== 'ArrangingPayment') {
74
- const transitionToStateResult = await this.orderService.transitionToState(ctx, orderId, 'ArrangingPayment');
75
- if (transitionToStateResult instanceof generated_graphql_shop_errors_1.OrderStateTransitionError) {
76
- core_1.Logger.error(`Error transitioning order ${orderCode} to ArrangingPayment state: ${transitionToStateResult.message}`, constants_1.loggerCtx);
47
+ const outerCtx = await this.createContext(channelToken, request);
48
+ await this.connection.withTransaction(outerCtx, async (ctx) => {
49
+ var _a, _b;
50
+ const order = await this.orderService.findOneByCode(ctx, orderCode);
51
+ if (!order) {
52
+ throw new Error(`Unable to find order ${orderCode}, unable to settle payment ${paymentIntent.id}!`);
53
+ }
54
+ try {
55
+ // Throws an error if the signature is invalid
56
+ await this.stripeService.constructEventFromPayload(ctx, order, request.rawBody, signature);
57
+ }
58
+ catch (e) {
59
+ core_1.Logger.error(`${signatureErrorMessage} ${signature}: ${e === null || e === void 0 ? void 0 : e.message}`, constants_1.loggerCtx);
60
+ response.status(common_1.HttpStatus.BAD_REQUEST).send(signatureErrorMessage);
77
61
  return;
78
62
  }
79
- }
80
- const paymentMethod = await this.getPaymentMethod(ctx);
81
- const addPaymentToOrderResult = await this.orderService.addPaymentToOrder(ctx, orderId, {
82
- method: paymentMethod.code,
83
- metadata: {
84
- paymentIntentAmountReceived: paymentIntent.amount_received,
85
- paymentIntentId: paymentIntent.id,
86
- },
63
+ if (event.type === 'payment_intent.payment_failed') {
64
+ const message = (_b = (_a = paymentIntent.last_payment_error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : 'unknown error';
65
+ core_1.Logger.warn(`Payment for order ${orderCode} failed: ${message}`, constants_1.loggerCtx);
66
+ response.status(common_1.HttpStatus.OK).send('Ok');
67
+ return;
68
+ }
69
+ if (event.type !== 'payment_intent.succeeded') {
70
+ // This should never happen as the webhook is configured to receive
71
+ // payment_intent.succeeded and payment_intent.payment_failed events only
72
+ core_1.Logger.info(`Received ${event.type} status update for order ${orderCode}`, constants_1.loggerCtx);
73
+ return;
74
+ }
75
+ if (order.state !== 'ArrangingPayment') {
76
+ const transitionToStateResult = await this.orderService.transitionToState(ctx, orderId, 'ArrangingPayment');
77
+ if (transitionToStateResult instanceof generated_graphql_shop_errors_1.OrderStateTransitionError) {
78
+ core_1.Logger.error(`Error transitioning order ${orderCode} to ArrangingPayment state: ${transitionToStateResult.message}`, constants_1.loggerCtx);
79
+ return;
80
+ }
81
+ }
82
+ const paymentMethod = await this.getPaymentMethod(ctx);
83
+ const addPaymentToOrderResult = await this.orderService.addPaymentToOrder(ctx, orderId, {
84
+ method: paymentMethod.code,
85
+ metadata: {
86
+ paymentIntentAmountReceived: paymentIntent.amount_received,
87
+ paymentIntentId: paymentIntent.id,
88
+ },
89
+ });
90
+ if (!(addPaymentToOrderResult instanceof core_1.Order)) {
91
+ core_1.Logger.error(`Error adding payment to order ${orderCode}: ${addPaymentToOrderResult.message}`, constants_1.loggerCtx);
92
+ }
87
93
  });
88
- if (!(addPaymentToOrderResult instanceof core_1.Order)) {
89
- core_1.Logger.error(`Error adding payment to order ${orderCode}: ${addPaymentToOrderResult.message}`, constants_1.loggerCtx);
90
- return;
91
- }
92
94
  core_1.Logger.info(`Stripe payment intent id ${paymentIntent.id} added to order ${orderCode}`, constants_1.loggerCtx);
93
95
  response.status(common_1.HttpStatus.OK).send('Ok');
94
96
  }
@@ -122,7 +124,8 @@ StripeController = __decorate([
122
124
  __metadata("design:paramtypes", [core_1.PaymentMethodService,
123
125
  core_1.OrderService,
124
126
  stripe_service_1.StripeService,
125
- core_1.RequestContextService])
127
+ core_1.RequestContextService,
128
+ core_1.TransactionalConnection])
126
129
  ], StripeController);
127
130
  exports.StripeController = StripeController;
128
131
  //# sourceMappingURL=stripe.controller.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.controller.js","sourceRoot":"","sources":["../../src/stripe/stripe.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAiF;AACjF,wCAUuB;AACvB,iHAA0G;AAI1G,2CAAwC;AACxC,qDAA8D;AAC9D,qDAAiD;AAGjD,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AACpE,MAAM,qBAAqB,GAAG,0CAA0C,CAAC;AACzE,MAAM,2BAA2B,GAAG,wCAAwC,CAAC;AAGtE,IAAM,gBAAgB,GAAtB,MAAM,gBAAgB;IACzB,YACY,oBAA0C,EAC1C,YAA0B,EAC1B,aAA4B,EAC5B,qBAA4C;QAH5C,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,iBAAY,GAAZ,YAAY,CAAc;QAC1B,kBAAa,GAAb,aAAa,CAAe;QAC5B,0BAAqB,GAArB,qBAAqB,CAAuB;IACrD,CAAC;IAGE,AAAN,KAAK,CAAC,OAAO,CACoB,SAA6B,EACnD,OAA2B,EAC3B,QAAkB;;QAEzB,IAAI,CAAC,SAAS,EAAE;YACZ,aAAM,CAAC,KAAK,CAAC,yBAAyB,EAAE,qBAAS,CAAC,CAAC;YACnD,QAAQ,CAAC,MAAM,CAAC,mBAAU,CAAC,WAAW,CAAC,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAC;YACxE,OAAO;SACV;QACD,MAAM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,IAAI,CAAC,IAAI,CAAC,CAAC;IAC9C,CAAC;IAEO,KAAK,CAAC,aAAa,CAAC,YAAoB,EAAE,GAAuB;QACrE,OAAO,IAAI,CAAC,qBAAqB,CAAC,MAAM,CAAC;YACrC,OAAO,EAAE,OAAO;YAChB,cAAc,EAAE,YAAY;YAC5B,GAAG;YACH,YAAY,EAAE,mBAAY,CAAC,EAAE;SAChC,CAAC,CAAC;IACP,CAAC;IAEO,KAAK,CAAC,gBAAgB,CAAC,GAAmB;QAC9C,MAAM,MAAM,GAAG,CAAC,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CACpE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,KAAK,2CAA0B,CAAC,IAAI,CAC1D,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,0BAAmB,CAAC,IAAI,qBAAS,uCAAuC,CAAC,CAAC;SACvF;QAED,OAAO,MAAM,CAAC;IAClB,CAAC;CACJ,CAAA;AAjHS;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IAEV,WAAA,IAAA,gBAAO,EAAC,kBAAkB,CAAC,CAAA;IAC3B,WAAA,IAAA,YAAG,GAAE,CAAA;IACL,WAAA,IAAA,YAAG,GAAE,CAAA;;;;+CAwFT;AArGQ,gBAAgB;IAD5B,IAAA,mBAAU,EAAC,UAAU,CAAC;qCAGe,2BAAoB;QAC5B,mBAAY;QACX,8BAAa;QACL,4BAAqB;QAChC,8BAAuB;GANtC,gBAAgB,CA2H5B;AA3HY,4CAAgB"}
@@ -35,6 +35,7 @@ import { StripePluginOptions } from './types';
35
35
  * }),
36
36
  * ]
37
37
  * ````
38
+ * For all the plugin options, see the {@link StripePluginOptions} type.
38
39
  * 2. Create a new PaymentMethod in the Admin UI, and select "Stripe payments" as the handler.
39
40
  * 3. Set the webhook secret and API key in the PaymentMethod form.
40
41
  *
@@ -51,6 +51,7 @@ const stripe_service_1 = require("./stripe.service");
51
51
  * }),
52
52
  * ]
53
53
  * ````
54
+ * For all the plugin options, see the {@link StripePluginOptions} type.
54
55
  * 2. Create a new PaymentMethod in the Admin UI, and select "Stripe payments" as the handler.
55
56
  * 3. Set the webhook secret and API key in the PaymentMethod form.
56
57
  *
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.plugin.js","sourceRoot":"","sources":["../../src/stripe/stripe.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsF;AAEtF,6CAAkC;AAElC,2CAAoD;AACpD,+DAA0D;AAC1D,2DAAuD;AACvD,qDAA8D;AAC9D,uDAAmD;AACnD,qDAAiD;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkJG;AA2CI,IAAM,YAAY,oBAAlB,MAAM,YAAY;IAGrB;;;OAGG;IACH,MAAM,CAAC,IAAI,CAAC,OAA4B;QACpC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,cAAY,CAAC;IACxB,CAAC;CACJ,CAAA;AAXY,YAAY;IA1CxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,iCAAqB;gBAC9B,UAAU,EAAE,GAAwB,EAAE,CAAC,cAAY,CAAC,OAAO;aAC9D;YACD,8BAAa;SAChB;QACD,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,2CAA0B,CAAC,CAAC;YAE7E,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;gBAC9B,KA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,CAAC;CACJ,CAAA;AAXY,YAAY;IA1CxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,iCAAqB;gBAC9B,UAAU,EAAE,GAAwB,EAAE,CAAC,cAAY,CAAC,OAAO;aAC9D;YACD,8BAAa;SAChB;QACD,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,2CAA0B,CAAC,CAAC;YAE7E,MAAM,CAAC,UAAU,CAAC,UAAU,CAAC,IAAI,CAAC;gBAC9B,KAAK,EAAE,kBAAkB;gBACzB,OAAO,EAAE,uCAAiB;gBAC1B,YAAY,EAAE,IAAI;aACrB,CAAC,CAAC;YAEH,IAAI,cAAY,CAAC,OAAO,CAAC,sBAAsB,EAAE;gBAC7C,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAC9B,IAAI,EAAE,kBAAkB;oBACxB,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,oBAAoB,EAAE,CAAC;oBACvE,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,IAAI;iBACjB,CAAC,CAAC;aACN;YAED,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,iBAAiB,EAAE;YACf,MAAM,EAAE,IAAA,iBAAG,EAAA;;;;SAIV;YACD,SAAS,EAAE,CAAC,gCAAc,CAAC;SAC9B;QACD,aAAa,EAAE,QAAQ;KAC1B,CAAC;GACW,YAAY,CAWxB;AAXY,oCAAY"}
@@ -5,11 +5,11 @@ import Stripe from 'stripe';
5
5
  import { VendureStripeClient } from './stripe-client';
6
6
  import { StripePluginOptions } from './types';
7
7
  export declare class StripeService {
8
+ private options;
8
9
  private connection;
9
10
  private paymentMethodService;
10
- private options;
11
11
  private moduleRef;
12
- constructor(connection: TransactionalConnection, paymentMethodService: PaymentMethodService, options: StripePluginOptions, moduleRef: ModuleRef);
12
+ constructor(options: StripePluginOptions, connection: TransactionalConnection, paymentMethodService: PaymentMethodService, moduleRef: ModuleRef);
13
13
  createPaymentIntent(ctx: RequestContext, order: Order): Promise<string>;
14
14
  constructEventFromPayload(ctx: RequestContext, order: Order, payload: Buffer, signature: string): Promise<Stripe.Event>;
15
15
  createRefund(ctx: RequestContext, order: Order, payment: Payment, amount: number): Promise<Stripe.Response<Stripe.Refund>>;
@@ -22,31 +22,28 @@ const stripe_client_1 = require("./stripe-client");
22
22
  const stripe_utils_1 = require("./stripe-utils");
23
23
  const stripe_handler_1 = require("./stripe.handler");
24
24
  let StripeService = class StripeService {
25
- constructor(connection, paymentMethodService, options, moduleRef) {
25
+ constructor(options, connection, paymentMethodService, moduleRef) {
26
+ this.options = options;
26
27
  this.connection = connection;
27
28
  this.paymentMethodService = paymentMethodService;
28
- this.options = options;
29
29
  this.moduleRef = moduleRef;
30
30
  }
31
31
  async createPaymentIntent(ctx, order) {
32
+ var _a, _b, _c;
32
33
  let customerId;
33
34
  const stripe = await this.getStripeClient(ctx, order);
34
35
  if (this.options.storeCustomersInStripe && ctx.activeUserId) {
35
36
  customerId = await this.getStripeCustomerId(ctx, order);
36
37
  }
37
38
  const amountInMinorUnits = (0, stripe_utils_1.getAmountInStripeMinorUnits)(order);
39
+ const additionalParams = await ((_b = (_a = this.options).paymentIntentCreateParams) === null || _b === void 0 ? void 0 : _b.call(_a, new core_2.Injector(this.moduleRef), ctx, order));
38
40
  const metadata = (0, metadata_sanitize_1.sanitizeMetadata)(Object.assign(Object.assign({}, (typeof this.options.metadata === 'function'
39
41
  ? await this.options.metadata(new core_2.Injector(this.moduleRef), ctx, order)
40
42
  : {})), { channelToken: ctx.channel.token, orderId: order.id, orderCode: order.code }));
41
- const { client_secret } = await stripe.paymentIntents.create({
42
- amount: amountInMinorUnits,
43
- currency: order.currencyCode.toLowerCase(),
44
- customer: customerId,
45
- automatic_payment_methods: {
43
+ const allMetadata = Object.assign(Object.assign({}, metadata), (0, metadata_sanitize_1.sanitizeMetadata)((_c = additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.metadata) !== null && _c !== void 0 ? _c : {}));
44
+ const { client_secret } = await stripe.paymentIntents.create(Object.assign(Object.assign({ amount: amountInMinorUnits, currency: order.currencyCode.toLowerCase(), customer: customerId, automatic_payment_methods: {
46
45
  enabled: true,
47
- },
48
- metadata,
49
- }, { idempotencyKey: `${order.code}_${amountInMinorUnits}` });
46
+ } }, (additionalParams !== null && additionalParams !== void 0 ? additionalParams : {})), { metadata: allMetadata }), { idempotencyKey: `${order.code}_${amountInMinorUnits}` });
50
47
  if (!client_secret) {
51
48
  // This should never happen
52
49
  core_2.Logger.warn(`Payment intent creation for order ${order.code} did not return client secret`, constants_1.loggerCtx);
@@ -103,6 +100,7 @@ let StripeService = class StripeService {
103
100
  * Otherwise, creates a new Customer record in Stripe and returns the generated id.
104
101
  */
105
102
  async getStripeCustomerId(ctx, activeOrder) {
103
+ var _a, _b;
106
104
  const [stripe, order] = await Promise.all([
107
105
  this.getStripeClient(ctx, activeOrder),
108
106
  // Load relation with customer not available in the response from activeOrderService.getOrderFromContext()
@@ -125,10 +123,10 @@ let StripeService = class StripeService {
125
123
  stripeCustomerId = stripeCustomers.data[0].id;
126
124
  }
127
125
  else {
128
- const newStripeCustomer = await stripe.customers.create({
129
- email: customer.emailAddress,
130
- name: `${customer.firstName} ${customer.lastName}`,
131
- });
126
+ const additionalParams = await ((_b = (_a = this.options).customerCreateParams) === null || _b === void 0 ? void 0 : _b.call(_a, new core_2.Injector(this.moduleRef), ctx, order));
127
+ const newStripeCustomer = await stripe.customers.create(Object.assign(Object.assign({ email: customer.emailAddress, name: `${customer.firstName} ${customer.lastName}` }, (additionalParams !== null && additionalParams !== void 0 ? additionalParams : {})), ((additionalParams === null || additionalParams === void 0 ? void 0 : additionalParams.metadata)
128
+ ? { metadata: (0, metadata_sanitize_1.sanitizeMetadata)(additionalParams.metadata) }
129
+ : {})));
132
130
  stripeCustomerId = newStripeCustomer.id;
133
131
  core_2.Logger.info(`Created Stripe Customer record for customerId ${customer.id}`, constants_1.loggerCtx);
134
132
  }
@@ -139,9 +137,10 @@ let StripeService = class StripeService {
139
137
  };
140
138
  StripeService = __decorate([
141
139
  (0, common_1.Injectable)(),
142
- __param(2, (0, common_1.Inject)(constants_1.STRIPE_PLUGIN_OPTIONS)),
143
- __metadata("design:paramtypes", [core_2.TransactionalConnection,
144
- core_2.PaymentMethodService, Object, core_1.ModuleRef])
140
+ __param(0, (0, common_1.Inject)(constants_1.STRIPE_PLUGIN_OPTIONS)),
141
+ __metadata("design:paramtypes", [Object, core_2.TransactionalConnection,
142
+ core_2.PaymentMethodService,
143
+ core_1.ModuleRef])
145
144
  ], StripeService);
146
145
  exports.StripeService = StripeService;
147
146
  //# sourceMappingURL=stripe.service.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"stripe.service.js","sourceRoot":"","sources":["../../src/stripe/stripe.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoD;AACpD,uCAAyC;AAEzC,wCAWuB;AAGvB,2CAA+D;AAC/D,2DAAuD;AACvD,mDAAsD;AACtD,iDAA6D;AAC7D,qDAA8D;AAIvD,IAAM,aAAa,GAAnB,MAAM,aAAa;IACtB,YACY,UAAmC,EACnC,oBAA0C,EACX,OAA4B,EAC3D,SAAoB;QAHpB,eAAU,GAAV,UAAU,CAAyB;QACnC,yBAAoB,GAApB,oBAAoB,CAAsB;QACX,YAAO,GAAP,OAAO,CAAqB;QAC3D,cAAS,GAAT,SAAS,CAAW;IAC7B,CAAC;IAEJ,KAAK,CAAC,mBAAmB,CAAC,GAAmB,EAAE,KAAY;QACvD,IAAI,UAA8B,CAAC;QACnC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,eAAe,CA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Y,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;QAC1D,MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,eAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;QAErF,OAAO,gBAAgB,CAAC;IAC5B,CAAC;CACJ,CAAA;AAhLY,aAAa;IADzB,IAAA,mBAAU,GAAE;IAGJ,WAAA,IAAA,eAAM,EAAC,iCAAqB,CAAC,CAAA;6CACV,8BAAuB;QACb,2BAAoB;QAC/B,gBAAS;GALvB,aAAa,CAgLzB;AAhLY,sCAAa"}
@@ -1,13 +1,15 @@
1
1
  /// <reference types="node" />
2
- import { Injector, Order, RequestContext } from '@vendure/core';
3
2
  import '@vendure/core/dist/entity/custom-entity-fields';
4
- import { Request } from 'express';
5
- import Stripe from 'stripe';
3
+ import type { Injector, Order, RequestContext } from '@vendure/core';
4
+ import type { Request } from 'express';
5
+ import type Stripe from 'stripe';
6
6
  declare module '@vendure/core/dist/entity/custom-entity-fields' {
7
7
  interface CustomCustomerFields {
8
8
  stripeCustomerId?: string;
9
9
  }
10
10
  }
11
+ type AdditionalPaymentIntentCreateParams = Partial<Omit<Stripe.PaymentIntentCreateParams, 'amount' | 'currency' | 'customer'>>;
12
+ type AdditionalCustomerCreateParams = Partial<Omit<Stripe.CustomerCreateParams, 'email'>>;
11
13
  /**
12
14
  * @description
13
15
  * Configuration options for the Stripe payments plugin.
@@ -28,12 +30,106 @@ export interface StripePluginOptions {
28
30
  storeCustomersInStripe?: boolean;
29
31
  /**
30
32
  * @description
31
- * Attach extra metadata to Stripe payment intent
33
+ * Attach extra metadata to Stripe payment intent creation call.
34
+ *
35
+ * @example
36
+ * ```ts
37
+ * import { EntityHydrator, VendureConfig } from '\@vendure/core';
38
+ * import { StripePlugin } from '\@vendure/payments-plugin/package/stripe';
39
+ *
40
+ * export const config: VendureConfig = {
41
+ * // ...
42
+ * plugins: [
43
+ * StripePlugin.init({
44
+ * metadata: async (injector, ctx, order) => {
45
+ * const hydrator = injector.get(EntityHydrator);
46
+ * await hydrator.hydrate(ctx, order, { relations: ['customer'] });
47
+ * return {
48
+ * description: `Order #${order.code} for ${order.customer!.emailAddress}`
49
+ * },
50
+ * }
51
+ * }),
52
+ * ],
53
+ * };
54
+ *
55
+ * Note: If the `paymentIntentCreateParams` is also used and returns a `metadata` key, then the values
56
+ * returned by both functions will be merged.
32
57
  *
33
58
  * @since 1.9.7
34
59
  */
35
60
  metadata?: (injector: Injector, ctx: RequestContext, order: Order) => Stripe.MetadataParam | Promise<Stripe.MetadataParam>;
61
+ /**
62
+ * @description
63
+ * Provide additional parameters to the Stripe payment intent creation. By default,
64
+ * the plugin will already pass the `amount`, `currency`, `customer` and `automatic_payment_methods: { enabled: true }` parameters.
65
+ *
66
+ * For example, if you want to provide a `description` for the payment intent, you can do so like this:
67
+ *
68
+ * @example
69
+ * ```ts
70
+ * import { VendureConfig } from '\@vendure/core';
71
+ * import { StripePlugin } from '\@vendure/payments-plugin/package/stripe';
72
+ *
73
+ * export const config: VendureConfig = {
74
+ * // ...
75
+ * plugins: [
76
+ * StripePlugin.init({
77
+ * paymentIntentCreateParams: (injector, ctx, order) => {
78
+ * return {
79
+ * description: `Order #${order.code} for ${order.customer?.emailAddress}`
80
+ * },
81
+ * }
82
+ * }),
83
+ * ],
84
+ * };
85
+ * ```
86
+ *
87
+ * @since 2.1.0
88
+ *
89
+ */
90
+ paymentIntentCreateParams?: (injector: Injector, ctx: RequestContext, order: Order) => AdditionalPaymentIntentCreateParams | Promise<AdditionalPaymentIntentCreateParams>;
91
+ /**
92
+ * @description
93
+ * Provide additional parameters to the Stripe customer creation. By default,
94
+ * the plugin will already pass the `email` and `name` parameters.
95
+ *
96
+ * For example, if you want to provide an address for the customer:
97
+ *
98
+ * @example
99
+ * ```ts
100
+ * import { EntityHydrator, VendureConfig } from '\@vendure/core';
101
+ * import { StripePlugin } from '\@vendure/payments-plugin/package/stripe';
102
+ *
103
+ * export const config: VendureConfig = {
104
+ * // ...
105
+ * plugins: [
106
+ * StripePlugin.init({
107
+ * storeCustomersInStripe: true,
108
+ * customerCreateParams: async (injector, ctx, order) => {
109
+ * const entityHydrator = injector.get(EntityHydrator);
110
+ * const customer = order.customer;
111
+ * await entityHydrator.hydrate(ctx, customer, { relations: ['addresses'] });
112
+ * const defaultBillingAddress = customer.addresses.find(a => a.defaultBillingAddress) ?? customer.addresses[0];
113
+ * return {
114
+ * address: {
115
+ * line1: defaultBillingAddress.streetLine1 || order.shippingAddress?.streetLine1,
116
+ * postal_code: defaultBillingAddress.postalCode || order.shippingAddress?.postalCode,
117
+ * city: defaultBillingAddress.city || order.shippingAddress?.city,
118
+ * state: defaultBillingAddress.province || order.shippingAddress?.province,
119
+ * country: defaultBillingAddress.country.code || order.shippingAddress?.countryCode,
120
+ * },
121
+ * },
122
+ * }
123
+ * }),
124
+ * ],
125
+ * };
126
+ * ```
127
+ *
128
+ * @since 2.1.0
129
+ */
130
+ customerCreateParams?: (injector: Injector, ctx: RequestContext, order: Order) => AdditionalCustomerCreateParams | Promise<AdditionalCustomerCreateParams>;
36
131
  }
37
132
  export interface RequestWithRawBody extends Request {
38
133
  rawBody: Buffer;
39
134
  }
135
+ export {};
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/stripe/types.ts"],"names":[],"mappings":";;AACA,0DAAwD"}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/stripe/types.ts"],"names":[],"mappings":";;AAAA,0DAAwD"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vendure/payments-plugin",
3
- "version": "2.1.0-next.5",
3
+ "version": "2.1.0-next.7",
4
4
  "license": "MIT",
5
5
  "main": "package/index.js",
6
6
  "types": "package/index.d.ts",
@@ -46,9 +46,9 @@
46
46
  "@mollie/api-client": "^3.7.0",
47
47
  "@types/braintree": "^2.22.15",
48
48
  "@types/localtunnel": "2.0.1",
49
- "@vendure/common": "2.1.0-next.5",
50
- "@vendure/core": "2.1.0-next.5",
51
- "@vendure/testing": "2.1.0-next.5",
49
+ "@vendure/common": "2.1.0-next.7",
50
+ "@vendure/core": "2.1.0-next.7",
51
+ "@vendure/testing": "2.1.0-next.7",
52
52
  "braintree": "^3.16.0",
53
53
  "localtunnel": "2.0.2",
54
54
  "nock": "^13.1.4",
@@ -56,5 +56,5 @@
56
56
  "stripe": "^13.3.0",
57
57
  "typescript": "4.9.5"
58
58
  },
59
- "gitHead": "b4b78ba7ac534e5995877e46421870b114f429de"
59
+ "gitHead": "4a8a230e1bd234ab92682945e92ee03d8db6b231"
60
60
  }