@vendure/payments-plugin 1.3.4 → 1.4.2

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 (43) hide show
  1. package/package/braintree/braintree-common.d.ts +2 -2
  2. package/package/braintree/braintree-common.js +2 -2
  3. package/package/braintree/braintree-common.js.map +1 -1
  4. package/package/braintree/braintree.handler.d.ts +28 -0
  5. package/package/braintree/braintree.handler.js +129 -0
  6. package/package/braintree/braintree.handler.js.map +1 -0
  7. package/package/braintree/braintree.plugin.d.ts +190 -0
  8. package/package/braintree/braintree.plugin.js +241 -0
  9. package/package/braintree/braintree.plugin.js.map +1 -0
  10. package/package/braintree/braintree.resolver.d.ts +4 -2
  11. package/package/braintree/braintree.resolver.js +14 -10
  12. package/package/braintree/braintree.resolver.js.map +1 -1
  13. package/package/braintree/constants.d.ts +1 -0
  14. package/package/braintree/constants.js +2 -1
  15. package/package/braintree/constants.js.map +1 -1
  16. package/package/braintree/index.d.ts +3 -2
  17. package/package/braintree/index.js +3 -2
  18. package/package/braintree/index.js.map +1 -1
  19. package/package/braintree/types.d.ts +33 -1
  20. package/package/index.d.ts +1 -1
  21. package/package/index.js +1 -1
  22. package/package/mollie/constants.d.ts +2 -0
  23. package/package/mollie/constants.js +6 -0
  24. package/package/mollie/constants.js.map +1 -0
  25. package/package/mollie/index.d.ts +2 -0
  26. package/package/mollie/index.js +15 -0
  27. package/package/mollie/index.js.map +1 -0
  28. package/package/mollie/mollie.controller.d.ts +10 -0
  29. package/package/mollie/mollie.controller.js +101 -0
  30. package/package/mollie/mollie.controller.js.map +1 -0
  31. package/package/mollie/mollie.handler.d.ts +18 -0
  32. package/package/mollie/mollie.handler.js +127 -0
  33. package/package/mollie/mollie.handler.js.map +1 -0
  34. package/package/mollie/mollie.plugin.d.ts +101 -0
  35. package/package/mollie/mollie.plugin.js +116 -0
  36. package/package/mollie/mollie.plugin.js.map +1 -0
  37. package/package.json +37 -29
  38. package/package/braintree/braintree-payment-method.d.ts +0 -15
  39. package/package/braintree/braintree-payment-method.js +0 -79
  40. package/package/braintree/braintree-payment-method.js.map +0 -1
  41. package/package/braintree/braintree-plugin.d.ts +0 -5
  42. package/package/braintree/braintree-plugin.js +0 -38
  43. package/package/braintree/braintree-plugin.js.map +0 -1
@@ -0,0 +1,116 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var MolliePlugin_1;
9
+ Object.defineProperty(exports, "__esModule", { value: true });
10
+ exports.MolliePlugin = void 0;
11
+ const core_1 = require("@vendure/core");
12
+ const constants_1 = require("./constants");
13
+ const mollie_controller_1 = require("./mollie.controller");
14
+ const mollie_handler_1 = require("./mollie.handler");
15
+ /**
16
+ * @description
17
+ * 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.
19
+ *
20
+ * ## Requirements
21
+ *
22
+ * 1. You will need to create a Mollie account and get your apiKey in the dashboard.
23
+ * 2. Install the Payments plugin and the Mollie client:
24
+ *
25
+ * `yarn add \@vendure/payments-plugin \@mollie/api-client`
26
+ *
27
+ * or
28
+ *
29
+ * `npm install \@vendure/payments-plugin \@mollie/api-client`
30
+ *
31
+ * ## Setup
32
+ *
33
+ * 1. Add the plugin to your VendureConfig `plugins` array:
34
+ * ```TypeScript
35
+ * import { MolliePlugin } from '\@vendure/payments-plugin/package/mollie';
36
+ *
37
+ * // ...
38
+ *
39
+ * plugins: [
40
+ * MolliePlugin.init({ vendureHost: 'https://yourhost.io/' }),
41
+ * ]
42
+ * ```
43
+ * 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.
46
+ *
47
+ * ## Storefront usage
48
+ *
49
+ * In your storefront you add a payment to an order using the `addPaymentToOrder` mutation. In this example, our Mollie
50
+ * PaymentMethod was given the code "mollie-payment-method".
51
+ *
52
+ * ```GraphQL
53
+ * mutation AddPaymentToOrder {
54
+ * addPaymentToOrder(input: {
55
+ * method: "mollie-payment-method"
56
+ * metadata: {}
57
+ * }) {
58
+ * ...on Order {
59
+ * id
60
+ * state
61
+ * payments {
62
+ * id
63
+ * metadata
64
+ * }
65
+ * }
66
+ * ...on ErrorResult {
67
+ * errorCode
68
+ * message
69
+ * }
70
+ * }
71
+ * }
72
+ * ```
73
+ * The response will have
74
+ * a `order.payments.metadata.public.redirectLink` in it, which can be used to redirect your customer to the Mollie
75
+ * platform.
76
+ *
77
+ * After completing payment on the Mollie platform,
78
+ * the user is redirected to the configured redirect url + orderCode: `https://storefront/order/CH234X5`
79
+ *
80
+ * ## Local development
81
+ *
82
+ * Use something like [localtunnel](https://github.com/localtunnel/localtunnel) to test on localhost.
83
+ *
84
+ * ```bash
85
+ * npx localtunnel --port 3000 --subdomain my-shop-local-dev
86
+ * > your url is: https://my-shop-local-dev.loca.lt <- use this as the vendureHost for local dev.
87
+ * ```
88
+ *
89
+ * @docsCategory payments-plugin
90
+ * @docsPage MolliePlugin
91
+ * @docsWeight 0
92
+ */
93
+ let MolliePlugin = MolliePlugin_1 = class MolliePlugin {
94
+ /**
95
+ * @description
96
+ * Initialize the mollie payment plugin
97
+ * @param vendureHost is needed to pass to mollie for callback
98
+ */
99
+ static init(options) {
100
+ this.options = options;
101
+ return MolliePlugin_1;
102
+ }
103
+ };
104
+ MolliePlugin = MolliePlugin_1 = __decorate([
105
+ core_1.VendurePlugin({
106
+ imports: [core_1.PluginCommonModule],
107
+ controllers: [mollie_controller_1.MollieController],
108
+ providers: [{ provide: constants_1.PLUGIN_INIT_OPTIONS, useFactory: () => MolliePlugin_1.options }],
109
+ configuration: (config) => {
110
+ config.paymentOptions.paymentMethodHandlers.push(mollie_handler_1.molliePaymentHandler);
111
+ return config;
112
+ },
113
+ })
114
+ ], MolliePlugin);
115
+ exports.MolliePlugin = MolliePlugin;
116
+ //# sourceMappingURL=mollie.plugin.js.map
@@ -0,0 +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,CAAC;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"}
package/package.json CHANGED
@@ -1,31 +1,39 @@
1
1
  {
2
- "name": "@vendure/payments-plugin",
3
- "version": "1.3.4",
4
- "license": "MIT",
5
- "main": "package/index.js",
6
- "types": "package/index.d.ts",
7
- "files": [
8
- "package/**/*"
9
- ],
10
- "private": false,
11
- "scripts": {
12
- "watch": "tsc -p ./tsconfig.build.json --watch",
13
- "build": "rimraf package && tsc -p ./tsconfig.build.json",
14
- "lint": "tslint --fix --project ./",
15
- "ci": "yarn build"
16
- },
17
- "homepage": "https://www.vendure.io/",
18
- "funding": "https://github.com/sponsors/michaelbromley",
19
- "publishConfig": {
20
- "access": "public"
21
- },
22
- "devDependencies": {
23
- "@types/braintree": "^2.22.15",
24
- "@vendure/common": "^1.3.4",
25
- "@vendure/core": "^1.3.4",
26
- "braintree": "^3.0.0",
27
- "rimraf": "^3.0.2",
28
- "typescript": "4.3.5"
29
- },
30
- "gitHead": "c56b85f6d87b5687595ae79c8889bd633101e0d5"
2
+ "name": "@vendure/payments-plugin",
3
+ "version": "1.4.2",
4
+ "license": "MIT",
5
+ "main": "package/index.js",
6
+ "types": "package/index.d.ts",
7
+ "files": [
8
+ "package/**/*"
9
+ ],
10
+ "private": false,
11
+ "scripts": {
12
+ "watch": "tsc -p ./tsconfig.build.json --watch",
13
+ "build": "rimraf package && tsc -p ./tsconfig.build.json",
14
+ "e2e": "jest --config ../../e2e-common/jest-config.js --runInBand --package=payments-plugin",
15
+ "lint": "tslint --fix --project ./",
16
+ "ci": "yarn build"
17
+ },
18
+ "homepage": "https://www.vendure.io/",
19
+ "funding": "https://github.com/sponsors/michaelbromley",
20
+ "publishConfig": {
21
+ "access": "public"
22
+ },
23
+ "peerDependencies": {
24
+ "@mollie/api-client": "3.x",
25
+ "braintree": "3.x"
26
+ },
27
+ "devDependencies": {
28
+ "@mollie/api-client": "^3.5.1",
29
+ "@types/braintree": "^2.22.15",
30
+ "@vendure/common": "^1.4.2",
31
+ "@vendure/core": "^1.4.2",
32
+ "@vendure/testing": "^1.4.2",
33
+ "braintree": "^3.0.0",
34
+ "nock": "^13.1.4",
35
+ "rimraf": "^3.0.2",
36
+ "typescript": "4.3.5"
37
+ },
38
+ "gitHead": "0418d311a406ce475d83b96ff96c100e8b468cc6"
31
39
  }
@@ -1,15 +0,0 @@
1
- import { PaymentMethodHandler } from '@vendure/core';
2
- /**
3
- * The handler for Braintree payments.
4
- */
5
- export declare const braintreePaymentMethodHandler: PaymentMethodHandler<{
6
- merchantId: {
7
- type: "string";
8
- };
9
- publicKey: {
10
- type: "string";
11
- };
12
- privateKey: {
13
- type: "string";
14
- };
15
- }>;
@@ -1,79 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.braintreePaymentMethodHandler = void 0;
4
- const generated_types_1 = require("@vendure/common/lib/generated-types");
5
- const core_1 = require("@vendure/core");
6
- const braintree_common_1 = require("./braintree-common");
7
- const constants_1 = require("./constants");
8
- /**
9
- * The handler for Braintree payments.
10
- */
11
- exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
12
- code: 'braintree',
13
- description: [{ languageCode: generated_types_1.LanguageCode.en, value: 'Braintree' }],
14
- args: {
15
- merchantId: { type: 'string' },
16
- publicKey: { type: 'string' },
17
- privateKey: { type: 'string' },
18
- },
19
- async createPayment(ctx, order, amount, args, metadata) {
20
- const gateway = braintree_common_1.getGateway(args);
21
- try {
22
- const response = await gateway.transaction.sale({
23
- amount: (amount / 100).toString(10),
24
- orderId: order.code,
25
- paymentMethodNonce: metadata.nonce,
26
- options: {
27
- submitForSettlement: true,
28
- },
29
- });
30
- if (!response.success) {
31
- return {
32
- amount,
33
- state: 'Declined',
34
- transactionId: response.transaction.id,
35
- errorMessage: response.message,
36
- metadata: braintree_common_1.extractMetadataFromTransaction(response.transaction),
37
- };
38
- }
39
- return {
40
- amount,
41
- state: 'Settled',
42
- transactionId: response.transaction.id,
43
- metadata: braintree_common_1.extractMetadataFromTransaction(response.transaction),
44
- };
45
- }
46
- catch (e) {
47
- core_1.Logger.error(e, constants_1.loggerCtx);
48
- return {
49
- amount: order.total,
50
- state: 'Error',
51
- transactionId: '',
52
- errorMessage: e.toString(),
53
- metadata: e,
54
- };
55
- }
56
- },
57
- settlePayment() {
58
- return {
59
- success: true,
60
- };
61
- },
62
- async createRefund(ctx, input, total, order, payment, args) {
63
- const gateway = braintree_common_1.getGateway(args);
64
- const response = await gateway.transaction.refund(payment.transactionId, (total / 100).toString(10));
65
- if (!response.success) {
66
- return {
67
- state: 'Failed',
68
- transactionId: response.transaction.id,
69
- metadata: response,
70
- };
71
- }
72
- return {
73
- state: 'Settled',
74
- transactionId: response.transaction.id,
75
- metadata: response,
76
- };
77
- },
78
- });
79
- //# sourceMappingURL=braintree-payment-method.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"braintree-payment-method.js","sourceRoot":"","sources":["../../src/braintree/braintree-payment-method.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,wCAA6D;AAE7D,yDAAgF;AAChF,2CAAwC;AAExC;;GAEG;AACU,QAAA,6BAA6B,GAAG,IAAI,2BAAoB,CAAC;IAClE,IAAI,EAAE,WAAW;IACjB,WAAW,EAAE,CAAC,EAAE,YAAY,EAAE,8BAAY,CAAC,EAAE,EAAE,KAAK,EAAE,WAAW,EAAE,CAAC;IACpE,IAAI,EAAE;QACF,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC9B,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;QAC7B,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;KACjC;IAED,KAAK,CAAC,aAAa,CAAC,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ;QAClD,MAAM,OAAO,GAAG,6BAAU,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI;YACA,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,WAAW,CAAC,IAAI,CAAC;gBAC5C,MAAM,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC;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AAE,CAAC,CAAC,CAAC;QACrG,IAAI,CAAC,QAAQ,CAAC,OAAO,EAAE;YACnB,OAAO;gBACH,KAAK,EAAE,QAAiB;gBACxB,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;gBACtC,QAAQ,EAAE,QAAQ;aACrB,CAAC;SACL;QACD,OAAO;YACH,KAAK,EAAE,SAAkB;YACzB,aAAa,EAAE,QAAQ,CAAC,WAAW,CAAC,EAAE;YACtC,QAAQ,EAAE,QAAQ;SACrB,CAAC;IACN,CAAC;CACJ,CAAC,CAAC"}
@@ -1,5 +0,0 @@
1
- /**
2
- * This plugin implements the Braintree (https://www.braintreepayments.com/) payment provider.
3
- */
4
- export declare class BraintreePlugin {
5
- }
@@ -1,38 +0,0 @@
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
- Object.defineProperty(exports, "__esModule", { value: true });
9
- exports.BraintreePlugin = void 0;
10
- const core_1 = require("@vendure/core");
11
- const apollo_server_core_1 = require("apollo-server-core");
12
- const braintree_payment_method_1 = require("./braintree-payment-method");
13
- const braintree_resolver_1 = require("./braintree.resolver");
14
- /**
15
- * This plugin implements the Braintree (https://www.braintreepayments.com/) payment provider.
16
- */
17
- let BraintreePlugin = class BraintreePlugin {
18
- };
19
- BraintreePlugin = __decorate([
20
- core_1.VendurePlugin({
21
- imports: [core_1.PluginCommonModule],
22
- providers: [],
23
- configuration: config => {
24
- config.paymentOptions.paymentMethodHandlers.push(braintree_payment_method_1.braintreePaymentMethodHandler);
25
- return config;
26
- },
27
- shopApiExtensions: {
28
- schema: apollo_server_core_1.gql `
29
- extend type Query {
30
- generateBraintreeClientToken(orderId: ID!): String!
31
- }
32
- `,
33
- resolvers: [braintree_resolver_1.BraintreeResolver],
34
- },
35
- })
36
- ], BraintreePlugin);
37
- exports.BraintreePlugin = BraintreePlugin;
38
- //# sourceMappingURL=braintree-plugin.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"braintree-plugin.js","sourceRoot":"","sources":["../../src/braintree/braintree-plugin.ts"],"names":[],"mappings":";;;;;;;;;AAAA,wCAAkE;AAClE,2DAAyC;AAEzC,yEAA2E;AAC3E,6DAAyD;AAEzD;;GAEG;AAiBH,IAAa,eAAe,GAA5B,MAAa,eAAe;CAAG,CAAA;AAAlB,eAAe;IAhB3B,oBAAa,CAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE,EAAE;QACb,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,wDAA6B,CAAC,CAAC;YAChF,OAAO,MAAM,CAAC;QAClB,CAAC;QACD,iBAAiB,EAAE;YACf,MAAM,EAAE,wBAAG,CAAA;;;;SAIV;YACD,SAAS,EAAE,CAAC,sCAAiB,CAAC;SACjC;KACJ,CAAC;GACW,eAAe,CAAG;AAAlB,0CAAe"}