@vendure/payments-plugin 2.0.0-next.1 → 2.0.0-next.10
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 +21 -7
- package/package/braintree/braintree.handler.js.map +1 -1
- package/package/braintree/braintree.plugin.d.ts +47 -5
- package/package/braintree/braintree.plugin.js +51 -9
- package/package/braintree/braintree.plugin.js.map +1 -1
- package/package/braintree/braintree.resolver.d.ts +4 -3
- package/package/braintree/braintree.resolver.js +13 -4
- package/package/braintree/braintree.resolver.js.map +1 -1
- package/package/braintree/types.d.ts +56 -1
- package/package/braintree/types.js.map +1 -1
- package/package/mollie/graphql/generated-shop-types.d.ts +1023 -997
- package/package/mollie/graphql/generated-shop-types.js +331 -306
- package/package/mollie/graphql/generated-shop-types.js.map +1 -1
- package/package/mollie/mollie-shop-schema.js +15 -15
- package/package/stripe/raw-body.middleware.js.map +1 -1
- package/package/stripe/stripe.controller.d.ts +5 -5
- package/package/stripe/stripe.controller.js +20 -15
- package/package/stripe/stripe.controller.js.map +1 -1
- package/package/stripe/stripe.service.d.ts +2 -1
- package/package/stripe/stripe.service.js +21 -1
- 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;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,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;;;;GAIG;AACH,SAAgB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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"}
|
|
@@ -27,18 +27,28 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
27
27
|
async createPayment(ctx, order, amount, args, metadata) {
|
|
28
28
|
const gateway = (0, braintree_common_1.getGateway)(args, options);
|
|
29
29
|
let customerId;
|
|
30
|
+
const { nonce, storeCardInVault } = metadata;
|
|
31
|
+
if (!nonce) {
|
|
32
|
+
return {
|
|
33
|
+
amount,
|
|
34
|
+
state: 'Error',
|
|
35
|
+
transactionId: '',
|
|
36
|
+
errorMessage: `No "nonce" value was specified in the metadata`,
|
|
37
|
+
metadata,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
30
40
|
try {
|
|
31
41
|
await entityHydrator.hydrate(ctx, order, { relations: ['customer'] });
|
|
32
42
|
const customer = order.customer;
|
|
33
43
|
if (options.storeCustomersInBraintree && ctx.activeUserId && customer) {
|
|
34
44
|
customerId = await getBraintreeCustomerId(ctx, gateway, customer);
|
|
35
45
|
}
|
|
36
|
-
return processPayment(ctx, gateway, order, amount,
|
|
46
|
+
return processPayment(ctx, gateway, order, amount, nonce, customerId, options, storeCardInVault);
|
|
37
47
|
}
|
|
38
48
|
catch (e) {
|
|
39
49
|
core_1.Logger.error(e, constants_1.loggerCtx);
|
|
40
50
|
return {
|
|
41
|
-
amount
|
|
51
|
+
amount,
|
|
42
52
|
state: 'Error',
|
|
43
53
|
transactionId: '',
|
|
44
54
|
errorMessage: e.toString(),
|
|
@@ -52,12 +62,13 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
52
62
|
};
|
|
53
63
|
},
|
|
54
64
|
async createRefund(ctx, input, total, order, payment, args) {
|
|
65
|
+
var _a;
|
|
55
66
|
const gateway = (0, braintree_common_1.getGateway)(args, options);
|
|
56
67
|
const response = await gateway.transaction.refund(payment.transactionId, (total / 100).toString(10));
|
|
57
68
|
if (!response.success) {
|
|
58
69
|
return {
|
|
59
70
|
state: 'Failed',
|
|
60
|
-
transactionId: response.transaction.id,
|
|
71
|
+
transactionId: (_a = response.transaction) === null || _a === void 0 ? void 0 : _a.id,
|
|
61
72
|
metadata: response,
|
|
62
73
|
};
|
|
63
74
|
}
|
|
@@ -68,7 +79,8 @@ exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
|
68
79
|
};
|
|
69
80
|
},
|
|
70
81
|
});
|
|
71
|
-
async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, customerId) {
|
|
82
|
+
async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, customerId, pluginOptions, storeCardInVault = true) {
|
|
83
|
+
var _a;
|
|
72
84
|
const response = await gateway.transaction.sale({
|
|
73
85
|
customerId,
|
|
74
86
|
amount: (amount / 100).toString(10),
|
|
@@ -76,23 +88,25 @@ async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, c
|
|
|
76
88
|
paymentMethodNonce,
|
|
77
89
|
options: {
|
|
78
90
|
submitForSettlement: true,
|
|
79
|
-
storeInVaultOnSuccess: !!customerId,
|
|
91
|
+
storeInVaultOnSuccess: !!customerId && storeCardInVault,
|
|
80
92
|
},
|
|
81
93
|
});
|
|
94
|
+
const extractMetadataFn = (_a = pluginOptions.extractMetadata) !== null && _a !== void 0 ? _a : braintree_common_1.defaultExtractMetadataFn;
|
|
95
|
+
const metadata = extractMetadataFn(response.transaction);
|
|
82
96
|
if (!response.success) {
|
|
83
97
|
return {
|
|
84
98
|
amount,
|
|
85
99
|
state: 'Declined',
|
|
86
100
|
transactionId: response.transaction.id,
|
|
87
101
|
errorMessage: response.message,
|
|
88
|
-
metadata
|
|
102
|
+
metadata,
|
|
89
103
|
};
|
|
90
104
|
}
|
|
91
105
|
return {
|
|
92
106
|
amount,
|
|
93
107
|
state: 'Settled',
|
|
94
108
|
transactionId: response.transaction.id,
|
|
95
|
-
metadata
|
|
109
|
+
metadata,
|
|
96
110
|
};
|
|
97
111
|
}
|
|
98
112
|
/**
|
|
@@ -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,EAA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C,SAAS;gBAC7B,QAAQ,EAAE,QAAQ,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"}
|
|
@@ -56,7 +56,7 @@ import { BraintreePluginOptions } from './types';
|
|
|
56
56
|
* 2. Use this client token to instantiate the Braintree Dropin UI.
|
|
57
57
|
* 3. Listen for the `"paymentMethodRequestable"` event which emitted by the Dropin.
|
|
58
58
|
* 4. Use the Dropin's `requestPaymentMethod()` method to get the required payment metadata.
|
|
59
|
-
* 5. Pass that metadata to the `addPaymentToOrder` mutation.
|
|
59
|
+
* 5. Pass that metadata to the `addPaymentToOrder` mutation. The metadata should be an object of type `{ nonce: string; }`
|
|
60
60
|
*
|
|
61
61
|
* Here is an example of how your storefront code will look. Note that this example is attempting to
|
|
62
62
|
* be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
|
|
@@ -122,12 +122,12 @@ import { BraintreePluginOptions } from './types';
|
|
|
122
122
|
* });
|
|
123
123
|
* }
|
|
124
124
|
*
|
|
125
|
-
* async function generateClientToken(
|
|
125
|
+
* async function generateClientToken() {
|
|
126
126
|
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
127
|
-
* query GenerateBraintreeClientToken
|
|
128
|
-
* generateBraintreeClientToken
|
|
127
|
+
* query GenerateBraintreeClientToken {
|
|
128
|
+
* generateBraintreeClientToken
|
|
129
129
|
* }
|
|
130
|
-
*
|
|
130
|
+
* `);
|
|
131
131
|
* return generateBraintreeClientToken;
|
|
132
132
|
* }
|
|
133
133
|
*
|
|
@@ -180,7 +180,49 @@ import { BraintreePluginOptions } from './types';
|
|
|
180
180
|
* dropin.clearSelectedPaymentMethod();
|
|
181
181
|
* }
|
|
182
182
|
* }
|
|
183
|
+
*
|
|
184
|
+
* ## Storing cards in the vault
|
|
185
|
+
*
|
|
186
|
+
* Braintree has a "vault" mechanism which allows it to store the credit card information for a Customer, so that on the next purchase
|
|
187
|
+
* the stored details do not need to be re-entered.
|
|
188
|
+
*
|
|
189
|
+
* To enable this feature, you need to ensure that the {@link BraintreePluginOptions} `storeCustomersInBraintree` option is set to
|
|
190
|
+
* `true`. This will allow Braintree to associate a unique ID to each of your Customers.
|
|
191
|
+
*
|
|
192
|
+
* From v1.7.0, you can then specify on a per-payment basis whether a card should be stored in the vault. By default, all cards will
|
|
193
|
+
* be automatically stored in the vault. But you can opt out of this behavior by specifying the `storeCardInVault` property in the `metadata` object
|
|
194
|
+
* supplied to the `addPaymentToOrder` mutation:
|
|
195
|
+
*
|
|
196
|
+
* @example
|
|
197
|
+
* ```TypeScript {hl_lines=[21]}
|
|
198
|
+
* const { addPaymentToOrder } = await graphQlClient.query(gql`
|
|
199
|
+
* mutation AddPayment($input: PaymentInput!) {
|
|
200
|
+
* addPaymentToOrder(input: $input) {
|
|
201
|
+
* ... on Order {
|
|
202
|
+
* id
|
|
203
|
+
* payments {
|
|
204
|
+
* id
|
|
205
|
+
* # ... etc
|
|
206
|
+
* }
|
|
207
|
+
* }
|
|
208
|
+
* ... on ErrorResult {
|
|
209
|
+
* errorCode
|
|
210
|
+
* message
|
|
211
|
+
* }
|
|
212
|
+
* }
|
|
213
|
+
* }`, {
|
|
214
|
+
* input: {
|
|
215
|
+
* method: 'braintree',
|
|
216
|
+
* metadata: {
|
|
217
|
+
* nonce: paymentResult.nonce,
|
|
218
|
+
* storeCardInVault: false,
|
|
219
|
+
* },
|
|
220
|
+
* },
|
|
221
|
+
* },
|
|
222
|
+
* );
|
|
183
223
|
* ```
|
|
224
|
+
*
|
|
225
|
+
*
|
|
184
226
|
* @docsCategory payments-plugin
|
|
185
227
|
* @docsPage BraintreePlugin
|
|
186
228
|
*/
|
|
@@ -69,7 +69,7 @@ const constants_1 = require("./constants");
|
|
|
69
69
|
* 2. Use this client token to instantiate the Braintree Dropin UI.
|
|
70
70
|
* 3. Listen for the `"paymentMethodRequestable"` event which emitted by the Dropin.
|
|
71
71
|
* 4. Use the Dropin's `requestPaymentMethod()` method to get the required payment metadata.
|
|
72
|
-
* 5. Pass that metadata to the `addPaymentToOrder` mutation.
|
|
72
|
+
* 5. Pass that metadata to the `addPaymentToOrder` mutation. The metadata should be an object of type `{ nonce: string; }`
|
|
73
73
|
*
|
|
74
74
|
* Here is an example of how your storefront code will look. Note that this example is attempting to
|
|
75
75
|
* be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
|
|
@@ -135,12 +135,12 @@ const constants_1 = require("./constants");
|
|
|
135
135
|
* });
|
|
136
136
|
* }
|
|
137
137
|
*
|
|
138
|
-
* async function generateClientToken(
|
|
138
|
+
* async function generateClientToken() {
|
|
139
139
|
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
140
|
-
* query GenerateBraintreeClientToken
|
|
141
|
-
* generateBraintreeClientToken
|
|
140
|
+
* query GenerateBraintreeClientToken {
|
|
141
|
+
* generateBraintreeClientToken
|
|
142
142
|
* }
|
|
143
|
-
*
|
|
143
|
+
* `);
|
|
144
144
|
* return generateBraintreeClientToken;
|
|
145
145
|
* }
|
|
146
146
|
*
|
|
@@ -193,7 +193,49 @@ const constants_1 = require("./constants");
|
|
|
193
193
|
* dropin.clearSelectedPaymentMethod();
|
|
194
194
|
* }
|
|
195
195
|
* }
|
|
196
|
+
*
|
|
197
|
+
* ## Storing cards in the vault
|
|
198
|
+
*
|
|
199
|
+
* Braintree has a "vault" mechanism which allows it to store the credit card information for a Customer, so that on the next purchase
|
|
200
|
+
* the stored details do not need to be re-entered.
|
|
201
|
+
*
|
|
202
|
+
* To enable this feature, you need to ensure that the {@link BraintreePluginOptions} `storeCustomersInBraintree` option is set to
|
|
203
|
+
* `true`. This will allow Braintree to associate a unique ID to each of your Customers.
|
|
204
|
+
*
|
|
205
|
+
* From v1.7.0, you can then specify on a per-payment basis whether a card should be stored in the vault. By default, all cards will
|
|
206
|
+
* be automatically stored in the vault. But you can opt out of this behavior by specifying the `storeCardInVault` property in the `metadata` object
|
|
207
|
+
* supplied to the `addPaymentToOrder` mutation:
|
|
208
|
+
*
|
|
209
|
+
* @example
|
|
210
|
+
* ```TypeScript {hl_lines=[21]}
|
|
211
|
+
* const { addPaymentToOrder } = await graphQlClient.query(gql`
|
|
212
|
+
* mutation AddPayment($input: PaymentInput!) {
|
|
213
|
+
* addPaymentToOrder(input: $input) {
|
|
214
|
+
* ... on Order {
|
|
215
|
+
* id
|
|
216
|
+
* payments {
|
|
217
|
+
* id
|
|
218
|
+
* # ... etc
|
|
219
|
+
* }
|
|
220
|
+
* }
|
|
221
|
+
* ... on ErrorResult {
|
|
222
|
+
* errorCode
|
|
223
|
+
* message
|
|
224
|
+
* }
|
|
225
|
+
* }
|
|
226
|
+
* }`, {
|
|
227
|
+
* input: {
|
|
228
|
+
* method: 'braintree',
|
|
229
|
+
* metadata: {
|
|
230
|
+
* nonce: paymentResult.nonce,
|
|
231
|
+
* storeCardInVault: false,
|
|
232
|
+
* },
|
|
233
|
+
* },
|
|
234
|
+
* },
|
|
235
|
+
* );
|
|
196
236
|
* ```
|
|
237
|
+
*
|
|
238
|
+
*
|
|
197
239
|
* @docsCategory payments-plugin
|
|
198
240
|
* @docsPage BraintreePlugin
|
|
199
241
|
*/
|
|
@@ -228,10 +270,10 @@ BraintreePlugin = BraintreePlugin_1 = __decorate([
|
|
|
228
270
|
return config;
|
|
229
271
|
},
|
|
230
272
|
shopApiExtensions: {
|
|
231
|
-
schema: (0, apollo_server_core_1.gql) `
|
|
232
|
-
extend type Query {
|
|
233
|
-
generateBraintreeClientToken(orderId: ID
|
|
234
|
-
}
|
|
273
|
+
schema: (0, apollo_server_core_1.gql) `
|
|
274
|
+
extend type Query {
|
|
275
|
+
generateBraintreeClientToken(orderId: ID): String!
|
|
276
|
+
}
|
|
235
277
|
`,
|
|
236
278
|
resolvers: [braintree_resolver_1.BraintreeResolver],
|
|
237
279
|
},
|
|
@@ -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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;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,CAM3B;AANY,0CAAe"}
|
|
@@ -1,12 +1,13 @@
|
|
|
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
|
+
constructor(connection: TransactionalConnection, orderService: OrderService, activeOrderService: ActiveOrderService, options: BraintreePluginOptions);
|
|
8
9
|
generateBraintreeClientToken(ctx: RequestContext, { orderId }: {
|
|
9
|
-
orderId
|
|
10
|
+
orderId?: ID;
|
|
10
11
|
}): Promise<string>;
|
|
11
12
|
private getPaymentMethodArgs;
|
|
12
13
|
}
|
|
@@ -20,14 +20,22 @@ 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
29
|
async generateBraintreeClientToken(ctx, { orderId }) {
|
|
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);
|
|
@@ -65,9 +73,10 @@ __decorate([
|
|
|
65
73
|
], BraintreeResolver.prototype, "generateBraintreeClientToken", null);
|
|
66
74
|
BraintreeResolver = __decorate([
|
|
67
75
|
(0, graphql_1.Resolver)(),
|
|
68
|
-
__param(
|
|
76
|
+
__param(3, (0, common_1.Inject)(constants_1.BRAINTREE_PLUGIN_OPTIONS)),
|
|
69
77
|
__metadata("design:paramtypes", [core_1.TransactionalConnection,
|
|
70
|
-
core_1.OrderService,
|
|
78
|
+
core_1.OrderService,
|
|
79
|
+
core_1.ActiveOrderService, Object])
|
|
71
80
|
], BraintreeResolver);
|
|
72
81
|
exports.BraintreeResolver = BraintreeResolver;
|
|
73
82
|
//# 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,k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M,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;AA/CG;IADC,IAAA,eAAK,GAAE;IAC4B,WAAA,IAAA,UAAG,GAAE,CAAA;IAAuB,WAAA,IAAA,cAAI,GAAE,CAAA;;qCAAvB,qBAAc;;qEA8B5D;AAvCQ,iBAAiB;IAD7B,IAAA,kBAAQ,GAAE;IAMF,WAAA,IAAA,eAAM,EAAC,oCAAwB,CAAC,CAAA;qCAHb,8BAAuB;QACrB,mBAAY;QACN,yBAAkB;GAJzC,iBAAiB,CAwD7B;AAxDY,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' {
|
|
@@ -33,4 +34,58 @@ export interface BraintreePluginOptions {
|
|
|
33
34
|
* @default false
|
|
34
35
|
*/
|
|
35
36
|
storeCustomersInBraintree?: boolean;
|
|
37
|
+
/**
|
|
38
|
+
* @description
|
|
39
|
+
* Allows you to configure exactly what information from the Braintree
|
|
40
|
+
* [Transaction object](https://developer.paypal.com/braintree/docs/reference/response/transaction#result-object] (which is returned by the
|
|
41
|
+
* `transaction.sale()` method of the SDK) should be persisted to the resulting Payment entity metadata.
|
|
42
|
+
*
|
|
43
|
+
* By default, the built-in extraction function will return a metadata object that looks like this:
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* ```TypeScript
|
|
47
|
+
* const metadata = {
|
|
48
|
+
* "status": "settling",
|
|
49
|
+
* "currencyIsoCode": "GBP",
|
|
50
|
+
* "merchantAccountId": "my_account_id",
|
|
51
|
+
* "cvvCheck": "Not Applicable",
|
|
52
|
+
* "avsPostCodeCheck": "Not Applicable",
|
|
53
|
+
* "avsStreetAddressCheck": "Not Applicable",
|
|
54
|
+
* "processorAuthorizationCode": null,
|
|
55
|
+
* "processorResponseText": "Approved",
|
|
56
|
+
* // for Paypal payments
|
|
57
|
+
* "paymentMethod": "paypal_account",
|
|
58
|
+
* "paypalData": {
|
|
59
|
+
* "payerEmail": "michael-buyer@paypalsandbox.com",
|
|
60
|
+
* "paymentId": "PAYID-MLCXYNI74301746XK8807043",
|
|
61
|
+
* "authorizationId": "3BU93594D85624939",
|
|
62
|
+
* "payerStatus": "VERIFIED",
|
|
63
|
+
* "sellerProtectionStatus": "ELIGIBLE",
|
|
64
|
+
* "transactionFeeAmount": "0.54"
|
|
65
|
+
* },
|
|
66
|
+
* // for credit card payments
|
|
67
|
+
* "paymentMethod": "credit_card",
|
|
68
|
+
* "cardData": {
|
|
69
|
+
* "cardType": "MasterCard",
|
|
70
|
+
* "last4": "5454",
|
|
71
|
+
* "expirationDate": "02/2023"
|
|
72
|
+
* }
|
|
73
|
+
* // publicly-available metadata that will be
|
|
74
|
+
* // readable from the Shop API
|
|
75
|
+
* "public": {
|
|
76
|
+
* "cardData": {
|
|
77
|
+
* "cardType": "MasterCard",
|
|
78
|
+
* "last4": "5454",
|
|
79
|
+
* "expirationDate": "02/2023"
|
|
80
|
+
* },
|
|
81
|
+
* "paypalData": {
|
|
82
|
+
* "authorizationId": "3BU93594D85624939",
|
|
83
|
+
* }
|
|
84
|
+
* }
|
|
85
|
+
* }
|
|
86
|
+
* ```
|
|
87
|
+
*
|
|
88
|
+
* @since 1.7.0
|
|
89
|
+
*/
|
|
90
|
+
extractMetadata?: (transaction: Transaction) => PaymentMetadata;
|
|
36
91
|
}
|
|
@@ -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"}
|