@vendure/payments-plugin 1.4.7 → 2.0.0-next.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.
- package/package/braintree/braintree.handler.js +4 -4
- package/package/braintree/braintree.handler.js.map +1 -1
- package/package/braintree/braintree.plugin.js +2 -2
- package/package/braintree/braintree.plugin.js.map +1 -1
- package/package/braintree/braintree.resolver.js +6 -6
- package/package/braintree/braintree.resolver.js.map +1 -1
- package/package/braintree/types.d.ts +2 -1
- package/package/braintree/types.js +1 -0
- package/package/braintree/types.js.map +1 -1
- package/package/mollie/mollie.controller.js +7 -7
- package/package/mollie/mollie.controller.js.map +1 -1
- package/package/mollie/mollie.handler.js +2 -2
- package/package/mollie/mollie.handler.js.map +1 -1
- package/package/mollie/mollie.plugin.js +1 -1
- package/package/mollie/mollie.plugin.js.map +1 -1
- package/package/stripe/constants.d.ts +2 -0
- package/package/stripe/constants.js +6 -0
- package/package/stripe/constants.js.map +1 -0
- package/package/stripe/index.d.ts +2 -0
- package/package/stripe/index.js +15 -0
- package/package/stripe/index.js.map +1 -0
- package/package/stripe/raw-body.middleware.d.ts +6 -0
- package/package/stripe/raw-body.middleware.js +17 -0
- package/package/stripe/raw-body.middleware.js.map +1 -0
- package/package/stripe/stripe.controller.d.ts +14 -0
- package/package/stripe/stripe.controller.js +120 -0
- package/package/stripe/stripe.controller.js.map +1 -0
- package/package/stripe/stripe.handler.d.ts +5 -0
- package/package/stripe/stripe.handler.js +69 -0
- package/package/stripe/stripe.handler.js.map +1 -0
- package/package/stripe/stripe.plugin.d.ts +80 -0
- package/package/stripe/stripe.plugin.js +140 -0
- package/package/stripe/stripe.plugin.js.map +1 -0
- package/package/stripe/stripe.resolver.d.ts +8 -0
- package/package/stripe/stripe.resolver.js +46 -0
- package/package/stripe/stripe.resolver.js.map +1 -0
- package/package/stripe/stripe.service.d.ts +19 -0
- package/package/stripe/stripe.service.js +114 -0
- package/package/stripe/stripe.service.js.map +1 -0
- package/package/stripe/types.d.ts +40 -0
- package/package/stripe/types.js +4 -0
- package/package/stripe/types.js.map +1 -0
- package/package.json +10 -8
|
@@ -25,7 +25,7 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
25
25
|
entityHydrator = injector.get(core_1.EntityHydrator);
|
|
26
26
|
},
|
|
27
27
|
async createPayment(ctx, order, amount, args, metadata) {
|
|
28
|
-
const gateway = braintree_common_1.getGateway(args, options);
|
|
28
|
+
const gateway = (0, braintree_common_1.getGateway)(args, options);
|
|
29
29
|
let customerId;
|
|
30
30
|
try {
|
|
31
31
|
await entityHydrator.hydrate(ctx, order, { relations: ['customer'] });
|
|
@@ -52,7 +52,7 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
52
52
|
};
|
|
53
53
|
},
|
|
54
54
|
async createRefund(ctx, input, total, order, payment, args) {
|
|
55
|
-
const gateway = braintree_common_1.getGateway(args, options);
|
|
55
|
+
const gateway = (0, braintree_common_1.getGateway)(args, options);
|
|
56
56
|
const response = await gateway.transaction.refund(payment.transactionId, (total / 100).toString(10));
|
|
57
57
|
if (!response.success) {
|
|
58
58
|
return {
|
|
@@ -85,14 +85,14 @@ async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, c
|
|
|
85
85
|
state: 'Declined',
|
|
86
86
|
transactionId: response.transaction.id,
|
|
87
87
|
errorMessage: response.message,
|
|
88
|
-
metadata: braintree_common_1.extractMetadataFromTransaction(response.transaction),
|
|
88
|
+
metadata: (0, braintree_common_1.extractMetadataFromTransaction)(response.transaction),
|
|
89
89
|
};
|
|
90
90
|
}
|
|
91
91
|
return {
|
|
92
92
|
amount,
|
|
93
93
|
state: 'Settled',
|
|
94
94
|
transactionId: response.transaction.id,
|
|
95
|
-
metadata: braintree_common_1.extractMetadataFromTransaction(response.transaction),
|
|
95
|
+
metadata: (0, braintree_common_1.extractMetadataFromTransaction)(response.transaction),
|
|
96
96
|
};
|
|
97
97
|
}
|
|
98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|
};
|
|
206
206
|
BraintreePlugin.options = {};
|
|
207
207
|
BraintreePlugin = BraintreePlugin_1 = __decorate([
|
|
208
|
-
core_1.VendurePlugin({
|
|
208
|
+
(0, core_1.VendurePlugin)({
|
|
209
209
|
imports: [core_1.PluginCommonModule],
|
|
210
210
|
providers: [
|
|
211
211
|
{
|
|
@@ -228,7 +228,7 @@ BraintreePlugin = BraintreePlugin_1 = __decorate([
|
|
|
228
228
|
return config;
|
|
229
229
|
},
|
|
230
230
|
shopApiExtensions: {
|
|
231
|
-
schema: apollo_server_core_1.gql `
|
|
231
|
+
schema: (0, apollo_server_core_1.gql) `
|
|
232
232
|
extend type Query {
|
|
233
233
|
generateBraintreeClientToken(orderId: ID!): String!
|
|
234
234
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"braintree.plugin.js","sourceRoot":"","sources":["../../src/braintree/braintree.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsF;AACtF,2DAAyC;AAEzC,2DAAoE;AACpE,6DAAyD;AACzD,2CAAuD;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuLG;AAgCH,IAAa,eAAe,uBAA5B,MAAa,eAAe;IAExB,MAAM,CAAC,IAAI,CAAC,OAA+B;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,iBAAe,CAAC;IAC3B,CAAC;CACJ,CAAA;AALU,uBAAO,GAA2B,
|
|
1
|
+
{"version":3,"file":"braintree.plugin.js","sourceRoot":"","sources":["../../src/braintree/braintree.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsF;AACtF,2DAAyC;AAEzC,2DAAoE;AACpE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AAA;;;;SAIV;YACD,SAAS,EAAE,CAAC,sCAAiB,CAAC;SACjC;KACJ,CAAC;GACW,eAAe,CAM3B;AANY,0CAAe"}
|
|
@@ -31,7 +31,7 @@ let BraintreeResolver = class BraintreeResolver {
|
|
|
31
31
|
if (order && order.customer) {
|
|
32
32
|
const customerId = (_a = order.customer.customFields.braintreeCustomerId) !== null && _a !== void 0 ? _a : undefined;
|
|
33
33
|
const args = await this.getPaymentMethodArgs(ctx);
|
|
34
|
-
const gateway = braintree_common_1.getGateway(args, this.options);
|
|
34
|
+
const gateway = (0, braintree_common_1.getGateway)(args, this.options);
|
|
35
35
|
try {
|
|
36
36
|
const result = await gateway.clientToken.generate({ customerId });
|
|
37
37
|
return result.clientToken;
|
|
@@ -56,16 +56,16 @@ let BraintreeResolver = class BraintreeResolver {
|
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
58
|
__decorate([
|
|
59
|
-
graphql_1.Query(),
|
|
60
|
-
__param(0, core_1.Ctx()),
|
|
61
|
-
__param(1, graphql_1.Args()),
|
|
59
|
+
(0, graphql_1.Query)(),
|
|
60
|
+
__param(0, (0, core_1.Ctx)()),
|
|
61
|
+
__param(1, (0, graphql_1.Args)()),
|
|
62
62
|
__metadata("design:type", Function),
|
|
63
63
|
__metadata("design:paramtypes", [core_1.RequestContext, Object]),
|
|
64
64
|
__metadata("design:returntype", Promise)
|
|
65
65
|
], BraintreeResolver.prototype, "generateBraintreeClientToken", null);
|
|
66
66
|
BraintreeResolver = __decorate([
|
|
67
|
-
graphql_1.Resolver(),
|
|
68
|
-
__param(2, common_1.Inject(constants_1.BRAINTREE_PLUGIN_OPTIONS)),
|
|
67
|
+
(0, graphql_1.Resolver)(),
|
|
68
|
+
__param(2, (0, common_1.Inject)(constants_1.BRAINTREE_PLUGIN_OPTIONS)),
|
|
69
69
|
__metadata("design:paramtypes", [core_1.TransactionalConnection,
|
|
70
70
|
core_1.OrderService, Object])
|
|
71
71
|
], BraintreeResolver);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"braintree.resolver.js","sourceRoot":"","sources":["../../src/braintree/braintree.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAwD;AACxD,wCASuB;AAEvB,yDAAgD;AAChD,2DAAoE;AACpE,2CAAkE;AAIlE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAC1B,YACY,UAAmC,EACnC,YAA0B,EACQ,OAA+B;QAFjE,eAAU,GAAV,UAAU,CAAyB;QACnC,iBAAY,GAAZ,YAAY,CAAc;QACQ,YAAO,GAAP,OAAO,CAAwB;IAC1E,CAAC;IAGJ,KAAK,CAAC,4BAA4B,CAAQ,GAAmB,EAAU,EAAE,OAAO,EAAmB;;QAC/F,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,OAAO,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QAC5D,IAAI,KAAK,IAAI,KAAK,CAAC,QAAQ,EAAE;YACzB,MAAM,UAAU,GAAG,MAAA,KAAK,CAAC,QAAQ,CAAC,YAAY,CAAC,mBAAmB,mCAAI,SAAS,CAAC;YAChF,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,GAAG,CAAC,CAAC;YAClD,MAAM,OAAO,GAAG,6BAAU,
|
|
1
|
+
{"version":3,"file":"braintree.resolver.js","sourceRoot":"","sources":["../../src/braintree/braintree.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAwD;AACxD,wCASuB;AAEvB,yDAAgD;AAChD,2DAAoE;AACpE,2CAAkE;AAIlE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAC1B,YACY,UAAmC,EACnC,YAA0B,EACQ,OAA+B;QAFjE,eAAU,GAAV,UAAU,CAAyB;QACnC,iBAAY,GAAZ,YAAY,CAAc;QACQ,YAAO,GAAP,OAAO,CAAwB;IAC1E,CAAC;IAGJ,KAAK,CAAC,4B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CAAC,MAAM,CAAC,CAAC,IAAI,EAAE,GAAG,EAAE,EAAE;YAC5C,uCACO,IAAI,KACP,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,GAAG,CAAC,KAAK,IACvB;QACN,CAAC,EAAE,EAA2B,CAAC,CAAC;IACpC,CAAC;CACJ,CAAA;AApCG;IADC,IAAA,eAAK,GAAE;IAC4B,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,cAAI,GAAE,CAAA;;qCAAvB,qBAAc;;qEAmB5D;AA3BQ,iBAAiB;IAD7B,IAAA,kBAAQ,GAAE;IAKF,WAAA,IAAA,eAAM,EAAC,oCAAwB,CAAC,CAAA;qCAFb,8BAAuB;QACrB,mBAAY;GAH7B,iBAAiB,CA4C7B;AA5CY,8CAAiB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ConfigArgValues } from '@vendure/core/dist/common/configurable-operation';
|
|
2
|
+
import '@vendure/core/dist/entity/custom-entity-fields';
|
|
2
3
|
import { Environment } from 'braintree';
|
|
3
4
|
import { braintreePaymentMethodHandler } from './braintree.handler';
|
|
4
5
|
export declare type PaymentMethodArgsHash = ConfigArgValues<typeof braintreePaymentMethodHandler['args']>;
|
|
5
|
-
declare module '@vendure/core' {
|
|
6
|
+
declare module '@vendure/core/dist/entity/custom-entity-fields' {
|
|
6
7
|
interface CustomCustomerFields {
|
|
7
8
|
braintreeCustomerId?: string;
|
|
8
9
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/braintree/types.ts"],"names":[],"mappings":""}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/braintree/types.ts"],"names":[],"mappings":";;AACA,0DAAwD"}
|
|
@@ -50,13 +50,13 @@ let MollieController = class MollieController {
|
|
|
50
50
|
const paymentMethod = await this.paymentMethodService.findOne(ctx, paymentMethodId);
|
|
51
51
|
if (!paymentMethod) {
|
|
52
52
|
// Fail silently, as we don't want to expose if a paymentMethodId exists or not
|
|
53
|
-
return core_1.Logger.error(`No paymentMethod found with id ${
|
|
53
|
+
return core_1.Logger.error(`No paymentMethod found with id ${paymentMethodId}`, constants_1.loggerCtx);
|
|
54
54
|
}
|
|
55
55
|
const apiKey = (_a = paymentMethod.handler.args.find(a => a.name === 'apiKey')) === null || _a === void 0 ? void 0 : _a.value;
|
|
56
56
|
if (!apiKey) {
|
|
57
57
|
throw Error(`No apiKey found for payment ${paymentMethod.id} for channel ${channelToken}`);
|
|
58
58
|
}
|
|
59
|
-
const client = api_client_1.default({ apiKey });
|
|
59
|
+
const client = (0, api_client_1.default)({ apiKey });
|
|
60
60
|
const molliePayment = await client.payments.get(body.id);
|
|
61
61
|
core_1.Logger.info(`Received payment ${molliePayment.id} for order ${molliePayment.metadata.orderCode} with status ${molliePayment.status}`, constants_1.loggerCtx);
|
|
62
62
|
const dbPayment = await this.connection
|
|
@@ -82,16 +82,16 @@ let MollieController = class MollieController {
|
|
|
82
82
|
}
|
|
83
83
|
};
|
|
84
84
|
__decorate([
|
|
85
|
-
common_1.Post('mollie/:channelToken/:paymentMethodId'),
|
|
86
|
-
__param(0, common_1.Param('channelToken')),
|
|
87
|
-
__param(1, common_1.Param('paymentMethodId')),
|
|
88
|
-
__param(2, common_1.Body()),
|
|
85
|
+
(0, common_1.Post)('mollie/:channelToken/:paymentMethodId'),
|
|
86
|
+
__param(0, (0, common_1.Param)('channelToken')),
|
|
87
|
+
__param(1, (0, common_1.Param)('paymentMethodId')),
|
|
88
|
+
__param(2, (0, common_1.Body)()),
|
|
89
89
|
__metadata("design:type", Function),
|
|
90
90
|
__metadata("design:paramtypes", [String, String, Object]),
|
|
91
91
|
__metadata("design:returntype", Promise)
|
|
92
92
|
], MollieController.prototype, "webhook", null);
|
|
93
93
|
MollieController = __decorate([
|
|
94
|
-
common_1.Controller('payments'),
|
|
94
|
+
(0, common_1.Controller)('payments'),
|
|
95
95
|
__metadata("design:paramtypes", [core_1.OrderService,
|
|
96
96
|
core_1.TransactionalConnection,
|
|
97
97
|
core_1.PaymentMethodService,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mollie.controller.js","sourceRoot":"","sources":["../../src/mollie/mollie.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAuE;AACvE,2CAA+D;AAC/D,wCASuB;AAEvB,2CAAwC;AAGxC,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IACzB,YACY,YAA0B,EAC1B,UAAmC,EACnC,oBAA0C,EAC1C,cAA8B;QAH9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,eAAU,GAAV,UAAU,CAAyB;QACnC,yBAAoB,GAApB,oBAAoB,CAAsB;QAC1C,mBAAc,GAAd,cAAc,CAAgB;IACvC,CAAC;IAGJ,KAAK,CAAC,OAAO,CACc,YAAoB,EACjB,eAAuB,EACzC,IAAS;;QAEjB,MAAM,GAAG,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,YAAY,CAAC,CAAC;QACnD,aAAM,CAAC,IAAI,CAAC,wBAAwB,YAAY,EAAE,EAAE,qBAAS,CAAC,CAAC;QAC/D,MAAM,aAAa,GAAG,MAAM,IAAI,CAAC,oBAAoB,CAAC,OAAO,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QACpF,IAAI,CAAC,aAAa,EAAE;YAChB,+EAA+E;YAC/E,OAAO,aAAM,CAAC,KAAK,CAAC,kCAAkC,
|
|
1
|
+
{"version":3,"file":"mollie.controller.js","sourceRoot":"","sources":["../../src/mollie/mollie.controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAuE;AACvE,2CAA+D;AAC/D,wCASuB;AAEvB,2CAAwC;AAGxC,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IACzB,YACY,YAA0B,EAC1B,UAAmC,EACnC,oBAA0C,EAC1C,cAA8B;QAH9B,iBAAY,G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= new core_1.PaymentMethodHandler({
|
|
|
58
58
|
if (!paymentMethod) {
|
|
59
59
|
throw Error(`No paymentMethod found for given apiKey`); // This should never happen
|
|
60
60
|
}
|
|
61
|
-
const mollieClient = api_client_1.default({ apiKey });
|
|
61
|
+
const mollieClient = (0, api_client_1.default)({ apiKey });
|
|
62
62
|
redirectUrl = redirectUrl.endsWith('/') ? redirectUrl.slice(0, -1) : redirectUrl; // remove appending slash
|
|
63
63
|
const vendureHost = options.vendureHost.endsWith('/')
|
|
64
64
|
? options.vendureHost.slice(0, -1)
|
|
@@ -101,7 +101,7 @@ exports.molliePaymentHandler = new core_1.PaymentMethodHandler({
|
|
|
101
101
|
},
|
|
102
102
|
createRefund: async (ctx, input, amount, order, payment, args) => {
|
|
103
103
|
const { apiKey } = args;
|
|
104
|
-
const mollieClient = api_client_1.default({ apiKey });
|
|
104
|
+
const mollieClient = (0, api_client_1.default)({ apiKey });
|
|
105
105
|
const refund = await mollieClient.payments_refunds.create({
|
|
106
106
|
paymentId: payment.transactionId,
|
|
107
107
|
description: input.reason,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mollie.handler.js","sourceRoot":"","sources":["../../src/mollie/mollie.handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,iEAAsE;AACtE,yEAAmE;AACnE,wCAQuB;AAEvB,2CAA6D;AAG7D,IAAI,oBAA0C,CAAC;AAC/C,IAAI,OAA4B,CAAC;AACpB,QAAA,oBAAoB,GAAG,IAAI,2BAAoB,CAAC;IACzD,IAAI,EAAE,wBAAwB;IAC9B,WAAW,EAAE;QACT;YACI,YAAY,EAAE,8BAAY,CAAC,EAAE;YAC7B,KAAK,EAAE,gBAAgB;SAC1B;KACJ;IACD,IAAI,EAAE;QACF,MAAM,EAAE;YACJ,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,8BAAY,CAAC,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,CA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F,qBAAS,CACZ,CAAC;YACF,OAAO;gBACH,KAAK,EAAE,QAAQ;gBACf,aAAa,EAAE,OAAO,CAAC,aAAa;aACvC,CAAC;SACL;QACD,aAAM,CAAC,IAAI,CACP,qBAAqB,MAAM,CAAC,OAAO,EAAE,cAAc,KAAK,CAAC,IAAI,oBACzD,OAAO,CAAC,aACZ,EAAE,EACF,qBAAS,CACZ,CAAC;QACF,OAAO;YACH,KAAK,EAAE,SAAS;YAChB,aAAa,EAAE,OAAO,CAAC,aAAa;SACvC,CAAC;IACN,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -102,7 +102,7 @@ let MolliePlugin = MolliePlugin_1 = class MolliePlugin {
|
|
|
102
102
|
}
|
|
103
103
|
};
|
|
104
104
|
MolliePlugin = MolliePlugin_1 = __decorate([
|
|
105
|
-
core_1.VendurePlugin({
|
|
105
|
+
(0, core_1.VendurePlugin)({
|
|
106
106
|
imports: [core_1.PluginCommonModule],
|
|
107
107
|
controllers: [mollie_controller_1.MollieController],
|
|
108
108
|
providers: [{ provide: constants_1.PLUGIN_INIT_OPTIONS, useFactory: () => MolliePlugin_1.options }],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mollie.plugin.js","sourceRoot":"","sources":["../../src/mollie/mollie.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAwF;AAExF,2CAAkD;AAClD,2DAAuD;AACvD,qDAAwD;AAiBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAUH,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;IATxB,oBAAa,
|
|
1
|
+
{"version":3,"file":"mollie.plugin.js","sourceRoot":"","sources":["../../src/mollie/mollie.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAwF;AAExF,2CAAkD;AAClD,2DAAuD;AACvD,qDAAwD;AAiBxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6EG;AAUH,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;IATxB,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,WAAW,EAAE,CAAC,oCAAgB,CAAC;QAC/B,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,+BAAmB,EAAE,UAAU,EAAE,GAAG,EAAE,CAAC,cAAY,CAAC,OAAO,EAAE,CAAC;QACrF,aAAa,EAAE,CAAC,MAA4B,EAAE,EAAE;YAC5C,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,qCAAoB,CAAC,CAAC;YACvE,OAAO,MAAM,CAAC;QAClB,CAAC;KACJ,CAAC;GACW,YAAY,CAYxB;AAZY,oCAAY"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.STRIPE_PLUGIN_OPTIONS = exports.loggerCtx = void 0;
|
|
4
|
+
exports.loggerCtx = 'StripePlugin';
|
|
5
|
+
exports.STRIPE_PLUGIN_OPTIONS = Symbol('STRIPE_PLUGIN_OPTIONS');
|
|
6
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/stripe/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG,cAAc,CAAC;AAC3B,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
|
|
5
|
+
}) : (function(o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
o[k2] = m[k];
|
|
8
|
+
}));
|
|
9
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
10
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
11
|
+
};
|
|
12
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
+
__exportStar(require("./stripe.plugin"), exports);
|
|
14
|
+
__exportStar(require("./"), exports);
|
|
15
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/stripe/index.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAAgC;AAChC,qCAAmB"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.rawBodyMiddleware = void 0;
|
|
4
|
+
const body_parser_1 = require("body-parser");
|
|
5
|
+
/**
|
|
6
|
+
* Middleware which adds the raw request body to the incoming message object. This is needed by
|
|
7
|
+
* Stripe to properly verify webhook events.
|
|
8
|
+
*/
|
|
9
|
+
exports.rawBodyMiddleware = (0, body_parser_1.json)({
|
|
10
|
+
verify(req, _, buf) {
|
|
11
|
+
if (Buffer.isBuffer(buf)) {
|
|
12
|
+
req.rawBody = Buffer.from(buf);
|
|
13
|
+
}
|
|
14
|
+
return true;
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
//# sourceMappingURL=raw-body.middleware.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"raw-body.middleware.js","sourceRoot":"","sources":["../../src/stripe/raw-body.middleware.ts"],"names":[],"mappings":";;;AAAA,6CAAmC;AAKnC;;;GAGG;AACU,QAAA,iBAAiB,GAAG,IAAA,kBAAI,EAAC;IAClC,MAAM,CAAC,GAA+B,EAAE,CAAiB,EAAE,GAAW;QAClE,IAAI,MAAM,CAAC,QAAQ,CAAC,GAAG,CAAC,EAAE;YACtB,GAAG,CAAC,OAAO,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;SAClC;QAED,OAAO,IAAI,CAAC;IAChB,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { ChannelService, OrderService, TransactionalConnection } from '@vendure/core';
|
|
2
|
+
import { Response } from 'express';
|
|
3
|
+
import { StripeService } from './stripe.service';
|
|
4
|
+
import { IncomingMessageWithRawBody } from './types';
|
|
5
|
+
export declare class StripeController {
|
|
6
|
+
private connection;
|
|
7
|
+
private channelService;
|
|
8
|
+
private orderService;
|
|
9
|
+
private stripeService;
|
|
10
|
+
constructor(connection: TransactionalConnection, channelService: ChannelService, orderService: OrderService, stripeService: StripeService);
|
|
11
|
+
webhook(signature: string | undefined, request: IncomingMessageWithRawBody, response: Response): Promise<void>;
|
|
12
|
+
private createContext;
|
|
13
|
+
private getPaymentMethod;
|
|
14
|
+
}
|
|
@@ -0,0 +1,120 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StripeController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const generated_graphql_shop_errors_1 = require("@vendure/core/dist/common/error/generated-graphql-shop-errors");
|
|
19
|
+
const constants_1 = require("./constants");
|
|
20
|
+
const stripe_handler_1 = require("./stripe.handler");
|
|
21
|
+
const stripe_service_1 = require("./stripe.service");
|
|
22
|
+
const missingHeaderErrorMessage = 'Missing stripe-signature header';
|
|
23
|
+
const signatureErrorMessage = 'Error verifying Stripe webhook signature';
|
|
24
|
+
const noPaymentIntentErrorMessage = 'No payment intent in the event payload';
|
|
25
|
+
let StripeController = class StripeController {
|
|
26
|
+
constructor(connection, channelService, orderService, stripeService) {
|
|
27
|
+
this.connection = connection;
|
|
28
|
+
this.channelService = channelService;
|
|
29
|
+
this.orderService = orderService;
|
|
30
|
+
this.stripeService = stripeService;
|
|
31
|
+
}
|
|
32
|
+
async webhook(signature, request, response) {
|
|
33
|
+
var _a;
|
|
34
|
+
if (!signature) {
|
|
35
|
+
core_1.Logger.error(missingHeaderErrorMessage, constants_1.loggerCtx);
|
|
36
|
+
response.status(common_1.HttpStatus.BAD_REQUEST).send(missingHeaderErrorMessage);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
let event = null;
|
|
40
|
+
try {
|
|
41
|
+
event = this.stripeService.constructEventFromPayload(request.rawBody, signature);
|
|
42
|
+
}
|
|
43
|
+
catch (e) {
|
|
44
|
+
core_1.Logger.error(`${signatureErrorMessage} ${signature}: ${e.message}`, constants_1.loggerCtx);
|
|
45
|
+
response.status(common_1.HttpStatus.BAD_REQUEST).send(signatureErrorMessage);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
const paymentIntent = event.data.object;
|
|
49
|
+
if (!paymentIntent) {
|
|
50
|
+
core_1.Logger.error(noPaymentIntentErrorMessage, constants_1.loggerCtx);
|
|
51
|
+
response.status(common_1.HttpStatus.BAD_REQUEST).send(noPaymentIntentErrorMessage);
|
|
52
|
+
return;
|
|
53
|
+
}
|
|
54
|
+
const { metadata: { channelToken, orderCode, orderId } = {} } = paymentIntent;
|
|
55
|
+
if (event.type === 'payment_intent.payment_failed') {
|
|
56
|
+
const message = (_a = paymentIntent.last_payment_error) === null || _a === void 0 ? void 0 : _a.message;
|
|
57
|
+
core_1.Logger.warn(`Payment for order ${orderCode} failed: ${message}`, constants_1.loggerCtx);
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
if (event.type !== 'payment_intent.succeeded') {
|
|
61
|
+
// This should never happen as the webhook is configured to receive
|
|
62
|
+
// payment_intent.succeeded and payment_intent.payment_failed events only
|
|
63
|
+
core_1.Logger.info(`Received ${event.type} status update for order ${orderCode}`, constants_1.loggerCtx);
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
const ctx = await this.createContext(channelToken);
|
|
67
|
+
const transitionToStateResult = await this.orderService.transitionToState(ctx, orderId, 'ArrangingPayment');
|
|
68
|
+
if (transitionToStateResult instanceof generated_graphql_shop_errors_1.OrderStateTransitionError) {
|
|
69
|
+
core_1.Logger.error(`Error transitioning order ${orderCode} to ArrangingPayment state: ${transitionToStateResult.message}`, constants_1.loggerCtx);
|
|
70
|
+
return;
|
|
71
|
+
}
|
|
72
|
+
const paymentMethod = await this.getPaymentMethod(ctx);
|
|
73
|
+
const addPaymentToOrderResult = await this.orderService.addPaymentToOrder(ctx, orderId, {
|
|
74
|
+
method: paymentMethod.code,
|
|
75
|
+
metadata: {
|
|
76
|
+
paymentIntentId: paymentIntent.id,
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
if (!(addPaymentToOrderResult instanceof core_1.Order)) {
|
|
80
|
+
core_1.Logger.error(`Error adding payment to order ${orderCode}: ${addPaymentToOrderResult.message}`, constants_1.loggerCtx);
|
|
81
|
+
return;
|
|
82
|
+
}
|
|
83
|
+
core_1.Logger.info(`Stripe payment intent id ${paymentIntent.id} added to order ${orderCode}`, constants_1.loggerCtx);
|
|
84
|
+
}
|
|
85
|
+
async createContext(channelToken) {
|
|
86
|
+
const channel = await this.channelService.getChannelFromToken(channelToken);
|
|
87
|
+
return new core_1.RequestContext({
|
|
88
|
+
apiType: 'admin',
|
|
89
|
+
isAuthorized: true,
|
|
90
|
+
authorizedAsOwnerOnly: false,
|
|
91
|
+
channel,
|
|
92
|
+
languageCode: core_1.LanguageCode.en,
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
async getPaymentMethod(ctx) {
|
|
96
|
+
const method = (await this.connection.getRepository(ctx, core_1.PaymentMethod).find()).find(m => m.handler.code === stripe_handler_1.stripePaymentMethodHandler.code);
|
|
97
|
+
if (!method) {
|
|
98
|
+
throw new core_1.InternalServerError(`[${constants_1.loggerCtx}] Could not find Stripe PaymentMethod`);
|
|
99
|
+
}
|
|
100
|
+
return method;
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, common_1.Post)('stripe'),
|
|
105
|
+
__param(0, (0, common_1.Headers)('stripe-signature')),
|
|
106
|
+
__param(1, (0, common_1.Req)()),
|
|
107
|
+
__param(2, (0, common_1.Res)()),
|
|
108
|
+
__metadata("design:type", Function),
|
|
109
|
+
__metadata("design:paramtypes", [Object, Object, Object]),
|
|
110
|
+
__metadata("design:returntype", Promise)
|
|
111
|
+
], StripeController.prototype, "webhook", null);
|
|
112
|
+
StripeController = __decorate([
|
|
113
|
+
(0, common_1.Controller)('payments'),
|
|
114
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection,
|
|
115
|
+
core_1.ChannelService,
|
|
116
|
+
core_1.OrderService,
|
|
117
|
+
stripe_service_1.StripeService])
|
|
118
|
+
], StripeController);
|
|
119
|
+
exports.StripeController = StripeController;
|
|
120
|
+
//# sourceMappingURL=stripe.controller.js.map
|
|
@@ -0,0 +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;AAG7E,IAAa,gBAAgB,GAA7B,MAAa,gBAAgB;IACzB,YACY,UAAmC,EACnC,cAA8B,EAC9B,YAA0B,EAC1B,aAA4B;QAH5B,eAAU,GAAV,UAAU,CAAyB;QACnC,mBAAc,GAAd,cAAc,CAAgB;QAC9B,iBAAY,GAAZ,YAAY,CAAc;QAC1B,kBAAa,GAAb,aAAa,CAAe;IACrC,CAAC;IAGJ,KAAK,CAAC,OAAO,CACoB,SAA6B,EACnD,OAAmC,EACnC,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;QAED,IAAI,KAAK,GAAG,IAAI,CAAC;Q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MAAM,IAAI,CAAC,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,oBAAa,CAAC,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,CAChF,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;AArGG;IADC,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;;;;+CAyET;AArFQ,gBAAgB;IAD5B,IAAA,mBAAU,EAAC,UAAU,CAAC;qCAGK,8BAAuB;QACnB,qBAAc;QAChB,mBAAY;QACX,8BAAa;GAL/B,gBAAgB,CA8G5B;AA9GY,4CAAgB"}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.stripePaymentMethodHandler = void 0;
|
|
7
|
+
const core_1 = require("@vendure/core");
|
|
8
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
9
|
+
const stripe_service_1 = require("./stripe.service");
|
|
10
|
+
const { StripeError } = stripe_1.default.errors;
|
|
11
|
+
let stripeService;
|
|
12
|
+
/**
|
|
13
|
+
* The handler for Stripe payments.
|
|
14
|
+
*/
|
|
15
|
+
exports.stripePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
16
|
+
code: 'stripe',
|
|
17
|
+
description: [{ languageCode: core_1.LanguageCode.en, value: 'Stripe payments' }],
|
|
18
|
+
args: {},
|
|
19
|
+
init(injector) {
|
|
20
|
+
stripeService = injector.get(stripe_service_1.StripeService);
|
|
21
|
+
},
|
|
22
|
+
async createPayment(_, __, amount, ___, metadata) {
|
|
23
|
+
// Payment is already settled in Stripe by the time the webhook in stripe.controller.ts
|
|
24
|
+
// adds the payment to the order
|
|
25
|
+
return {
|
|
26
|
+
amount,
|
|
27
|
+
state: 'Settled',
|
|
28
|
+
transactionId: metadata.paymentIntentId,
|
|
29
|
+
};
|
|
30
|
+
},
|
|
31
|
+
settlePayment() {
|
|
32
|
+
return {
|
|
33
|
+
success: true,
|
|
34
|
+
};
|
|
35
|
+
},
|
|
36
|
+
async createRefund(ctx, input, amount, order, payment, args) {
|
|
37
|
+
const result = await stripeService.createRefund(payment.transactionId, amount);
|
|
38
|
+
if (result instanceof StripeError) {
|
|
39
|
+
return {
|
|
40
|
+
state: 'Failed',
|
|
41
|
+
transactionId: payment.transactionId,
|
|
42
|
+
metadata: {
|
|
43
|
+
type: result.type,
|
|
44
|
+
message: result.message,
|
|
45
|
+
},
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
if (result.status === 'succeeded') {
|
|
49
|
+
return {
|
|
50
|
+
state: 'Settled',
|
|
51
|
+
transactionId: payment.transactionId,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
if (result.status === 'pending') {
|
|
55
|
+
return {
|
|
56
|
+
state: 'Pending',
|
|
57
|
+
transactionId: payment.transactionId,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
return {
|
|
61
|
+
state: 'Failed',
|
|
62
|
+
transactionId: payment.transactionId,
|
|
63
|
+
metadata: {
|
|
64
|
+
message: result.failure_reason,
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
},
|
|
68
|
+
});
|
|
69
|
+
//# sourceMappingURL=stripe.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.handler.js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,CAAC,MAAM,KAAK,WAAW,EAAE;YAC/B,OAAO;gBACH,KAAK,EAAE,SAAkB;gBACzB,aAAa,EAAE,OAAO,CAAC,aAAa;aACvC,CAAC;SACL;QAED,IAAI,MAAM,CAAC,MAAM,KAAK,SAAS,EAAE;YAC7B,OAAO;gBACH,KAAK,EAAE,SAAkB;gBACzB,aAAa,EAAE,OAAO,CAAC,aAAa;aACvC,CAAC;SACL;QAED,OAAO;YACH,KAAK,EAAE,QAAiB;YACxB,aAAa,EAAE,OAAO,CAAC,aAAa;YACpC,QAAQ,EAAE;gBACN,OAAO,EAAE,MAAM,CAAC,cAAc;aACjC;SACJ,CAAC;IACN,CAAC;CACJ,CAAC,CAAC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { Type } from '@vendure/core';
|
|
2
|
+
import { StripePluginOptions } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* @description
|
|
5
|
+
* Plugin to enable payments through [Stripe](https://stripe.com/docs) via the Payment Intents API.
|
|
6
|
+
*
|
|
7
|
+
* ## Requirements
|
|
8
|
+
*
|
|
9
|
+
* 1. You will need to create a Stripe account and get your secret key in the dashboard.
|
|
10
|
+
* 2. Create a webhook endpoint in the Stripe dashboard which listens to the `payment_intent.succeeded` and
|
|
11
|
+
* `payment_intent.payment_failed` events. The URL should be `https://my-shop.com/payments/stripe`, where
|
|
12
|
+
* `my-shop.com` is the host of your storefront application.
|
|
13
|
+
* 3. Get the signing secret for the newly created webhook.
|
|
14
|
+
* 4. Install the Payments plugin and the Stripe Node library:
|
|
15
|
+
*
|
|
16
|
+
* `yarn add \@vendure/payments-plugin stripe`
|
|
17
|
+
*
|
|
18
|
+
* or
|
|
19
|
+
*
|
|
20
|
+
* `npm install \@vendure/payments-plugin stripe`
|
|
21
|
+
*
|
|
22
|
+
* ## Setup
|
|
23
|
+
*
|
|
24
|
+
* 1. Add the plugin to your VendureConfig `plugins` array:
|
|
25
|
+
* ```TypeScript
|
|
26
|
+
* import { StripePlugin } from '\@vendure/payments-plugin/package/stripe';
|
|
27
|
+
*
|
|
28
|
+
* // ...
|
|
29
|
+
*
|
|
30
|
+
* plugins: [
|
|
31
|
+
* StripePlugin.init({
|
|
32
|
+
* apiKey: process.env.YOUR_STRIPE_SECRET_KEY,
|
|
33
|
+
* webhookSigningSecret: process.env.YOUR_STRIPE_WEBHOOK_SIGNING_SECRET,
|
|
34
|
+
* // This prevents different customers from using the same PaymentIntent
|
|
35
|
+
* storeCustomersInStripe: true,
|
|
36
|
+
* }),
|
|
37
|
+
* ]
|
|
38
|
+
* ````
|
|
39
|
+
* 2. Create a new PaymentMethod in the Admin UI, and select "Stripe payments" as the handler.
|
|
40
|
+
*
|
|
41
|
+
* ## Storefront usage
|
|
42
|
+
*
|
|
43
|
+
* The plugin is designed to work with the [Custom payment flow](https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements).
|
|
44
|
+
* In this flow, Stripe provides libraries which handle the payment UI and confirmation for you. You can install it in your storefront project
|
|
45
|
+
* with:
|
|
46
|
+
*
|
|
47
|
+
* ```shell
|
|
48
|
+
* yarn add \@stripe/stripe-js
|
|
49
|
+
* # or
|
|
50
|
+
* npm install \@stripe/stripe-js
|
|
51
|
+
* ```
|
|
52
|
+
*
|
|
53
|
+
* If you are using React, you should also consider installing `@stripe/react-stripe-js`, which is a wrapper around Stripe Elements.
|
|
54
|
+
*
|
|
55
|
+
* The high-level workflow is:
|
|
56
|
+
* 1. Create a "payment intent" on the server by executing the `createStripePaymentIntent` mutation which is exposed by this plugin.
|
|
57
|
+
* 2. Use the returned client secret to instantiate the Stripe Payment Element.
|
|
58
|
+
* 3. Once the form is submitted and Stripe processes the payment, the webhook takes care of updating the order without additional action
|
|
59
|
+
* in the storefront.
|
|
60
|
+
*
|
|
61
|
+
* ## Local development
|
|
62
|
+
*
|
|
63
|
+
* Use something like [localtunnel](https://github.com/localtunnel/localtunnel) to test on localhost.
|
|
64
|
+
*
|
|
65
|
+
* ```bash
|
|
66
|
+
* npx localtunnel --port 3000 --subdomain my-shop-local-dev
|
|
67
|
+
* > your url is: https://my-shop-local-dev.loca.lt
|
|
68
|
+
* ```
|
|
69
|
+
*
|
|
70
|
+
* @docsCategory payments-plugin
|
|
71
|
+
* @docsPage StripePlugin
|
|
72
|
+
*/
|
|
73
|
+
export declare class StripePlugin {
|
|
74
|
+
static options: StripePluginOptions;
|
|
75
|
+
/**
|
|
76
|
+
* @description
|
|
77
|
+
* Initialize the Stripe payment plugin
|
|
78
|
+
*/
|
|
79
|
+
static init(options: StripePluginOptions): Type<StripePlugin>;
|
|
80
|
+
}
|
|
@@ -0,0 +1,140 @@
|
|
|
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 StripePlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.StripePlugin = void 0;
|
|
11
|
+
const core_1 = require("@vendure/core");
|
|
12
|
+
const graphql_tag_1 = require("graphql-tag");
|
|
13
|
+
const constants_1 = require("./constants");
|
|
14
|
+
const raw_body_middleware_1 = require("./raw-body.middleware");
|
|
15
|
+
const stripe_controller_1 = require("./stripe.controller");
|
|
16
|
+
const stripe_handler_1 = require("./stripe.handler");
|
|
17
|
+
const stripe_resolver_1 = require("./stripe.resolver");
|
|
18
|
+
const stripe_service_1 = require("./stripe.service");
|
|
19
|
+
/**
|
|
20
|
+
* @description
|
|
21
|
+
* Plugin to enable payments through [Stripe](https://stripe.com/docs) via the Payment Intents API.
|
|
22
|
+
*
|
|
23
|
+
* ## Requirements
|
|
24
|
+
*
|
|
25
|
+
* 1. You will need to create a Stripe account and get your secret key in the dashboard.
|
|
26
|
+
* 2. Create a webhook endpoint in the Stripe dashboard which listens to the `payment_intent.succeeded` and
|
|
27
|
+
* `payment_intent.payment_failed` events. The URL should be `https://my-shop.com/payments/stripe`, where
|
|
28
|
+
* `my-shop.com` is the host of your storefront application.
|
|
29
|
+
* 3. Get the signing secret for the newly created webhook.
|
|
30
|
+
* 4. Install the Payments plugin and the Stripe Node library:
|
|
31
|
+
*
|
|
32
|
+
* `yarn add \@vendure/payments-plugin stripe`
|
|
33
|
+
*
|
|
34
|
+
* or
|
|
35
|
+
*
|
|
36
|
+
* `npm install \@vendure/payments-plugin stripe`
|
|
37
|
+
*
|
|
38
|
+
* ## Setup
|
|
39
|
+
*
|
|
40
|
+
* 1. Add the plugin to your VendureConfig `plugins` array:
|
|
41
|
+
* ```TypeScript
|
|
42
|
+
* import { StripePlugin } from '\@vendure/payments-plugin/package/stripe';
|
|
43
|
+
*
|
|
44
|
+
* // ...
|
|
45
|
+
*
|
|
46
|
+
* plugins: [
|
|
47
|
+
* StripePlugin.init({
|
|
48
|
+
* apiKey: process.env.YOUR_STRIPE_SECRET_KEY,
|
|
49
|
+
* webhookSigningSecret: process.env.YOUR_STRIPE_WEBHOOK_SIGNING_SECRET,
|
|
50
|
+
* // This prevents different customers from using the same PaymentIntent
|
|
51
|
+
* storeCustomersInStripe: true,
|
|
52
|
+
* }),
|
|
53
|
+
* ]
|
|
54
|
+
* ````
|
|
55
|
+
* 2. Create a new PaymentMethod in the Admin UI, and select "Stripe payments" as the handler.
|
|
56
|
+
*
|
|
57
|
+
* ## Storefront usage
|
|
58
|
+
*
|
|
59
|
+
* The plugin is designed to work with the [Custom payment flow](https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements).
|
|
60
|
+
* In this flow, Stripe provides libraries which handle the payment UI and confirmation for you. You can install it in your storefront project
|
|
61
|
+
* with:
|
|
62
|
+
*
|
|
63
|
+
* ```shell
|
|
64
|
+
* yarn add \@stripe/stripe-js
|
|
65
|
+
* # or
|
|
66
|
+
* npm install \@stripe/stripe-js
|
|
67
|
+
* ```
|
|
68
|
+
*
|
|
69
|
+
* If you are using React, you should also consider installing `@stripe/react-stripe-js`, which is a wrapper around Stripe Elements.
|
|
70
|
+
*
|
|
71
|
+
* The high-level workflow is:
|
|
72
|
+
* 1. Create a "payment intent" on the server by executing the `createStripePaymentIntent` mutation which is exposed by this plugin.
|
|
73
|
+
* 2. Use the returned client secret to instantiate the Stripe Payment Element.
|
|
74
|
+
* 3. Once the form is submitted and Stripe processes the payment, the webhook takes care of updating the order without additional action
|
|
75
|
+
* in the storefront.
|
|
76
|
+
*
|
|
77
|
+
* ## Local development
|
|
78
|
+
*
|
|
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
|
|
84
|
+
* ```
|
|
85
|
+
*
|
|
86
|
+
* @docsCategory payments-plugin
|
|
87
|
+
* @docsPage StripePlugin
|
|
88
|
+
*/
|
|
89
|
+
let StripePlugin = StripePlugin_1 = class StripePlugin {
|
|
90
|
+
/**
|
|
91
|
+
* @description
|
|
92
|
+
* Initialize the Stripe payment plugin
|
|
93
|
+
*/
|
|
94
|
+
static init(options) {
|
|
95
|
+
this.options = options;
|
|
96
|
+
return StripePlugin_1;
|
|
97
|
+
}
|
|
98
|
+
};
|
|
99
|
+
StripePlugin = StripePlugin_1 = __decorate([
|
|
100
|
+
(0, core_1.VendurePlugin)({
|
|
101
|
+
imports: [core_1.PluginCommonModule],
|
|
102
|
+
controllers: [stripe_controller_1.StripeController],
|
|
103
|
+
providers: [
|
|
104
|
+
{
|
|
105
|
+
provide: constants_1.STRIPE_PLUGIN_OPTIONS,
|
|
106
|
+
useFactory: () => StripePlugin_1.options,
|
|
107
|
+
},
|
|
108
|
+
stripe_service_1.StripeService,
|
|
109
|
+
],
|
|
110
|
+
configuration: config => {
|
|
111
|
+
config.paymentOptions.paymentMethodHandlers.push(stripe_handler_1.stripePaymentMethodHandler);
|
|
112
|
+
config.apiOptions.middleware.push({
|
|
113
|
+
route: '/payments/stripe',
|
|
114
|
+
handler: raw_body_middleware_1.rawBodyMiddleware,
|
|
115
|
+
beforeListen: true,
|
|
116
|
+
});
|
|
117
|
+
if (StripePlugin_1.options.storeCustomersInStripe) {
|
|
118
|
+
config.customFields.Customer.push({
|
|
119
|
+
name: 'stripeCustomerId',
|
|
120
|
+
type: 'string',
|
|
121
|
+
label: [{ languageCode: core_1.LanguageCode.en, value: 'Stripe Customer ID' }],
|
|
122
|
+
nullable: true,
|
|
123
|
+
public: false,
|
|
124
|
+
readonly: true,
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
return config;
|
|
128
|
+
},
|
|
129
|
+
shopApiExtensions: {
|
|
130
|
+
schema: (0, graphql_tag_1.gql) `
|
|
131
|
+
extend type Mutation {
|
|
132
|
+
createStripePaymentIntent: String
|
|
133
|
+
}
|
|
134
|
+
`,
|
|
135
|
+
resolvers: [stripe_resolver_1.StripeResolver],
|
|
136
|
+
},
|
|
137
|
+
})
|
|
138
|
+
], StripePlugin);
|
|
139
|
+
exports.StripePlugin = StripePlugin;
|
|
140
|
+
//# sourceMappingURL=stripe.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.plugin.js","sourceRoot":"","sources":["../../src/stripe/stripe.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsF;AACtF,6CAAkC;AAElC,2CAAoD;AACpD,+DAA0D;AAC1D,2DAAuD;AACvD,qDAA8D;AAC9D,uDAAmD;AACnD,qDAAiD;AAGjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;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AAE,CAAC,gCAAc,CAAC;SAC9B;KACJ,CAAC;GACW,YAAY,CAWxB;AAXY,oCAAY"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { ActiveOrderService, RequestContext } from '@vendure/core';
|
|
2
|
+
import { StripeService } from './stripe.service';
|
|
3
|
+
export declare class StripeResolver {
|
|
4
|
+
private stripeService;
|
|
5
|
+
private activeOrderService;
|
|
6
|
+
constructor(stripeService: StripeService, activeOrderService: ActiveOrderService);
|
|
7
|
+
createStripePaymentIntent(ctx: RequestContext): Promise<string | undefined>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StripeResolver = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const core_1 = require("@vendure/core");
|
|
18
|
+
const stripe_service_1 = require("./stripe.service");
|
|
19
|
+
let StripeResolver = class StripeResolver {
|
|
20
|
+
constructor(stripeService, activeOrderService) {
|
|
21
|
+
this.stripeService = stripeService;
|
|
22
|
+
this.activeOrderService = activeOrderService;
|
|
23
|
+
}
|
|
24
|
+
async createStripePaymentIntent(ctx) {
|
|
25
|
+
if (ctx.authorizedAsOwnerOnly) {
|
|
26
|
+
const sessionOrder = await this.activeOrderService.getOrderFromContext(ctx);
|
|
27
|
+
if (sessionOrder) {
|
|
28
|
+
return this.stripeService.createPaymentIntent(ctx, sessionOrder);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
__decorate([
|
|
34
|
+
(0, graphql_1.Mutation)(),
|
|
35
|
+
(0, core_1.Allow)(core_1.Permission.Owner),
|
|
36
|
+
__param(0, (0, core_1.Ctx)()),
|
|
37
|
+
__metadata("design:type", Function),
|
|
38
|
+
__metadata("design:paramtypes", [core_1.RequestContext]),
|
|
39
|
+
__metadata("design:returntype", Promise)
|
|
40
|
+
], StripeResolver.prototype, "createStripePaymentIntent", null);
|
|
41
|
+
StripeResolver = __decorate([
|
|
42
|
+
(0, graphql_1.Resolver)(),
|
|
43
|
+
__metadata("design:paramtypes", [stripe_service_1.StripeService, core_1.ActiveOrderService])
|
|
44
|
+
], StripeResolver);
|
|
45
|
+
exports.StripeResolver = StripeResolver;
|
|
46
|
+
//# sourceMappingURL=stripe.resolver.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.resolver.js","sourceRoot":"","sources":["../../src/stripe/stripe.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAAqD;AACrD,wCAA2F;AAE3F,qDAAiD;AAGjD,IAAa,cAAc,GAA3B,MAAa,cAAc;IACvB,YAAoB,aAA4B,EAAU,kBAAsC;QAA5E,kBAAa,GAAb,aAAa,CAAe;QAAU,uBAAkB,GAAlB,kBAAkB,CAAoB;IAAG,CAAC;IAIpG,KAAK,CAAC,yBAAyB,CAAQ,GAAmB;QACtD,IAAI,GAAG,CAAC,qBAAqB,EAAE;YAC3B,MAAM,YAAY,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,mBAAmB,CAAC,GAAG,CAAC,CAAC;YAC5E,IAAI,YAAY,EAAE;gBACd,OAAO,IAAI,CAAC,aAAa,CAAC,mBAAmB,CAAC,GAAG,EAAE,YAAY,CAAC,CAAC;aACpE;SACJ;IACL,CAAC;CACJ,CAAA;AARG;IAFC,IAAA,kBAAQ,GAAE;IACV,IAAA,YAAK,EAAC,iBAAU,CAAC,KAAK,CAAC;IACS,WAAA,IAAA,UAAG,GAAE,CAAA;;qCAAM,qBAAc;;+DAOzD;AAZQ,cAAc;IAD1B,IAAA,kBAAQ,GAAE;qCAE4B,8BAAa,EAA8B,yBAAkB;GADvF,cAAc,CAa1B;AAbY,wCAAc"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Order, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
3
|
+
import Stripe from 'stripe';
|
|
4
|
+
import { StripePluginOptions } from './types';
|
|
5
|
+
export declare class StripeService {
|
|
6
|
+
private connection;
|
|
7
|
+
private options;
|
|
8
|
+
private stripe;
|
|
9
|
+
constructor(connection: TransactionalConnection, options: StripePluginOptions);
|
|
10
|
+
createPaymentIntent(ctx: RequestContext, order: Order): Promise<string | undefined>;
|
|
11
|
+
createRefund(paymentIntentId: string, amount: number): Promise<Stripe.Refund | Stripe.StripeError>;
|
|
12
|
+
constructEventFromPayload(payload: Buffer, signature: string): Stripe.Event;
|
|
13
|
+
/**
|
|
14
|
+
* Returns the stripeCustomerId if the Customer has one. If that's not the case, queries Stripe to check
|
|
15
|
+
* if the customer is already registered, in which case it saves the id as stripeCustomerId and returns it.
|
|
16
|
+
* Otherwise, creates a new Customer record in Stripe and returns the generated id.
|
|
17
|
+
*/
|
|
18
|
+
private getStripeCustomerId;
|
|
19
|
+
}
|
|
@@ -0,0 +1,114 @@
|
|
|
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 __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.StripeService = void 0;
|
|
19
|
+
const common_1 = require("@nestjs/common");
|
|
20
|
+
const core_1 = require("@vendure/core");
|
|
21
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
22
|
+
const constants_1 = require("./constants");
|
|
23
|
+
let StripeService = class StripeService {
|
|
24
|
+
constructor(connection, options) {
|
|
25
|
+
this.connection = connection;
|
|
26
|
+
this.options = options;
|
|
27
|
+
this.stripe = new stripe_1.default(this.options.apiKey, {
|
|
28
|
+
apiVersion: '2020-08-27',
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
async createPaymentIntent(ctx, order) {
|
|
32
|
+
let customerId;
|
|
33
|
+
if (this.options.storeCustomersInStripe && ctx.activeUserId) {
|
|
34
|
+
customerId = await this.getStripeCustomerId(ctx, order);
|
|
35
|
+
}
|
|
36
|
+
const { client_secret } = await this.stripe.paymentIntents.create({
|
|
37
|
+
amount: order.totalWithTax,
|
|
38
|
+
currency: order.currencyCode.toLowerCase(),
|
|
39
|
+
customer: customerId,
|
|
40
|
+
automatic_payment_methods: {
|
|
41
|
+
enabled: true,
|
|
42
|
+
},
|
|
43
|
+
metadata: {
|
|
44
|
+
channelToken: ctx.channel.token,
|
|
45
|
+
orderId: order.id,
|
|
46
|
+
orderCode: order.code,
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
if (!client_secret) {
|
|
50
|
+
// This should never happen
|
|
51
|
+
core_1.Logger.warn(`Payment intent creation for order ${order.code} did not return client secret`, constants_1.loggerCtx);
|
|
52
|
+
}
|
|
53
|
+
return client_secret !== null && client_secret !== void 0 ? client_secret : undefined;
|
|
54
|
+
}
|
|
55
|
+
async createRefund(paymentIntentId, amount) {
|
|
56
|
+
// TODO: Consider passing the "reason" property once this feature request is addressed:
|
|
57
|
+
// https://github.com/vendure-ecommerce/vendure/issues/893
|
|
58
|
+
try {
|
|
59
|
+
const refund = await this.stripe.refunds.create({
|
|
60
|
+
payment_intent: paymentIntentId,
|
|
61
|
+
amount,
|
|
62
|
+
});
|
|
63
|
+
return refund;
|
|
64
|
+
}
|
|
65
|
+
catch (e) {
|
|
66
|
+
return e;
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
constructEventFromPayload(payload, signature) {
|
|
70
|
+
return this.stripe.webhooks.constructEvent(payload, signature, this.options.webhookSigningSecret);
|
|
71
|
+
}
|
|
72
|
+
/**
|
|
73
|
+
* Returns the stripeCustomerId if the Customer has one. If that's not the case, queries Stripe to check
|
|
74
|
+
* if the customer is already registered, in which case it saves the id as stripeCustomerId and returns it.
|
|
75
|
+
* Otherwise, creates a new Customer record in Stripe and returns the generated id.
|
|
76
|
+
*/
|
|
77
|
+
async getStripeCustomerId(ctx, activeOrder) {
|
|
78
|
+
// Load relation with customer not available in the response from activeOrderService.getOrderFromContext()
|
|
79
|
+
const order = await this.connection.getRepository(core_1.Order).findOne(activeOrder.id, {
|
|
80
|
+
relations: ['customer'],
|
|
81
|
+
});
|
|
82
|
+
if (!order || !order.customer) {
|
|
83
|
+
// This should never happen
|
|
84
|
+
return undefined;
|
|
85
|
+
}
|
|
86
|
+
const { customer } = order;
|
|
87
|
+
if (customer.customFields.stripeCustomerId) {
|
|
88
|
+
return customer.customFields.stripeCustomerId;
|
|
89
|
+
}
|
|
90
|
+
let stripeCustomerId;
|
|
91
|
+
const stripeCustomers = await this.stripe.customers.list({ email: customer.emailAddress });
|
|
92
|
+
if (stripeCustomers.data.length > 0) {
|
|
93
|
+
stripeCustomerId = stripeCustomers.data[0].id;
|
|
94
|
+
}
|
|
95
|
+
else {
|
|
96
|
+
const newStripeCustomer = await this.stripe.customers.create({
|
|
97
|
+
email: customer.emailAddress,
|
|
98
|
+
name: `${customer.firstName} ${customer.lastName}`,
|
|
99
|
+
});
|
|
100
|
+
stripeCustomerId = newStripeCustomer.id;
|
|
101
|
+
core_1.Logger.info(`Created Stripe Customer record for customerId ${customer.id}`, constants_1.loggerCtx);
|
|
102
|
+
}
|
|
103
|
+
customer.customFields.stripeCustomerId = stripeCustomerId;
|
|
104
|
+
await this.connection.getRepository(ctx, core_1.Customer).save(customer, { reload: false });
|
|
105
|
+
return stripeCustomerId;
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
StripeService = __decorate([
|
|
109
|
+
(0, common_1.Injectable)(),
|
|
110
|
+
__param(1, (0, common_1.Inject)(constants_1.STRIPE_PLUGIN_OPTIONS)),
|
|
111
|
+
__metadata("design:paramtypes", [core_1.TransactionalConnection, Object])
|
|
112
|
+
], StripeService);
|
|
113
|
+
exports.StripeService = StripeService;
|
|
114
|
+
//# sourceMappingURL=stripe.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe.service.js","sourceRoot":"","sources":["../../src/stripe/stripe.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AA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gBAAgB,GAAG,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;SACjD;aAAM;YACH,MAAM,iBAAiB,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC;gBACzD,KAAK,EAAE,QAAQ,CAAC,YAAY;gBAC5B,IAAI,EAAE,GAAG,QAAQ,CAAC,SAAS,IAAI,QAAQ,CAAC,QAAQ,EAAE;aACrD,CAAC,CAAC;YAEH,gBAAgB,GAAG,iBAAiB,CAAC,EAAE,CAAC;YAExC,aAAM,CAAC,IAAI,CAAC,iDAAiD,QAAQ,CAAC,EAAE,EAAE,EAAE,qBAAS,CAAC,CAAC;SAC1F;QAED,QAAQ,CAAC,YAAY,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;AA1GY,aAAa;IADzB,IAAA,mBAAU,GAAE;IAMJ,WAAA,IAAA,eAAM,EAAC,iCAAqB,CAAC,CAAA;qCADV,8BAAuB;GAJtC,aAAa,CA0GzB;AA1GY,sCAAa"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import '@vendure/core/dist/entity/custom-entity-fields';
|
|
3
|
+
import { IncomingMessage } from 'http';
|
|
4
|
+
declare module '@vendure/core/dist/entity/custom-entity-fields' {
|
|
5
|
+
interface CustomCustomerFields {
|
|
6
|
+
stripeCustomerId?: string;
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* @description
|
|
11
|
+
* Configuration options for the Stripe payments plugin.
|
|
12
|
+
*
|
|
13
|
+
* @docsCategory payments-plugin
|
|
14
|
+
* @docsPage StripePlugin
|
|
15
|
+
*/
|
|
16
|
+
export interface StripePluginOptions {
|
|
17
|
+
/**
|
|
18
|
+
* @description
|
|
19
|
+
* Secret key of your Stripe account.
|
|
20
|
+
*/
|
|
21
|
+
apiKey: string;
|
|
22
|
+
/**
|
|
23
|
+
* @description
|
|
24
|
+
* Signing secret of your configured Stripe webhook.
|
|
25
|
+
*/
|
|
26
|
+
webhookSigningSecret: string;
|
|
27
|
+
/**
|
|
28
|
+
* @description
|
|
29
|
+
* If set to `true`, a [Customer](https://stripe.com/docs/api/customers) object will be created in Stripe - if
|
|
30
|
+
* it doesn't already exist - for authenticated users, which prevents payment methods attached to other Customers
|
|
31
|
+
* to be used with the same PaymentIntent. This is done by adding a custom field to the Customer entity to store
|
|
32
|
+
* the Stripe customer ID, so switching this on will require a database migration / synchronization.
|
|
33
|
+
*
|
|
34
|
+
* @default false
|
|
35
|
+
*/
|
|
36
|
+
storeCustomersInStripe?: boolean;
|
|
37
|
+
}
|
|
38
|
+
export interface IncomingMessageWithRawBody extends IncomingMessage {
|
|
39
|
+
rawBody: Buffer;
|
|
40
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
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": "
|
|
3
|
+
"version": "2.0.0-next.0",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "package/index.js",
|
|
6
6
|
"types": "package/index.d.ts",
|
|
@@ -22,18 +22,20 @@
|
|
|
22
22
|
},
|
|
23
23
|
"peerDependencies": {
|
|
24
24
|
"@mollie/api-client": "3.x",
|
|
25
|
-
"braintree": "3.x"
|
|
25
|
+
"braintree": "3.x",
|
|
26
|
+
"stripe": "8.x"
|
|
26
27
|
},
|
|
27
28
|
"devDependencies": {
|
|
28
|
-
"@mollie/api-client": "
|
|
29
|
+
"@mollie/api-client": "~3.5.1",
|
|
29
30
|
"@types/braintree": "^2.22.15",
|
|
30
|
-
"@vendure/common": "^
|
|
31
|
-
"@vendure/core": "^
|
|
32
|
-
"@vendure/testing": "^
|
|
31
|
+
"@vendure/common": "^2.0.0-next.0",
|
|
32
|
+
"@vendure/core": "^2.0.0-next.0",
|
|
33
|
+
"@vendure/testing": "^2.0.0-next.0",
|
|
33
34
|
"braintree": "^3.0.0",
|
|
34
35
|
"nock": "^13.1.4",
|
|
35
36
|
"rimraf": "^3.0.2",
|
|
36
|
-
"
|
|
37
|
+
"stripe": "^8.197.0",
|
|
38
|
+
"typescript": "4.5.5"
|
|
37
39
|
},
|
|
38
|
-
"gitHead": "
|
|
40
|
+
"gitHead": "1db9e96a8c92b23b4d06c6b83e4ab2b428afab7c"
|
|
39
41
|
}
|