@vendure/payments-plugin 2.0.0-next.2 → 2.0.0-next.20
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-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 +54 -6
- package/package/braintree/braintree.plugin.js +55 -7
- package/package/braintree/braintree.plugin.js.map +1 -1
- package/package/braintree/braintree.resolver.d.ts +6 -4
- package/package/braintree/braintree.resolver.js +17 -6
- package/package/braintree/braintree.resolver.js.map +1 -1
- package/package/braintree/types.d.ts +60 -2
- package/package/braintree/types.js.map +1 -1
- package/package/mollie/graphql/generated-shop-types.d.ts +62 -0
- package/package/mollie/graphql/generated-shop-types.js +25 -0
- package/package/mollie/graphql/generated-shop-types.js.map +1 -1
- package/package/mollie/mollie-shop-schema.js +24 -0
- package/package/mollie/mollie-shop-schema.js.map +1 -1
- package/package/mollie/mollie.plugin.d.ts +35 -6
- package/package/mollie/mollie.plugin.js +35 -6
- 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 +4 -2
- package/package/mollie/mollie.service.js +40 -14
- package/package/mollie/mollie.service.js.map +1 -1
- package/package/stripe/raw-body.middleware.js.map +1 -1
- 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 +21 -15
- package/package/stripe/stripe.controller.js.map +1 -1
- package/package/stripe/stripe.handler.js +4 -2
- package/package/stripe/stripe.handler.js.map +1 -1
- package/package/stripe/stripe.plugin.d.ts +89 -11
- package/package/stripe/stripe.plugin.js +89 -11
- package/package/stripe/stripe.plugin.js.map +1 -1
- package/package/stripe/stripe.service.d.ts +1 -1
- package/package/stripe/stripe.service.js +4 -2
- package/package/stripe/stripe.service.js.map +1 -1
- package/package/stripe/types.d.ts +2 -2
- package/package.json +5 -5
|
@@ -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;Q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ymentMethodHandler = 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,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,CAAC,QAAQ;gBAC3B,KAAK,EAAE,QAAQ,CAAC,YAAY;aAC/B,CAAC,CAAC;YACH,IAAI,MAAM,CAAC,OAAO,EAAE;gBAChB,MAAM,UAAU,GAAG,MAAM,CAAC,QAAQ,CAAC,EAAE,CAAC;gBACtC,aAAM,CAAC,OAAO,CAAC,oDAAoD,QAAQ,CAAC,EAAE,EAAE,EAAE,qBAAS,CAAC,CAAC;gBAC7F,QAAQ,CAAC,YAAY,CAAC,mBAAmB,GAAG,UAAU,CAAC;gBACvD,MAAM,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.
|
|
@@ -122,12 +123,12 @@ import { BraintreePluginOptions } from './types';
|
|
|
122
123
|
* });
|
|
123
124
|
* }
|
|
124
125
|
*
|
|
125
|
-
* async function generateClientToken(
|
|
126
|
+
* async function generateClientToken() {
|
|
126
127
|
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
127
|
-
* query GenerateBraintreeClientToken
|
|
128
|
-
* generateBraintreeClientToken
|
|
128
|
+
* query GenerateBraintreeClientToken {
|
|
129
|
+
* generateBraintreeClientToken
|
|
129
130
|
* }
|
|
130
|
-
*
|
|
131
|
+
* `);
|
|
131
132
|
* return generateBraintreeClientToken;
|
|
132
133
|
* }
|
|
133
134
|
*
|
|
@@ -181,6 +182,53 @@ import { BraintreePluginOptions } from './types';
|
|
|
181
182
|
* }
|
|
182
183
|
* }
|
|
183
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
|
+
*
|
|
184
232
|
* @docsCategory payments-plugin
|
|
185
233
|
* @docsPage BraintreePlugin
|
|
186
234
|
*/
|
|
@@ -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.
|
|
@@ -135,12 +136,12 @@ const constants_1 = require("./constants");
|
|
|
135
136
|
* });
|
|
136
137
|
* }
|
|
137
138
|
*
|
|
138
|
-
* async function generateClientToken(
|
|
139
|
+
* async function generateClientToken() {
|
|
139
140
|
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
140
|
-
* query GenerateBraintreeClientToken
|
|
141
|
-
* generateBraintreeClientToken
|
|
141
|
+
* query GenerateBraintreeClientToken {
|
|
142
|
+
* generateBraintreeClientToken
|
|
142
143
|
* }
|
|
143
|
-
*
|
|
144
|
+
* `);
|
|
144
145
|
* return generateBraintreeClientToken;
|
|
145
146
|
* }
|
|
146
147
|
*
|
|
@@ -194,6 +195,53 @@ const constants_1 = require("./constants");
|
|
|
194
195
|
* }
|
|
195
196
|
* }
|
|
196
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
|
+
*
|
|
197
245
|
* @docsCategory payments-plugin
|
|
198
246
|
* @docsPage BraintreePlugin
|
|
199
247
|
*/
|
|
@@ -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
|
|
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,2DAAoE;AACpE,6DAAyD;AACzD,2CAAuD;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuOG;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,EAAG,CAAA;AADnC,eAAe;IA/B3B,IAAA,oBAAa,EAAC;QACX,OAAO,EAAE,CAAC,yBAAkB,CAAC;QAC7B,SAAS,EAAE;YACP;gBACI,OAAO,EAAE,oCAAwB;gBACjC,UAAU,EAAE,GAAG,EAAE,CAAC,iBAAe,CAAC,OAAO;aAC5C;SACJ;QACD,aAAa,EAAE,MAAM,CAAC,EAAE;YACpB,MAAM,CAAC,cAAc,CAAC,qBAAqB,CAAC,IAAI,CAAC,iDAA6B,CAAC,CAAC;YAChF,IAAI,iBAAe,CAAC,OAAO,CAAC,yBAAyB,KAAK,IAAI,EAAE;gBAC5D,MAAM,CAAC,YAAY,CAAC,QAAQ,CAAC,IAAI,CAAC;oBAC9B,IAAI,EAAE,qBAAqB;oBAC3B,IAAI,EAAE,QAAQ;oBACd,KAAK,EAAE,CAAC,EAAE,YAAY,EAAE,mBAAY,CAAC,EAAE,EAAE,KAAK,EAAE,uBAAuB,EAAE,CAAC;oBAC1E,QAAQ,EAAE,IAAI;oBACd,MAAM,EAAE,KAAK;oBACb,QAAQ,EAAE,IAAI;iBACjB,CAAC,CAAC;aACN;YACD,OAAO,MAAM,CAAC;QAClB,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"}
|
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import { ID, OrderService, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
1
|
+
import { ActiveOrderService, ID, OrderService, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
2
2
|
import { BraintreePluginOptions } from './types';
|
|
3
3
|
export declare class BraintreeResolver {
|
|
4
4
|
private connection;
|
|
5
5
|
private orderService;
|
|
6
|
+
private activeOrderService;
|
|
6
7
|
private options;
|
|
7
|
-
constructor(connection: TransactionalConnection, orderService: OrderService, options: BraintreePluginOptions);
|
|
8
|
-
generateBraintreeClientToken(ctx: RequestContext, { orderId }: {
|
|
9
|
-
orderId
|
|
8
|
+
constructor(connection: TransactionalConnection, orderService: OrderService, activeOrderService: ActiveOrderService, options: BraintreePluginOptions);
|
|
9
|
+
generateBraintreeClientToken(ctx: RequestContext, { orderId, includeCustomerId }: {
|
|
10
|
+
orderId?: ID;
|
|
11
|
+
includeCustomerId?: boolean;
|
|
10
12
|
}): Promise<string>;
|
|
11
13
|
private getPaymentMethodArgs;
|
|
12
14
|
}
|
|
@@ -20,20 +20,30 @@ const braintree_common_1 = require("./braintree-common");
|
|
|
20
20
|
const braintree_handler_1 = require("./braintree.handler");
|
|
21
21
|
const constants_1 = require("./constants");
|
|
22
22
|
let BraintreeResolver = class BraintreeResolver {
|
|
23
|
-
constructor(connection, orderService, options) {
|
|
23
|
+
constructor(connection, orderService, activeOrderService, options) {
|
|
24
24
|
this.connection = connection;
|
|
25
25
|
this.orderService = orderService;
|
|
26
|
+
this.activeOrderService = activeOrderService;
|
|
26
27
|
this.options = options;
|
|
27
28
|
}
|
|
28
|
-
async generateBraintreeClientToken(ctx, { orderId }) {
|
|
29
|
+
async generateBraintreeClientToken(ctx, { orderId, includeCustomerId }) {
|
|
29
30
|
var _a;
|
|
30
|
-
|
|
31
|
+
if (orderId) {
|
|
32
|
+
core_1.Logger.warn(`The orderId argument to the generateBraintreeClientToken mutation has been deprecated and may be omitted.`);
|
|
33
|
+
}
|
|
34
|
+
const sessionOrder = await this.activeOrderService.getOrderFromContext(ctx);
|
|
35
|
+
if (!sessionOrder) {
|
|
36
|
+
throw new core_1.InternalServerError(`Cannot generate Braintree clientToken as there is no active Order.`);
|
|
37
|
+
}
|
|
38
|
+
const order = await this.orderService.findOne(ctx, sessionOrder.id);
|
|
31
39
|
if (order && order.customer) {
|
|
32
40
|
const customerId = (_a = order.customer.customFields.braintreeCustomerId) !== null && _a !== void 0 ? _a : undefined;
|
|
33
41
|
const args = await this.getPaymentMethodArgs(ctx);
|
|
34
42
|
const gateway = (0, braintree_common_1.getGateway)(args, this.options);
|
|
35
43
|
try {
|
|
36
|
-
const result = await gateway.clientToken.generate({
|
|
44
|
+
const result = await gateway.clientToken.generate({
|
|
45
|
+
customerId: includeCustomerId === false ? undefined : customerId,
|
|
46
|
+
});
|
|
37
47
|
return result.clientToken;
|
|
38
48
|
}
|
|
39
49
|
catch (e) {
|
|
@@ -65,9 +75,10 @@ __decorate([
|
|
|
65
75
|
], BraintreeResolver.prototype, "generateBraintreeClientToken", null);
|
|
66
76
|
BraintreeResolver = __decorate([
|
|
67
77
|
(0, graphql_1.Resolver)(),
|
|
68
|
-
__param(
|
|
78
|
+
__param(3, (0, common_1.Inject)(constants_1.BRAINTREE_PLUGIN_OPTIONS)),
|
|
69
79
|
__metadata("design:paramtypes", [core_1.TransactionalConnection,
|
|
70
|
-
core_1.OrderService,
|
|
80
|
+
core_1.OrderService,
|
|
81
|
+
core_1.ActiveOrderService, Object])
|
|
71
82
|
], BraintreeResolver);
|
|
72
83
|
exports.BraintreeResolver = BraintreeResolver;
|
|
73
84
|
//# sourceMappingURL=braintree.resolver.js.map
|
|
@@ -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":"","sources":["../../src/braintree/braintree.resolver.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAwC;AACxC,6CAAwD;AACxD,wCAUuB;AAEvB,yDAAgD;AAChD,2DAAoE;AACpE,2CAAkE;AAIlE,IAAa,iBAAiB,GAA9B,MAAa,iBAAiB;IAC1B,YACY,UAAmC,EACnC,YAA0B,EAC1B,kBAAsC,EACJ,OAA+B;QAHjE,eAAU,GAAV,UAAU,CAAyB;QACnC,iBAAY,GAAZ,YAAY,CAAc;QAC1B,uBAAkB,GAAlB,kBAAkB,CAAoB;QACJ,YAAO,GAAP,OAAO,CAAwB;IAC1E,CAAC;IAGJ,KAAK,CAAC,4BAA4B,CACvB,GAAmB,EAClB,EAAE,OAAO,EAAE,iBAAiB,E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,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;AApDG;IADC,IAAA,eAAK,GAAE;IAEH,WAAA,IAAA,UAAG,GAAE,CAAA;IACL,WAAA,IAAA,cAAI,GAAE,CAAA;;qCADK,qBAAc;;qEAkC7B;AA5CQ,iBAAiB;IAD7B,IAAA,kBAAQ,GAAE;IAMF,WAAA,IAAA,eAAM,EAAC,oCAAwB,CAAC,CAAA;qCAHb,8BAAuB;QACrB,mBAAY;QACN,yBAAkB;GAJzC,iBAAiB,CA6D7B;AA7DY,8CAAiB"}
|
|
@@ -1,6 +1,7 @@
|
|
|
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
6
|
export declare type PaymentMethodArgsHash = ConfigArgValues<typeof braintreePaymentMethodHandler['args']>;
|
|
6
7
|
declare module '@vendure/core/dist/entity/custom-entity-fields' {
|
|
@@ -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"}
|