@vendure/payments-plugin 2.0.0-next.9 → 2.0.1
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/README.md +36 -0
- package/package/braintree/braintree-common.d.ts +4 -2
- package/package/braintree/braintree-common.js +11 -5
- package/package/braintree/braintree-common.js.map +1 -1
- package/package/braintree/braintree.handler.js +14 -7
- package/package/braintree/braintree.handler.js.map +1 -1
- package/package/braintree/braintree.plugin.d.ts +52 -4
- package/package/braintree/braintree.plugin.js +53 -5
- package/package/braintree/braintree.plugin.js.map +1 -1
- package/package/braintree/braintree.resolver.d.ts +2 -1
- package/package/braintree/braintree.resolver.js +27 -6
- package/package/braintree/braintree.resolver.js.map +1 -1
- package/package/braintree/index.js +5 -1
- package/package/braintree/index.js.map +1 -1
- package/package/braintree/types.d.ts +62 -4
- package/package/braintree/types.js.map +1 -1
- package/package/mollie/graphql/generated-shop-types.d.ts +489 -338
- package/package/mollie/graphql/generated-shop-types.js +25 -2
- package/package/mollie/graphql/generated-shop-types.js.map +1 -1
- package/package/mollie/index.js +5 -1
- package/package/mollie/index.js.map +1 -1
- package/package/mollie/mollie-shop-schema.js +25 -0
- package/package/mollie/mollie-shop-schema.js.map +1 -1
- package/package/mollie/mollie.controller.d.ts +2 -1
- package/package/mollie/mollie.controller.js +14 -8
- package/package/mollie/mollie.controller.js.map +1 -1
- package/package/mollie/mollie.handler.d.ts +14 -0
- package/package/mollie/mollie.handler.js +53 -15
- package/package/mollie/mollie.handler.js.map +1 -1
- package/package/mollie/mollie.helpers.d.ts +33 -0
- package/package/mollie/mollie.helpers.js +142 -0
- package/package/mollie/mollie.helpers.js.map +1 -0
- package/package/mollie/mollie.plugin.d.ts +75 -21
- package/package/mollie/mollie.plugin.js +61 -19
- package/package/mollie/mollie.plugin.js.map +1 -1
- package/package/mollie/mollie.resolver.d.ts +3 -4
- package/package/mollie/mollie.resolver.js +13 -1
- package/package/mollie/mollie.resolver.js.map +1 -1
- package/package/mollie/mollie.service.d.ts +21 -10
- package/package/mollie/mollie.service.js +188 -71
- package/package/mollie/mollie.service.js.map +1 -1
- package/package/stripe/index.js +5 -1
- package/package/stripe/index.js.map +1 -1
- package/package/stripe/metadata-sanitize.d.ts +13 -0
- package/package/stripe/metadata-sanitize.js +33 -0
- package/package/stripe/metadata-sanitize.js.map +1 -0
- package/package/stripe/raw-body.middleware.js.map +1 -1
- package/package/stripe/stripe-client.d.ts +9 -0
- package/package/stripe/stripe-client.js +21 -0
- package/package/stripe/stripe-client.js.map +1 -0
- package/package/stripe/stripe-utils.d.ts +19 -0
- package/package/stripe/stripe-utils.js +43 -0
- package/package/stripe/stripe-utils.js.map +1 -0
- package/package/stripe/stripe.controller.d.ts +5 -5
- package/package/stripe/stripe.controller.js +27 -26
- package/package/stripe/stripe.controller.js.map +1 -1
- package/package/stripe/stripe.handler.d.ts +27 -2
- package/package/stripe/stripe.handler.js +56 -25
- package/package/stripe/stripe.handler.js.map +1 -1
- package/package/stripe/stripe.plugin.d.ts +91 -14
- package/package/stripe/stripe.plugin.js +92 -15
- package/package/stripe/stripe.plugin.js.map +1 -1
- package/package/stripe/stripe.resolver.d.ts +1 -1
- package/package/stripe/stripe.resolver.js +7 -5
- package/package/stripe/stripe.resolver.js.map +1 -1
- package/package/stripe/stripe.service.d.ts +14 -6
- package/package/stripe/stripe.service.js +74 -41
- package/package/stripe/stripe.service.js.map +1 -1
- package/package/stripe/types.d.ts +12 -13
- package/package/stripe/types.js.map +1 -1
- package/package.json +28 -9
package/README.md
CHANGED
|
@@ -1,3 +1,39 @@
|
|
|
1
1
|
# Payments plugin
|
|
2
2
|
|
|
3
3
|
For documentation, see https://www.vendure.io/docs/typescript-api/payments-plugin
|
|
4
|
+
|
|
5
|
+
## Development
|
|
6
|
+
|
|
7
|
+
### Mollie local development
|
|
8
|
+
|
|
9
|
+
For testing out changes to the Mollie plugin locally, with a real Mollie account, follow the steps below. These steps
|
|
10
|
+
will create an order, set Mollie as payment method, and create a payment intent link to the Mollie platform.
|
|
11
|
+
|
|
12
|
+
1. Get a test api key from your Mollie
|
|
13
|
+
dashboard: https://help.mollie.com/hc/en-us/articles/115000328205-Where-can-I-find-the-API-key-
|
|
14
|
+
2. Create the file `packages/payments-plugin/.env` with content `MOLLIE_APIKEY=your-test-apikey`
|
|
15
|
+
3. `cd packages/payments-plugin`
|
|
16
|
+
5. `yarn dev-server:mollie`
|
|
17
|
+
6. Watch the logs for `Mollie payment link` and click the link to finalize the test payment.
|
|
18
|
+
|
|
19
|
+
You can change the order flow, payment methods and more in the file `e2e/mollie-dev-server`, and restart the devserver.
|
|
20
|
+
|
|
21
|
+
### Stripe local development
|
|
22
|
+
|
|
23
|
+
For testing out changes to the Stripe plugin locally, with a real Stripe account, follow the steps below. These steps
|
|
24
|
+
will create an order, set Stripe as payment method, and create a payment secret.
|
|
25
|
+
|
|
26
|
+
1. Get a test api key from your Stripe
|
|
27
|
+
dashboard: https://dashboard.stripe.com/test/apikeys
|
|
28
|
+
2. Use Ngrok or Localtunnel to make your localhost publicly available and create a webhook as described here: https://www.vendure.io/docs/typescript-api/payments-plugin/stripe-plugin/
|
|
29
|
+
3. Create the file `packages/payments-plugin/.env` with these contents:
|
|
30
|
+
```sh
|
|
31
|
+
STRIPE_APIKEY=sk_test_xxxx
|
|
32
|
+
STRIPE_WEBHOOK_SECRET=webhook-secret
|
|
33
|
+
STRIPE_PUBLISHABLE_KEY=pk_test_xxxx
|
|
34
|
+
```
|
|
35
|
+
1. `cd packages/payments-plugin`
|
|
36
|
+
2. `yarn dev-server:stripe`
|
|
37
|
+
3. Watch the logs for the link or go to `http://localhost:3050/checkout` to test the checkout.
|
|
38
|
+
|
|
39
|
+
After checkout completion you can see your payment in https://dashboard.stripe.com/test/payments/
|
|
@@ -2,8 +2,10 @@ import { BraintreeGateway, Transaction } from 'braintree';
|
|
|
2
2
|
import { BraintreePluginOptions, PaymentMethodArgsHash } from './types';
|
|
3
3
|
export declare function getGateway(args: PaymentMethodArgsHash, options: BraintreePluginOptions): BraintreeGateway;
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* @description
|
|
6
|
+
* Returns a subset of the Transaction object of interest to the Administrator, plus some
|
|
7
|
+
* public data which may be useful to display in the storefront account area.
|
|
6
8
|
*/
|
|
7
|
-
export declare function
|
|
9
|
+
export declare function defaultExtractMetadataFn(transaction: Transaction): {
|
|
8
10
|
[key: string]: any;
|
|
9
11
|
};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.defaultExtractMetadataFn = exports.getGateway = void 0;
|
|
4
4
|
const braintree_1 = require("braintree");
|
|
5
5
|
function getGateway(args, options) {
|
|
6
6
|
return new braintree_1.BraintreeGateway({
|
|
@@ -12,9 +12,11 @@ function getGateway(args, options) {
|
|
|
12
12
|
}
|
|
13
13
|
exports.getGateway = getGateway;
|
|
14
14
|
/**
|
|
15
|
-
*
|
|
15
|
+
* @description
|
|
16
|
+
* Returns a subset of the Transaction object of interest to the Administrator, plus some
|
|
17
|
+
* public data which may be useful to display in the storefront account area.
|
|
16
18
|
*/
|
|
17
|
-
function
|
|
19
|
+
function defaultExtractMetadataFn(transaction) {
|
|
18
20
|
const metadata = {
|
|
19
21
|
status: transaction.status,
|
|
20
22
|
currencyIsoCode: transaction.currencyIsoCode,
|
|
@@ -25,13 +27,16 @@ function extractMetadataFromTransaction(transaction) {
|
|
|
25
27
|
processorAuthorizationCode: transaction.processorAuthorizationCode,
|
|
26
28
|
processorResponseText: transaction.processorResponseText,
|
|
27
29
|
paymentMethod: transaction.paymentInstrumentType,
|
|
30
|
+
public: {},
|
|
28
31
|
};
|
|
29
32
|
if (transaction.creditCard && transaction.creditCard.cardType) {
|
|
30
|
-
|
|
33
|
+
const cardData = {
|
|
31
34
|
cardType: transaction.creditCard.cardType,
|
|
32
35
|
last4: transaction.creditCard.last4,
|
|
33
36
|
expirationDate: transaction.creditCard.expirationDate,
|
|
34
37
|
};
|
|
38
|
+
metadata.cardData = cardData;
|
|
39
|
+
metadata.public.cardData = cardData;
|
|
35
40
|
}
|
|
36
41
|
if (transaction.paypalAccount && transaction.paypalAccount.authorizationId) {
|
|
37
42
|
metadata.paypalData = {
|
|
@@ -42,10 +47,11 @@ function extractMetadataFromTransaction(transaction) {
|
|
|
42
47
|
sellerProtectionStatus: transaction.paypalAccount.sellerProtectionStatus,
|
|
43
48
|
transactionFeeAmount: transaction.paypalAccount.transactionFeeAmount,
|
|
44
49
|
};
|
|
50
|
+
metadata.public.paypalData = { authorizationId: transaction.paypalAccount.authorizationId };
|
|
45
51
|
}
|
|
46
52
|
return metadata;
|
|
47
53
|
}
|
|
48
|
-
exports.
|
|
54
|
+
exports.defaultExtractMetadataFn = defaultExtractMetadataFn;
|
|
49
55
|
function decodeAvsCode(code) {
|
|
50
56
|
switch (code) {
|
|
51
57
|
case 'I':
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"braintree-common.js","sourceRoot":"","sources":["../../src/braintree/braintree-common.ts"],"names":[],"mappings":";;;AAAA,yCAAuE;AAIvE,SAAgB,UAAU,CAAC,IAA2B,EAAE,OAA+B;IACnF,OAAO,IAAI,4BAAgB,CAAC;QACxB,WAAW,EAAE,OAAO,CAAC,WAAW,IAAI,uBAAW,CAAC,OAAO;QACvD,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,UAAU,EAAE,IAAI,CAAC,UAAU;QAC3B,SAAS,EAAE,IAAI,CAAC,SAAS;KAC5B,CAAC,CAAC;AACP,CAAC;AAPD,gCAOC;AAED
|
|
1
|
+
{"version":3,"file":"braintree-common.js","sourceRoot":"","sources":["../../src/braintree/braintree-common.ts"],"names":[],"mappings":";;;AAAA,yCAAuE;AAIvE,SAAgB,UAAU,CAAC,IAA2B,EAAE,OAA+B;IACnF,OAAO,IAAI,4BAAgB,CAAC;QACxB,WAAW,EAAE,OAAO,CAAC,WA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EAAE,WAAW,CAAC,aAAa,CAAC,SAAS;YAC9C,eAAe,EAAE,WAAW,CAAC,aAAa,CAAC,eAAe;YAC1D,WAAW,EAAE,WAAW,CAAC,aAAa,CAAC,WAAW;YAClD,sBAAsB,EAAE,WAAW,CAAC,aAAa,CAAC,sBAAsB;YACxE,oBAAoB,EAAE,WAAW,CAAC,aAAa,CAAC,oBAAoB;SACvE,CAAC;QACF,QAAQ,CAAC,MAAM,CAAC,UAAU,GAAG,EAAE,eAAe,EAAE,WAAW,CAAC,aAAa,CAAC,eAAe,EAAE,CAAC;KAC/F;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AAlCD,4DAkCC;AAED,SAAS,aAAa,CAAC,IAAY;IAC/B,QAAQ,IAAI,EAAE;QACV,KAAK,GAAG;YACJ,OAAO,cAAc,CAAC;QAC1B,KAAK,GAAG;YACJ,OAAO,SAAS,CAAC;QACrB,KAAK,GAAG;YACJ,OAAO,aAAa,CAAC;QACzB,KAAK,GAAG;YACJ,OAAO,cAAc,CAAC;QAC1B,KAAK,GAAG;YACJ,OAAO,eAAe,CAAC;QAC3B,KAAK,GAAG;YACJ,OAAO,kBAAkB,CAAC;QAC9B,KAAK,GAAG;YACJ,OAAO,gBAAgB,CAAC;QAC5B,KAAK,GAAG;YACJ,OAAO,SAAS,CAAC;QACrB;YACI,OAAO,SAAS,CAAC;KACxB;AACL,CAAC"}
|
|
@@ -30,15 +30,18 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
30
30
|
try {
|
|
31
31
|
await entityHydrator.hydrate(ctx, order, { relations: ['customer'] });
|
|
32
32
|
const customer = order.customer;
|
|
33
|
-
if (options.storeCustomersInBraintree &&
|
|
33
|
+
if (options.storeCustomersInBraintree &&
|
|
34
|
+
ctx.activeUserId &&
|
|
35
|
+
customer &&
|
|
36
|
+
metadata.includeCustomerId !== false) {
|
|
34
37
|
customerId = await getBraintreeCustomerId(ctx, gateway, customer);
|
|
35
38
|
}
|
|
36
|
-
return processPayment(ctx, gateway, order, amount, metadata.nonce, customerId);
|
|
39
|
+
return processPayment(ctx, gateway, order, amount, metadata.nonce, customerId, options);
|
|
37
40
|
}
|
|
38
41
|
catch (e) {
|
|
39
42
|
core_1.Logger.error(e, constants_1.loggerCtx);
|
|
40
43
|
return {
|
|
41
|
-
amount
|
|
44
|
+
amount,
|
|
42
45
|
state: 'Error',
|
|
43
46
|
transactionId: '',
|
|
44
47
|
errorMessage: e.toString(),
|
|
@@ -52,12 +55,13 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
52
55
|
};
|
|
53
56
|
},
|
|
54
57
|
async createRefund(ctx, input, total, order, payment, args) {
|
|
58
|
+
var _a;
|
|
55
59
|
const gateway = (0, braintree_common_1.getGateway)(args, options);
|
|
56
60
|
const response = await gateway.transaction.refund(payment.transactionId, (total / 100).toString(10));
|
|
57
61
|
if (!response.success) {
|
|
58
62
|
return {
|
|
59
63
|
state: 'Failed',
|
|
60
|
-
transactionId: response.transaction.id,
|
|
64
|
+
transactionId: (_a = response.transaction) === null || _a === void 0 ? void 0 : _a.id,
|
|
61
65
|
metadata: response,
|
|
62
66
|
};
|
|
63
67
|
}
|
|
@@ -68,7 +72,8 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
68
72
|
};
|
|
69
73
|
},
|
|
70
74
|
});
|
|
71
|
-
async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, customerId) {
|
|
75
|
+
async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, customerId, pluginOptions) {
|
|
76
|
+
var _a;
|
|
72
77
|
const response = await gateway.transaction.sale({
|
|
73
78
|
customerId,
|
|
74
79
|
amount: (amount / 100).toString(10),
|
|
@@ -79,20 +84,22 @@ async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, c
|
|
|
79
84
|
storeInVaultOnSuccess: !!customerId,
|
|
80
85
|
},
|
|
81
86
|
});
|
|
87
|
+
const extractMetadataFn = (_a = pluginOptions.extractMetadata) !== null && _a !== void 0 ? _a : braintree_common_1.defaultExtractMetadataFn;
|
|
88
|
+
const metadata = extractMetadataFn(response.transaction);
|
|
82
89
|
if (!response.success) {
|
|
83
90
|
return {
|
|
84
91
|
amount,
|
|
85
92
|
state: 'Declined',
|
|
86
93
|
transactionId: response.transaction.id,
|
|
87
94
|
errorMessage: response.message,
|
|
88
|
-
metadata
|
|
95
|
+
metadata,
|
|
89
96
|
};
|
|
90
97
|
}
|
|
91
98
|
return {
|
|
92
99
|
amount,
|
|
93
100
|
state: 'Settled',
|
|
94
101
|
transactionId: response.transaction.id,
|
|
95
|
-
metadata
|
|
102
|
+
metadata,
|
|
96
103
|
};
|
|
97
104
|
}
|
|
98
105
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"braintree.handler.js","sourceRoot":"","sources":["../../src/braintree/braintree.handler.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,wCASuB;AAGvB,
|
|
1
|
+
{"version":3,"file":"braintree.handler.js","sourceRoot":"","sources":["../../src/braintree/braintree.handler.ts"],"names":[],"mappings":";;;AAAA,yEAAmE;AACnE,wCASuB;AAGvB,yDAA0E;AAC1E,2CAAkE;AAGlE,IAAI,OAA+B,CAAC;AACpC,IAAI,UAAmC,CAAC;AACxC,IAAI,cAA8B,CAAC;AAEnC;;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,oBAAoB,EAAE,CAAC;IAC7E,IAAI,EAAE;QACF,UAAU,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,8BAAY,CAAC,EAAE,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,EAAE;QAChG,SAAS,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,KA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,UAAU,CAAC,aAAa,CAAC,GAAG,EAAE,eAAQ,CAAC,CAAC,IAAI,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,CAAC;gBAChF,OAAO,UAAU,CAAC;aACrB;iBAAM;gBACH,aAAM,CAAC,KAAK,CACR,6DAA6D,QAAQ,CAAC,EAAE,sCAAsC,EAC9G,qBAAS,CACZ,CAAC;gBACF,aAAM,CAAC,KAAK,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC,EAAE,qBAAS,CAAC,CAAC;aACnE;SACJ;QAAC,OAAO,CAAM,EAAE;YACb,aAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,qBAAS,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC;SAC/C;KACJ;SAAM;QACH,OAAO,QAAQ,CAAC,YAAY,CAAC,mBAAmB,CAAC;KACpD;AACL,CAAC"}
|
|
@@ -31,7 +31,8 @@ import { BraintreePluginOptions } from './types';
|
|
|
31
31
|
* BraintreePlugin.init({
|
|
32
32
|
* environment: Environment.Sandbox,
|
|
33
33
|
* // This allows saving customer payment
|
|
34
|
-
* // methods with Braintree
|
|
34
|
+
* // methods with Braintree (see "vaulting"
|
|
35
|
+
* // section below for details)
|
|
35
36
|
* storeCustomersInBraintree: true,
|
|
36
37
|
* }),
|
|
37
38
|
* ]
|
|
@@ -56,7 +57,7 @@ import { BraintreePluginOptions } from './types';
|
|
|
56
57
|
* 2. Use this client token to instantiate the Braintree Dropin UI.
|
|
57
58
|
* 3. Listen for the `"paymentMethodRequestable"` event which emitted by the Dropin.
|
|
58
59
|
* 4. Use the Dropin's `requestPaymentMethod()` method to get the required payment metadata.
|
|
59
|
-
* 5. Pass that metadata to the `addPaymentToOrder` mutation.
|
|
60
|
+
* 5. Pass that metadata to the `addPaymentToOrder` mutation. The metadata should be an object of type `{ nonce: string; }`
|
|
60
61
|
*
|
|
61
62
|
* Here is an example of how your storefront code will look. Note that this example is attempting to
|
|
62
63
|
* be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
|
|
@@ -94,7 +95,7 @@ import { BraintreePluginOptions } from './types';
|
|
|
94
95
|
* // Braintree account.
|
|
95
96
|
* paypal: {
|
|
96
97
|
* flow: 'checkout',
|
|
97
|
-
* amount: order.totalWithTax,
|
|
98
|
+
* amount: order.totalWithTax / 100,
|
|
98
99
|
* currency: 'GBP',
|
|
99
100
|
* },
|
|
100
101
|
* }),
|
|
@@ -181,7 +182,54 @@ import { BraintreePluginOptions } from './types';
|
|
|
181
182
|
* }
|
|
182
183
|
* }
|
|
183
184
|
* ```
|
|
184
|
-
*
|
|
185
|
+
*
|
|
186
|
+
* ## Storing payment details (vaulting)
|
|
187
|
+
*
|
|
188
|
+
* Braintree has a [vault feature](https://developer.paypal.com/braintree/articles/control-panel/vault/overview) which allows the secure storage
|
|
189
|
+
* of customer's payment information. Using the vault allows you to offer a faster checkout for repeat customers without needing to worry about
|
|
190
|
+
* how to securely store payment details.
|
|
191
|
+
*
|
|
192
|
+
* To enable this feature, set the `storeCustomersInBraintree` option to `true`.
|
|
193
|
+
*
|
|
194
|
+
* ```TypeScript
|
|
195
|
+
* BraintreePlugin.init({
|
|
196
|
+
* environment: Environment.Sandbox,
|
|
197
|
+
* storeCustomersInBraintree: true,
|
|
198
|
+
* }),
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* Since v1.8, it is possible to override vaulting on a per-payment basis by passing `includeCustomerId: false` to the `generateBraintreeClientToken`
|
|
202
|
+
* mutation:
|
|
203
|
+
*
|
|
204
|
+
* ```GraphQL
|
|
205
|
+
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
206
|
+
* query GenerateBraintreeClientToken($includeCustomerId: Boolean) {
|
|
207
|
+
* generateBraintreeClientToken(includeCustomerId: $includeCustomerId)
|
|
208
|
+
* }
|
|
209
|
+
* `, { includeCustomerId: false });
|
|
210
|
+
* ```
|
|
211
|
+
*
|
|
212
|
+
* as well as in the metadata of the `addPaymentToOrder` mutation:
|
|
213
|
+
*
|
|
214
|
+
* ```TypeScript
|
|
215
|
+
* const { addPaymentToOrder } = await graphQlClient.query(gql`
|
|
216
|
+
* mutation AddPayment($input: PaymentInput!) {
|
|
217
|
+
* addPaymentToOrder(input: $input) {
|
|
218
|
+
* ...Order
|
|
219
|
+
* ...ErrorResult
|
|
220
|
+
* }
|
|
221
|
+
* }`, {
|
|
222
|
+
* input: {
|
|
223
|
+
* method: 'braintree',
|
|
224
|
+
* metadata: {
|
|
225
|
+
* ...paymentResult,
|
|
226
|
+
* includeCustomerId: false,
|
|
227
|
+
* },
|
|
228
|
+
* }
|
|
229
|
+
* );
|
|
230
|
+
* ```
|
|
231
|
+
*
|
|
232
|
+
* @docsCategory core plugins/PaymentsPlugin
|
|
185
233
|
* @docsPage BraintreePlugin
|
|
186
234
|
*/
|
|
187
235
|
export declare class BraintreePlugin {
|
|
@@ -44,7 +44,8 @@ const constants_1 = require("./constants");
|
|
|
44
44
|
* BraintreePlugin.init({
|
|
45
45
|
* environment: Environment.Sandbox,
|
|
46
46
|
* // This allows saving customer payment
|
|
47
|
-
* // methods with Braintree
|
|
47
|
+
* // methods with Braintree (see "vaulting"
|
|
48
|
+
* // section below for details)
|
|
48
49
|
* storeCustomersInBraintree: true,
|
|
49
50
|
* }),
|
|
50
51
|
* ]
|
|
@@ -69,7 +70,7 @@ const constants_1 = require("./constants");
|
|
|
69
70
|
* 2. Use this client token to instantiate the Braintree Dropin UI.
|
|
70
71
|
* 3. Listen for the `"paymentMethodRequestable"` event which emitted by the Dropin.
|
|
71
72
|
* 4. Use the Dropin's `requestPaymentMethod()` method to get the required payment metadata.
|
|
72
|
-
* 5. Pass that metadata to the `addPaymentToOrder` mutation.
|
|
73
|
+
* 5. Pass that metadata to the `addPaymentToOrder` mutation. The metadata should be an object of type `{ nonce: string; }`
|
|
73
74
|
*
|
|
74
75
|
* Here is an example of how your storefront code will look. Note that this example is attempting to
|
|
75
76
|
* be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
|
|
@@ -107,7 +108,7 @@ const constants_1 = require("./constants");
|
|
|
107
108
|
* // Braintree account.
|
|
108
109
|
* paypal: {
|
|
109
110
|
* flow: 'checkout',
|
|
110
|
-
* amount: order.totalWithTax,
|
|
111
|
+
* amount: order.totalWithTax / 100,
|
|
111
112
|
* currency: 'GBP',
|
|
112
113
|
* },
|
|
113
114
|
* }),
|
|
@@ -194,7 +195,54 @@ const constants_1 = require("./constants");
|
|
|
194
195
|
* }
|
|
195
196
|
* }
|
|
196
197
|
* ```
|
|
197
|
-
*
|
|
198
|
+
*
|
|
199
|
+
* ## Storing payment details (vaulting)
|
|
200
|
+
*
|
|
201
|
+
* Braintree has a [vault feature](https://developer.paypal.com/braintree/articles/control-panel/vault/overview) which allows the secure storage
|
|
202
|
+
* of customer's payment information. Using the vault allows you to offer a faster checkout for repeat customers without needing to worry about
|
|
203
|
+
* how to securely store payment details.
|
|
204
|
+
*
|
|
205
|
+
* To enable this feature, set the `storeCustomersInBraintree` option to `true`.
|
|
206
|
+
*
|
|
207
|
+
* ```TypeScript
|
|
208
|
+
* BraintreePlugin.init({
|
|
209
|
+
* environment: Environment.Sandbox,
|
|
210
|
+
* storeCustomersInBraintree: true,
|
|
211
|
+
* }),
|
|
212
|
+
* ```
|
|
213
|
+
*
|
|
214
|
+
* Since v1.8, it is possible to override vaulting on a per-payment basis by passing `includeCustomerId: false` to the `generateBraintreeClientToken`
|
|
215
|
+
* mutation:
|
|
216
|
+
*
|
|
217
|
+
* ```GraphQL
|
|
218
|
+
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
219
|
+
* query GenerateBraintreeClientToken($includeCustomerId: Boolean) {
|
|
220
|
+
* generateBraintreeClientToken(includeCustomerId: $includeCustomerId)
|
|
221
|
+
* }
|
|
222
|
+
* `, { includeCustomerId: false });
|
|
223
|
+
* ```
|
|
224
|
+
*
|
|
225
|
+
* as well as in the metadata of the `addPaymentToOrder` mutation:
|
|
226
|
+
*
|
|
227
|
+
* ```TypeScript
|
|
228
|
+
* const { addPaymentToOrder } = await graphQlClient.query(gql`
|
|
229
|
+
* mutation AddPayment($input: PaymentInput!) {
|
|
230
|
+
* addPaymentToOrder(input: $input) {
|
|
231
|
+
* ...Order
|
|
232
|
+
* ...ErrorResult
|
|
233
|
+
* }
|
|
234
|
+
* }`, {
|
|
235
|
+
* input: {
|
|
236
|
+
* method: 'braintree',
|
|
237
|
+
* metadata: {
|
|
238
|
+
* ...paymentResult,
|
|
239
|
+
* includeCustomerId: false,
|
|
240
|
+
* },
|
|
241
|
+
* }
|
|
242
|
+
* );
|
|
243
|
+
* ```
|
|
244
|
+
*
|
|
245
|
+
* @docsCategory core plugins/PaymentsPlugin
|
|
198
246
|
* @docsPage BraintreePlugin
|
|
199
247
|
*/
|
|
200
248
|
let BraintreePlugin = BraintreePlugin_1 = class BraintreePlugin {
|
|
@@ -230,7 +278,7 @@ BraintreePlugin = BraintreePlugin_1 = __decorate([
|
|
|
230
278
|
shopApiExtensions: {
|
|
231
279
|
schema: (0, apollo_server_core_1.gql) `
|
|
232
280
|
extend type Query {
|
|
233
|
-
generateBraintreeClientToken(orderId: ID): String!
|
|
281
|
+
generateBraintreeClientToken(orderId: ID, includeCustomerId: Boolean): String!
|
|
234
282
|
}
|
|
235
283
|
`,
|
|
236
284
|
resolvers: [braintree_resolver_1.BraintreeResolver],
|
|
@@ -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
|
|
1
|
+
{"version":3,"file":"braintree.plugin.js","sourceRoot":"","sources":["../../src/braintree/braintree.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsF;AACtF,2DAAyC;AAEzC,2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B,CAAC;QACD,iBAAiB,EAAE;YACf,MAAM,EAAE,IAAA,wBAAG,EAAA;;;;SAIV;YACD,SAAS,EAAE,CAAC,sCAAiB,CAAC;SACjC;KACJ,CAAC;GACW,eAAe,CAM3B;AANY,0CAAe"}
|
|
@@ -6,8 +6,9 @@ export declare class BraintreeResolver {
|
|
|
6
6
|
private activeOrderService;
|
|
7
7
|
private options;
|
|
8
8
|
constructor(connection: TransactionalConnection, orderService: OrderService, activeOrderService: ActiveOrderService, options: BraintreePluginOptions);
|
|
9
|
-
generateBraintreeClientToken(ctx: RequestContext, { orderId }: {
|
|
9
|
+
generateBraintreeClientToken(ctx: RequestContext, { orderId, includeCustomerId }: {
|
|
10
10
|
orderId?: ID;
|
|
11
|
+
includeCustomerId?: boolean;
|
|
11
12
|
}): Promise<string>;
|
|
12
13
|
private getPaymentMethodArgs;
|
|
13
14
|
}
|
|
@@ -26,14 +26,14 @@ let BraintreeResolver = class BraintreeResolver {
|
|
|
26
26
|
this.activeOrderService = activeOrderService;
|
|
27
27
|
this.options = options;
|
|
28
28
|
}
|
|
29
|
-
async generateBraintreeClientToken(ctx, { orderId }) {
|
|
29
|
+
async generateBraintreeClientToken(ctx, { orderId, includeCustomerId }) {
|
|
30
30
|
var _a;
|
|
31
31
|
if (orderId) {
|
|
32
|
-
core_1.Logger.warn(
|
|
32
|
+
core_1.Logger.warn('The orderId argument to the generateBraintreeClientToken mutation has been deprecated and may be omitted.');
|
|
33
33
|
}
|
|
34
34
|
const sessionOrder = await this.activeOrderService.getOrderFromContext(ctx);
|
|
35
35
|
if (!sessionOrder) {
|
|
36
|
-
throw new core_1.InternalServerError(
|
|
36
|
+
throw new core_1.InternalServerError('Cannot generate Braintree clientToken as there is no active Order.');
|
|
37
37
|
}
|
|
38
38
|
const order = await this.orderService.findOne(ctx, sessionOrder.id);
|
|
39
39
|
if (order && order.customer) {
|
|
@@ -41,11 +41,32 @@ let BraintreeResolver = class BraintreeResolver {
|
|
|
41
41
|
const args = await this.getPaymentMethodArgs(ctx);
|
|
42
42
|
const gateway = (0, braintree_common_1.getGateway)(args, this.options);
|
|
43
43
|
try {
|
|
44
|
-
|
|
45
|
-
|
|
44
|
+
let result = await gateway.clientToken.generate({
|
|
45
|
+
customerId: includeCustomerId === false ? undefined : customerId,
|
|
46
|
+
});
|
|
47
|
+
if (result.success === true) {
|
|
48
|
+
return result.clientToken;
|
|
49
|
+
}
|
|
50
|
+
else {
|
|
51
|
+
if (result.message === 'Customer specified by customer_id does not exist') {
|
|
52
|
+
// For some reason the custom_id is invalid. This could occur e.g. if the ID was created on the Sandbox endpoint and now
|
|
53
|
+
// we switched to Production. In this case, we will remove it and allow a new one
|
|
54
|
+
// to be generated when the payment is created.
|
|
55
|
+
if (this.options.storeCustomersInBraintree) {
|
|
56
|
+
order.customer.customFields.braintreeCustomerId = undefined;
|
|
57
|
+
await this.connection.getRepository(ctx, core_1.Customer).save(order.customer);
|
|
58
|
+
}
|
|
59
|
+
result = await gateway.clientToken.generate({ customerId: undefined });
|
|
60
|
+
if (result.success === true) {
|
|
61
|
+
return result.clientToken;
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
core_1.Logger.error(`Could not generate Braintree clientToken: ${result.message}`, constants_1.loggerCtx);
|
|
65
|
+
throw new core_1.InternalServerError(`Could not generate Braintree clientToken: ${result.message}`);
|
|
66
|
+
}
|
|
46
67
|
}
|
|
47
68
|
catch (e) {
|
|
48
|
-
core_1.Logger.error(
|
|
69
|
+
core_1.Logger.error('Could not generate Braintree clientToken. Check the configured credentials.', constants_1.loggerCtx);
|
|
49
70
|
throw e;
|
|
50
71
|
}
|
|
51
72
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"braintree.resolver.js","sourceRoot":"","sources":["../../src/braintree/braintree.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAwD;AACxD,
|
|
1
|
+
{"version":3,"file":"braintree.resolver.js","sourceRoot":"","s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,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,iDAA6B,CAAC,IAAI,CAC7D,CAAC;QAEF,IAAI,CAAC,MAAM,EAAE;YACT,MAAM,IAAI,0BAAmB,CAAC,IAAI,qBAAS,0CAA0C,CAAC,CAAC;SAC1F;QACD,OAAO,MAAM,CAAC,OAAO,CAAC,IAAI,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;AAxES;IADL,IAAA,eAAK,GAAE;IAEH,WAAA,IAAA,UAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAI,GAAE,CAAA;;qCADK,qBAAc;;qEAsD7B;AAhEQ,iBAAiB;IAD7B,IAAA,kBAAQ,GAAE;IAMF,WAAA,IAAA,eAAM,EAAC,oCAAwB,CAAC,CAAA;qCAHb,8BAAuB;QACrB,mBAAY;QACN,yBAAkB;GAJzC,iBAAiB,CAiF7B;AAjFY,8CAAiB"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
3
|
if (k2 === undefined) k2 = k;
|
|
4
|
-
Object.
|
|
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);
|
|
5
9
|
}) : (function(o, m, k, k2) {
|
|
6
10
|
if (k2 === undefined) k2 = k;
|
|
7
11
|
o[k2] = m[k];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/braintree/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/braintree/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,qDAAmC;AACnC,sDAAoC;AACpC,uDAAqC;AACrC,qDAAmC;AACnC,0CAAwB"}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
+
import { PaymentMetadata } from '@vendure/core';
|
|
1
2
|
import { ConfigArgValues } from '@vendure/core/dist/common/configurable-operation';
|
|
2
3
|
import '@vendure/core/dist/entity/custom-entity-fields';
|
|
3
|
-
import { Environment } from 'braintree';
|
|
4
|
+
import { Environment, Transaction } from 'braintree';
|
|
4
5
|
import { braintreePaymentMethodHandler } from './braintree.handler';
|
|
5
|
-
export
|
|
6
|
+
export type PaymentMethodArgsHash = ConfigArgValues<(typeof braintreePaymentMethodHandler)['args']>;
|
|
6
7
|
declare module '@vendure/core/dist/entity/custom-entity-fields' {
|
|
7
8
|
interface CustomCustomerFields {
|
|
8
9
|
braintreeCustomerId?: string;
|
|
@@ -12,7 +13,7 @@ declare module '@vendure/core/dist/entity/custom-entity-fields' {
|
|
|
12
13
|
* @description
|
|
13
14
|
* Options for the Braintree plugin.
|
|
14
15
|
*
|
|
15
|
-
* @docsCategory
|
|
16
|
+
* @docsCategory core plugins/PaymentsPlugin
|
|
16
17
|
* @docsPage BraintreePlugin
|
|
17
18
|
*/
|
|
18
19
|
export interface BraintreePluginOptions {
|
|
@@ -26,11 +27,68 @@ export interface BraintreePluginOptions {
|
|
|
26
27
|
/**
|
|
27
28
|
* @description
|
|
28
29
|
* If set to `true`, a [Customer](https://developer.paypal.com/braintree/docs/guides/customers) object
|
|
29
|
-
* will be created in Braintree, which allows the secure storage of previously-used payment methods.
|
|
30
|
+
* will be created in Braintree, which allows the secure storage ("vaulting") of previously-used payment methods.
|
|
30
31
|
* This is done by adding a custom field to the Customer entity to store the Braintree customer ID,
|
|
31
32
|
* so switching this on will require a database migration / synchronization.
|
|
32
33
|
*
|
|
34
|
+
* Since v1.8, it is possible to override vaulting on a per-payment basis by passing `includeCustomerId: false` to the
|
|
35
|
+
* `generateBraintreeClientToken` mutation.
|
|
36
|
+
*
|
|
33
37
|
* @default false
|
|
34
38
|
*/
|
|
35
39
|
storeCustomersInBraintree?: boolean;
|
|
40
|
+
/**
|
|
41
|
+
* @description
|
|
42
|
+
* Allows you to configure exactly what information from the Braintree
|
|
43
|
+
* [Transaction object](https://developer.paypal.com/braintree/docs/reference/response/transaction#result-object) (which is returned by the
|
|
44
|
+
* `transaction.sale()` method of the SDK) should be persisted to the resulting Payment entity metadata.
|
|
45
|
+
*
|
|
46
|
+
* By default, the built-in extraction function will return a metadata object that looks like this:
|
|
47
|
+
*
|
|
48
|
+
* @example
|
|
49
|
+
* ```TypeScript
|
|
50
|
+
* const metadata = {
|
|
51
|
+
* "status": "settling",
|
|
52
|
+
* "currencyIsoCode": "GBP",
|
|
53
|
+
* "merchantAccountId": "my_account_id",
|
|
54
|
+
* "cvvCheck": "Not Applicable",
|
|
55
|
+
* "avsPostCodeCheck": "Not Applicable",
|
|
56
|
+
* "avsStreetAddressCheck": "Not Applicable",
|
|
57
|
+
* "processorAuthorizationCode": null,
|
|
58
|
+
* "processorResponseText": "Approved",
|
|
59
|
+
* // for Paypal payments
|
|
60
|
+
* "paymentMethod": "paypal_account",
|
|
61
|
+
* "paypalData": {
|
|
62
|
+
* "payerEmail": "michael-buyer@paypalsandbox.com",
|
|
63
|
+
* "paymentId": "PAYID-MLCXYNI74301746XK8807043",
|
|
64
|
+
* "authorizationId": "3BU93594D85624939",
|
|
65
|
+
* "payerStatus": "VERIFIED",
|
|
66
|
+
* "sellerProtectionStatus": "ELIGIBLE",
|
|
67
|
+
* "transactionFeeAmount": "0.54"
|
|
68
|
+
* },
|
|
69
|
+
* // for credit card payments
|
|
70
|
+
* "paymentMethod": "credit_card",
|
|
71
|
+
* "cardData": {
|
|
72
|
+
* "cardType": "MasterCard",
|
|
73
|
+
* "last4": "5454",
|
|
74
|
+
* "expirationDate": "02/2023"
|
|
75
|
+
* }
|
|
76
|
+
* // publicly-available metadata that will be
|
|
77
|
+
* // readable from the Shop API
|
|
78
|
+
* "public": {
|
|
79
|
+
* "cardData": {
|
|
80
|
+
* "cardType": "MasterCard",
|
|
81
|
+
* "last4": "5454",
|
|
82
|
+
* "expirationDate": "02/2023"
|
|
83
|
+
* },
|
|
84
|
+
* "paypalData": {
|
|
85
|
+
* "authorizationId": "3BU93594D85624939",
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* }
|
|
89
|
+
* ```
|
|
90
|
+
*
|
|
91
|
+
* @since 1.7.0
|
|
92
|
+
*/
|
|
93
|
+
extractMetadata?: (transaction: Transaction) => PaymentMetadata;
|
|
36
94
|
}
|
|
@@ -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":";;AAEA,0DAAwD"}
|