@vendure/payments-plugin 1.3.3 → 1.4.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/package/braintree/braintree-common.d.ts +2 -2
- package/package/braintree/braintree-common.js +2 -2
- package/package/braintree/braintree-common.js.map +1 -1
- package/package/braintree/braintree.handler.d.ts +28 -0
- package/package/braintree/braintree.handler.js +129 -0
- package/package/braintree/braintree.handler.js.map +1 -0
- package/package/braintree/braintree.plugin.d.ts +190 -0
- package/package/braintree/braintree.plugin.js +241 -0
- package/package/braintree/braintree.plugin.js.map +1 -0
- package/package/braintree/braintree.resolver.d.ts +4 -2
- package/package/braintree/braintree.resolver.js +14 -10
- package/package/braintree/braintree.resolver.js.map +1 -1
- package/package/braintree/constants.d.ts +1 -0
- package/package/braintree/constants.js +2 -1
- package/package/braintree/constants.js.map +1 -1
- package/package/braintree/index.d.ts +3 -2
- package/package/braintree/index.js +3 -2
- package/package/braintree/index.js.map +1 -1
- package/package/braintree/types.d.ts +33 -1
- package/package/index.d.ts +1 -1
- package/package/index.js +1 -1
- package/package/mollie/constants.d.ts +2 -0
- package/package/mollie/constants.js +6 -0
- package/package/mollie/constants.js.map +1 -0
- package/package/mollie/index.d.ts +2 -0
- package/package/mollie/index.js +15 -0
- package/package/mollie/index.js.map +1 -0
- package/package/mollie/mollie.controller.d.ts +10 -0
- package/package/mollie/mollie.controller.js +101 -0
- package/package/mollie/mollie.controller.js.map +1 -0
- package/package/mollie/mollie.handler.d.ts +18 -0
- package/package/mollie/mollie.handler.js +127 -0
- package/package/mollie/mollie.handler.js.map +1 -0
- package/package/mollie/mollie.plugin.d.ts +101 -0
- package/package/mollie/mollie.plugin.js +116 -0
- package/package/mollie/mollie.plugin.js.map +1 -0
- package/package.json +37 -29
- package/package/braintree/braintree-payment-method.d.ts +0 -15
- package/package/braintree/braintree-payment-method.js +0 -79
- package/package/braintree/braintree-payment-method.js.map +0 -1
- package/package/braintree/braintree-plugin.d.ts +0 -5
- package/package/braintree/braintree-plugin.js +0 -38
- package/package/braintree/braintree-plugin.js.map +0 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BraintreeGateway, Transaction } from 'braintree';
|
|
2
|
-
import { PaymentMethodArgsHash } from './types';
|
|
3
|
-
export declare function getGateway(args: PaymentMethodArgsHash): BraintreeGateway;
|
|
2
|
+
import { BraintreePluginOptions, PaymentMethodArgsHash } from './types';
|
|
3
|
+
export declare function getGateway(args: PaymentMethodArgsHash, options: BraintreePluginOptions): BraintreeGateway;
|
|
4
4
|
/**
|
|
5
5
|
* Returns a subset of the Transaction object of interest to the Administrator.
|
|
6
6
|
*/
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.extractMetadataFromTransaction = exports.getGateway = void 0;
|
|
4
4
|
const braintree_1 = require("braintree");
|
|
5
|
-
function getGateway(args) {
|
|
5
|
+
function getGateway(args, options) {
|
|
6
6
|
return new braintree_1.BraintreeGateway({
|
|
7
|
-
environment: braintree_1.Environment.Sandbox,
|
|
7
|
+
environment: options.environment || braintree_1.Environment.Sandbox,
|
|
8
8
|
merchantId: args.merchantId,
|
|
9
9
|
privateKey: args.privateKey,
|
|
10
10
|
publicKey: args.publicKey,
|
|
@@ -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;
|
|
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,CAA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sBAAsB;YACxE,oBAAoB,EAAE,WAAW,CAAC,aAAa,CAAC,oBAAoB;SACvE,CAAC;KACL;IACD,OAAO,QAAQ,CAAC;AACpB,CAAC;AA9BD,wEA8BC;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"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { LanguageCode } from '@vendure/common/lib/generated-types';
|
|
2
|
+
import { PaymentMethodHandler } from '@vendure/core';
|
|
3
|
+
/**
|
|
4
|
+
* The handler for Braintree payments.
|
|
5
|
+
*/
|
|
6
|
+
export declare const braintreePaymentMethodHandler: PaymentMethodHandler<{
|
|
7
|
+
merchantId: {
|
|
8
|
+
type: "string";
|
|
9
|
+
label: {
|
|
10
|
+
languageCode: LanguageCode.en;
|
|
11
|
+
value: string;
|
|
12
|
+
}[];
|
|
13
|
+
};
|
|
14
|
+
publicKey: {
|
|
15
|
+
type: "string";
|
|
16
|
+
label: {
|
|
17
|
+
languageCode: LanguageCode.en;
|
|
18
|
+
value: string;
|
|
19
|
+
}[];
|
|
20
|
+
};
|
|
21
|
+
privateKey: {
|
|
22
|
+
type: "string";
|
|
23
|
+
label: {
|
|
24
|
+
languageCode: LanguageCode.en;
|
|
25
|
+
value: string;
|
|
26
|
+
}[];
|
|
27
|
+
};
|
|
28
|
+
}>;
|
|
@@ -0,0 +1,129 @@
|
|
|
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
|
+
let options;
|
|
9
|
+
let connection;
|
|
10
|
+
let entityHydrator;
|
|
11
|
+
/**
|
|
12
|
+
* The handler for Braintree payments.
|
|
13
|
+
*/
|
|
14
|
+
exports.braintreePaymentMethodHandler = new core_1.PaymentMethodHandler({
|
|
15
|
+
code: 'braintree',
|
|
16
|
+
description: [{ languageCode: generated_types_1.LanguageCode.en, value: 'Braintree payments' }],
|
|
17
|
+
args: {
|
|
18
|
+
merchantId: { type: 'string', label: [{ languageCode: generated_types_1.LanguageCode.en, value: 'Merchant ID' }] },
|
|
19
|
+
publicKey: { type: 'string', label: [{ languageCode: generated_types_1.LanguageCode.en, value: 'Public Key' }] },
|
|
20
|
+
privateKey: { type: 'string', label: [{ languageCode: generated_types_1.LanguageCode.en, value: 'Private Key' }] },
|
|
21
|
+
},
|
|
22
|
+
init(injector) {
|
|
23
|
+
options = injector.get(constants_1.BRAINTREE_PLUGIN_OPTIONS);
|
|
24
|
+
connection = injector.get(core_1.TransactionalConnection);
|
|
25
|
+
entityHydrator = injector.get(core_1.EntityHydrator);
|
|
26
|
+
},
|
|
27
|
+
async createPayment(ctx, order, amount, args, metadata) {
|
|
28
|
+
const gateway = braintree_common_1.getGateway(args, options);
|
|
29
|
+
let customerId;
|
|
30
|
+
try {
|
|
31
|
+
await entityHydrator.hydrate(ctx, order, { relations: ['customer'] });
|
|
32
|
+
const customer = order.customer;
|
|
33
|
+
if (options.storeCustomersInBraintree && ctx.activeUserId && customer) {
|
|
34
|
+
customerId = await getBraintreeCustomerId(ctx, gateway, customer);
|
|
35
|
+
}
|
|
36
|
+
return processPayment(ctx, gateway, order, amount, metadata.nonce, customerId);
|
|
37
|
+
}
|
|
38
|
+
catch (e) {
|
|
39
|
+
core_1.Logger.error(e, constants_1.loggerCtx);
|
|
40
|
+
return {
|
|
41
|
+
amount: order.total,
|
|
42
|
+
state: 'Error',
|
|
43
|
+
transactionId: '',
|
|
44
|
+
errorMessage: e.toString(),
|
|
45
|
+
metadata: e,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
settlePayment() {
|
|
50
|
+
return {
|
|
51
|
+
success: true,
|
|
52
|
+
};
|
|
53
|
+
},
|
|
54
|
+
async createRefund(ctx, input, total, order, payment, args) {
|
|
55
|
+
const gateway = braintree_common_1.getGateway(args, options);
|
|
56
|
+
const response = await gateway.transaction.refund(payment.transactionId, (total / 100).toString(10));
|
|
57
|
+
if (!response.success) {
|
|
58
|
+
return {
|
|
59
|
+
state: 'Failed',
|
|
60
|
+
transactionId: response.transaction.id,
|
|
61
|
+
metadata: response,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
return {
|
|
65
|
+
state: 'Settled',
|
|
66
|
+
transactionId: response.transaction.id,
|
|
67
|
+
metadata: response,
|
|
68
|
+
};
|
|
69
|
+
},
|
|
70
|
+
});
|
|
71
|
+
async function processPayment(ctx, gateway, order, amount, paymentMethodNonce, customerId) {
|
|
72
|
+
const response = await gateway.transaction.sale({
|
|
73
|
+
customerId,
|
|
74
|
+
amount: (amount / 100).toString(10),
|
|
75
|
+
orderId: order.code,
|
|
76
|
+
paymentMethodNonce,
|
|
77
|
+
options: {
|
|
78
|
+
submitForSettlement: true,
|
|
79
|
+
storeInVaultOnSuccess: !!customerId,
|
|
80
|
+
},
|
|
81
|
+
});
|
|
82
|
+
if (!response.success) {
|
|
83
|
+
return {
|
|
84
|
+
amount,
|
|
85
|
+
state: 'Declined',
|
|
86
|
+
transactionId: response.transaction.id,
|
|
87
|
+
errorMessage: response.message,
|
|
88
|
+
metadata: braintree_common_1.extractMetadataFromTransaction(response.transaction),
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
amount,
|
|
93
|
+
state: 'Settled',
|
|
94
|
+
transactionId: response.transaction.id,
|
|
95
|
+
metadata: braintree_common_1.extractMetadataFromTransaction(response.transaction),
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* If the Customer has no braintreeCustomerId, create one, else return the existing braintreeCustomerId.
|
|
100
|
+
*/
|
|
101
|
+
async function getBraintreeCustomerId(ctx, gateway, customer) {
|
|
102
|
+
if (!customer.customFields.braintreeCustomerId) {
|
|
103
|
+
try {
|
|
104
|
+
const result = await gateway.customer.create({
|
|
105
|
+
firstName: customer.firstName,
|
|
106
|
+
lastName: customer.lastName,
|
|
107
|
+
email: customer.emailAddress,
|
|
108
|
+
});
|
|
109
|
+
if (result.success) {
|
|
110
|
+
const customerId = result.customer.id;
|
|
111
|
+
core_1.Logger.verbose(`Created Braintree Customer record for customerId ${customer.id}`, constants_1.loggerCtx);
|
|
112
|
+
customer.customFields.braintreeCustomerId = customerId;
|
|
113
|
+
await connection.getRepository(ctx, core_1.Customer).save(customer, { reload: false });
|
|
114
|
+
return customerId;
|
|
115
|
+
}
|
|
116
|
+
else {
|
|
117
|
+
core_1.Logger.error(`Failed to create Braintree Customer record for customerId ${customer.id}. View Debug level logs for details.`, constants_1.loggerCtx);
|
|
118
|
+
core_1.Logger.debug(JSON.stringify(result.errors, null, 2), constants_1.loggerCtx);
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
core_1.Logger.error(e.message, constants_1.loggerCtx, e.stack);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
else {
|
|
126
|
+
return customer.customFields.braintreeCustomerId;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
//# sourceMappingURL=braintree.handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file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ugin enables payments to be processed by [Braintree](https://www.braintreepayments.com/), a popular payment provider.
|
|
6
|
+
*
|
|
7
|
+
* ## Requirements
|
|
8
|
+
*
|
|
9
|
+
* 1. You will need to create a Braintree sandbox account as outlined in https://developers.braintreepayments.com/start/overview.
|
|
10
|
+
* 2. Then install `braintree` and `@types/braintree` from npm. This plugin was written with `v3.x` of the Braintree lib.
|
|
11
|
+
* ```shell
|
|
12
|
+
* yarn add \@vendure/payments-plugin braintree
|
|
13
|
+
* yarn add -D \@types/braintree
|
|
14
|
+
* ```
|
|
15
|
+
* or
|
|
16
|
+
* ```shell
|
|
17
|
+
* npm install \@vendure/payments-plugin braintree
|
|
18
|
+
* npm install -D \@types/braintree
|
|
19
|
+
* ```
|
|
20
|
+
*
|
|
21
|
+
* ## Setup
|
|
22
|
+
*
|
|
23
|
+
* 1. Add the plugin to your VendureConfig `plugins` array:
|
|
24
|
+
* ```TypeScript
|
|
25
|
+
* import { BraintreePlugin } from '\@vendure/payments-plugin/package/braintree';
|
|
26
|
+
* import { Environment } from 'braintree';
|
|
27
|
+
*
|
|
28
|
+
* // ...
|
|
29
|
+
*
|
|
30
|
+
* plugins: [
|
|
31
|
+
* BraintreePlugin.init({
|
|
32
|
+
* environment: Environment.Sandbox,
|
|
33
|
+
* // This allows saving customer payment
|
|
34
|
+
* // methods with Braintree
|
|
35
|
+
* storeCustomersInBraintree: true,
|
|
36
|
+
* }),
|
|
37
|
+
* ]
|
|
38
|
+
* ```
|
|
39
|
+
* 2. Create a new PaymentMethod in the Admin UI, and select "Braintree payments" as the handler.
|
|
40
|
+
* 2. Fill in the `Merchant ID`, `Public Key` & `Private Key` from your Braintree sandbox account.
|
|
41
|
+
*
|
|
42
|
+
* ## Storefront usage
|
|
43
|
+
*
|
|
44
|
+
* The plugin is designed to work with the [Braintree drop-in UI](https://developers.braintreepayments.com/guides/drop-in/overview/javascript/v3).
|
|
45
|
+
* This is a library provided by Braintree which will handle the payment UI for you. You can install it in your storefront project
|
|
46
|
+
* with:
|
|
47
|
+
*
|
|
48
|
+
* ```shell
|
|
49
|
+
* yarn add braintree-web-drop-in
|
|
50
|
+
* # or
|
|
51
|
+
* npm install braintree-web-drop-in
|
|
52
|
+
* ```
|
|
53
|
+
*
|
|
54
|
+
* The high-level workflow is:
|
|
55
|
+
* 1. Generate a "client token" on the server by executing the `generateBraintreeClientToken` mutation which is exposed by this plugin.
|
|
56
|
+
* 2. Use this client token to instantiate the Braintree Dropin UI.
|
|
57
|
+
* 3. Listen for the `"paymentMethodRequestable"` event which emitted by the Dropin.
|
|
58
|
+
* 4. Use the Dropin's `requestPaymentMethod()` method to get the required payment metadata.
|
|
59
|
+
* 5. Pass that metadata to the `addPaymentToOrder` mutation.
|
|
60
|
+
*
|
|
61
|
+
* Here is an example of how your storefront code will look. Note that this example is attempting to
|
|
62
|
+
* be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
|
|
63
|
+
*
|
|
64
|
+
* ```TypeScript
|
|
65
|
+
* // The Braintree Dropin instance
|
|
66
|
+
* let dropin: import('braintree-web-drop-in').Dropin;
|
|
67
|
+
*
|
|
68
|
+
* // Used to show/hide a "submit" button, which would be bound to the
|
|
69
|
+
* // `submitPayment()` method below.
|
|
70
|
+
* let showSubmitButton = false;
|
|
71
|
+
*
|
|
72
|
+
* // Used to display a "processing..." spinner
|
|
73
|
+
* let processing = false;
|
|
74
|
+
*
|
|
75
|
+
* //
|
|
76
|
+
* // This method would be invoked when the payment screen is mounted/created.
|
|
77
|
+
* //
|
|
78
|
+
* async function renderDropin(order: Order, clientToken: string) {
|
|
79
|
+
* // Lazy load braintree dropin because it has a reference
|
|
80
|
+
* // to `window` which breaks SSR
|
|
81
|
+
* dropin = await import('braintree-web-drop-in').then((module) =>
|
|
82
|
+
* module.default.create({
|
|
83
|
+
* authorization: clientToken,
|
|
84
|
+
* // This assumes a div in your view with the corresponding ID
|
|
85
|
+
* container: '#dropin-container',
|
|
86
|
+
* card: {
|
|
87
|
+
* cardholderName: {
|
|
88
|
+
* required: true,
|
|
89
|
+
* },
|
|
90
|
+
* overrides: {},
|
|
91
|
+
* },
|
|
92
|
+
* // Additional config is passed here depending on
|
|
93
|
+
* // which payment methods you have enabled in your
|
|
94
|
+
* // Braintree account.
|
|
95
|
+
* paypal: {
|
|
96
|
+
* flow: 'checkout',
|
|
97
|
+
* amount: order.totalWithTax,
|
|
98
|
+
* currency: 'GBP',
|
|
99
|
+
* },
|
|
100
|
+
* }),
|
|
101
|
+
* );
|
|
102
|
+
*
|
|
103
|
+
* // If you are using the `storeCustomersInBraintree` option, then the
|
|
104
|
+
* // customer might already have a stored payment method selected as
|
|
105
|
+
* // soon as the dropin script loads. In this case, show the submit
|
|
106
|
+
* // button immediately.
|
|
107
|
+
* if (dropin.isPaymentMethodRequestable()) {
|
|
108
|
+
* showSubmitButton = true;
|
|
109
|
+
* }
|
|
110
|
+
*
|
|
111
|
+
* dropin.on('paymentMethodRequestable', (payload) => {
|
|
112
|
+
* if (payload.type === 'CreditCard') {
|
|
113
|
+
* showSubmitButton = true;
|
|
114
|
+
* }
|
|
115
|
+
* if (payload.type === 'PayPalAccount') {
|
|
116
|
+
* this.submitPayment();
|
|
117
|
+
* }
|
|
118
|
+
* });
|
|
119
|
+
*
|
|
120
|
+
* dropin.on('noPaymentMethodRequestable', () => {
|
|
121
|
+
* // Display an error
|
|
122
|
+
* });
|
|
123
|
+
* }
|
|
124
|
+
*
|
|
125
|
+
* async function generateClientToken(orderId: string) {
|
|
126
|
+
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
127
|
+
* query GenerateBraintreeClientToken($orderId: ID!) {
|
|
128
|
+
* generateBraintreeClientToken(orderId: $orderId)
|
|
129
|
+
* }
|
|
130
|
+
* `, { orderId });
|
|
131
|
+
* return generateBraintreeClientToken;
|
|
132
|
+
* }
|
|
133
|
+
*
|
|
134
|
+
* async submitPayment() {
|
|
135
|
+
* if (!dropin.isPaymentMethodRequestable()) {
|
|
136
|
+
* return;
|
|
137
|
+
* }
|
|
138
|
+
* showSubmitButton = false;
|
|
139
|
+
* processing = true;
|
|
140
|
+
*
|
|
141
|
+
* const paymentResult = await dropin.requestPaymentMethod();
|
|
142
|
+
*
|
|
143
|
+
* const { addPaymentToOrder } = await graphQlClient.query(gql`
|
|
144
|
+
* mutation AddPayment($input: PaymentInput!) {
|
|
145
|
+
* addPaymentToOrder(input: $input) {
|
|
146
|
+
* ... on Order {
|
|
147
|
+
* id
|
|
148
|
+
* payments {
|
|
149
|
+
* id
|
|
150
|
+
* amount
|
|
151
|
+
* errorMessage
|
|
152
|
+
* method
|
|
153
|
+
* state
|
|
154
|
+
* transactionId
|
|
155
|
+
* createdAt
|
|
156
|
+
* }
|
|
157
|
+
* }
|
|
158
|
+
* ... on ErrorResult {
|
|
159
|
+
* errorCode
|
|
160
|
+
* message
|
|
161
|
+
* }
|
|
162
|
+
* }
|
|
163
|
+
* }`, {
|
|
164
|
+
* input: {
|
|
165
|
+
* method: 'braintree', // The code of you Braintree PaymentMethod
|
|
166
|
+
* metadata: paymentResult,
|
|
167
|
+
* },
|
|
168
|
+
* },
|
|
169
|
+
* );
|
|
170
|
+
*
|
|
171
|
+
* switch (addPaymentToOrder?.__typename) {
|
|
172
|
+
* case 'Order':
|
|
173
|
+
* // Adding payment succeeded!
|
|
174
|
+
* break;
|
|
175
|
+
* case 'OrderStateTransitionError':
|
|
176
|
+
* case 'OrderPaymentStateError':
|
|
177
|
+
* case 'PaymentDeclinedError':
|
|
178
|
+
* case 'PaymentFailedError':
|
|
179
|
+
* // Display an error to the customer
|
|
180
|
+
* dropin.clearSelectedPaymentMethod();
|
|
181
|
+
* }
|
|
182
|
+
* }
|
|
183
|
+
* ```
|
|
184
|
+
* @docsCategory payments-plugin
|
|
185
|
+
* @docsPage BraintreePlugin
|
|
186
|
+
*/
|
|
187
|
+
export declare class BraintreePlugin {
|
|
188
|
+
static options: BraintreePluginOptions;
|
|
189
|
+
static init(options: BraintreePluginOptions): Type<BraintreePlugin>;
|
|
190
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
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 BraintreePlugin_1;
|
|
9
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
+
exports.BraintreePlugin = void 0;
|
|
11
|
+
const core_1 = require("@vendure/core");
|
|
12
|
+
const apollo_server_core_1 = require("apollo-server-core");
|
|
13
|
+
const braintree_handler_1 = require("./braintree.handler");
|
|
14
|
+
const braintree_resolver_1 = require("./braintree.resolver");
|
|
15
|
+
const constants_1 = require("./constants");
|
|
16
|
+
/**
|
|
17
|
+
* @description
|
|
18
|
+
* This plugin enables payments to be processed by [Braintree](https://www.braintreepayments.com/), a popular payment provider.
|
|
19
|
+
*
|
|
20
|
+
* ## Requirements
|
|
21
|
+
*
|
|
22
|
+
* 1. You will need to create a Braintree sandbox account as outlined in https://developers.braintreepayments.com/start/overview.
|
|
23
|
+
* 2. Then install `braintree` and `@types/braintree` from npm. This plugin was written with `v3.x` of the Braintree lib.
|
|
24
|
+
* ```shell
|
|
25
|
+
* yarn add \@vendure/payments-plugin braintree
|
|
26
|
+
* yarn add -D \@types/braintree
|
|
27
|
+
* ```
|
|
28
|
+
* or
|
|
29
|
+
* ```shell
|
|
30
|
+
* npm install \@vendure/payments-plugin braintree
|
|
31
|
+
* npm install -D \@types/braintree
|
|
32
|
+
* ```
|
|
33
|
+
*
|
|
34
|
+
* ## Setup
|
|
35
|
+
*
|
|
36
|
+
* 1. Add the plugin to your VendureConfig `plugins` array:
|
|
37
|
+
* ```TypeScript
|
|
38
|
+
* import { BraintreePlugin } from '\@vendure/payments-plugin/package/braintree';
|
|
39
|
+
* import { Environment } from 'braintree';
|
|
40
|
+
*
|
|
41
|
+
* // ...
|
|
42
|
+
*
|
|
43
|
+
* plugins: [
|
|
44
|
+
* BraintreePlugin.init({
|
|
45
|
+
* environment: Environment.Sandbox,
|
|
46
|
+
* // This allows saving customer payment
|
|
47
|
+
* // methods with Braintree
|
|
48
|
+
* storeCustomersInBraintree: true,
|
|
49
|
+
* }),
|
|
50
|
+
* ]
|
|
51
|
+
* ```
|
|
52
|
+
* 2. Create a new PaymentMethod in the Admin UI, and select "Braintree payments" as the handler.
|
|
53
|
+
* 2. Fill in the `Merchant ID`, `Public Key` & `Private Key` from your Braintree sandbox account.
|
|
54
|
+
*
|
|
55
|
+
* ## Storefront usage
|
|
56
|
+
*
|
|
57
|
+
* The plugin is designed to work with the [Braintree drop-in UI](https://developers.braintreepayments.com/guides/drop-in/overview/javascript/v3).
|
|
58
|
+
* This is a library provided by Braintree which will handle the payment UI for you. You can install it in your storefront project
|
|
59
|
+
* with:
|
|
60
|
+
*
|
|
61
|
+
* ```shell
|
|
62
|
+
* yarn add braintree-web-drop-in
|
|
63
|
+
* # or
|
|
64
|
+
* npm install braintree-web-drop-in
|
|
65
|
+
* ```
|
|
66
|
+
*
|
|
67
|
+
* The high-level workflow is:
|
|
68
|
+
* 1. Generate a "client token" on the server by executing the `generateBraintreeClientToken` mutation which is exposed by this plugin.
|
|
69
|
+
* 2. Use this client token to instantiate the Braintree Dropin UI.
|
|
70
|
+
* 3. Listen for the `"paymentMethodRequestable"` event which emitted by the Dropin.
|
|
71
|
+
* 4. Use the Dropin's `requestPaymentMethod()` method to get the required payment metadata.
|
|
72
|
+
* 5. Pass that metadata to the `addPaymentToOrder` mutation.
|
|
73
|
+
*
|
|
74
|
+
* Here is an example of how your storefront code will look. Note that this example is attempting to
|
|
75
|
+
* be framework-agnostic, so you'll need to adapt it to fit to your framework of choice.
|
|
76
|
+
*
|
|
77
|
+
* ```TypeScript
|
|
78
|
+
* // The Braintree Dropin instance
|
|
79
|
+
* let dropin: import('braintree-web-drop-in').Dropin;
|
|
80
|
+
*
|
|
81
|
+
* // Used to show/hide a "submit" button, which would be bound to the
|
|
82
|
+
* // `submitPayment()` method below.
|
|
83
|
+
* let showSubmitButton = false;
|
|
84
|
+
*
|
|
85
|
+
* // Used to display a "processing..." spinner
|
|
86
|
+
* let processing = false;
|
|
87
|
+
*
|
|
88
|
+
* //
|
|
89
|
+
* // This method would be invoked when the payment screen is mounted/created.
|
|
90
|
+
* //
|
|
91
|
+
* async function renderDropin(order: Order, clientToken: string) {
|
|
92
|
+
* // Lazy load braintree dropin because it has a reference
|
|
93
|
+
* // to `window` which breaks SSR
|
|
94
|
+
* dropin = await import('braintree-web-drop-in').then((module) =>
|
|
95
|
+
* module.default.create({
|
|
96
|
+
* authorization: clientToken,
|
|
97
|
+
* // This assumes a div in your view with the corresponding ID
|
|
98
|
+
* container: '#dropin-container',
|
|
99
|
+
* card: {
|
|
100
|
+
* cardholderName: {
|
|
101
|
+
* required: true,
|
|
102
|
+
* },
|
|
103
|
+
* overrides: {},
|
|
104
|
+
* },
|
|
105
|
+
* // Additional config is passed here depending on
|
|
106
|
+
* // which payment methods you have enabled in your
|
|
107
|
+
* // Braintree account.
|
|
108
|
+
* paypal: {
|
|
109
|
+
* flow: 'checkout',
|
|
110
|
+
* amount: order.totalWithTax,
|
|
111
|
+
* currency: 'GBP',
|
|
112
|
+
* },
|
|
113
|
+
* }),
|
|
114
|
+
* );
|
|
115
|
+
*
|
|
116
|
+
* // If you are using the `storeCustomersInBraintree` option, then the
|
|
117
|
+
* // customer might already have a stored payment method selected as
|
|
118
|
+
* // soon as the dropin script loads. In this case, show the submit
|
|
119
|
+
* // button immediately.
|
|
120
|
+
* if (dropin.isPaymentMethodRequestable()) {
|
|
121
|
+
* showSubmitButton = true;
|
|
122
|
+
* }
|
|
123
|
+
*
|
|
124
|
+
* dropin.on('paymentMethodRequestable', (payload) => {
|
|
125
|
+
* if (payload.type === 'CreditCard') {
|
|
126
|
+
* showSubmitButton = true;
|
|
127
|
+
* }
|
|
128
|
+
* if (payload.type === 'PayPalAccount') {
|
|
129
|
+
* this.submitPayment();
|
|
130
|
+
* }
|
|
131
|
+
* });
|
|
132
|
+
*
|
|
133
|
+
* dropin.on('noPaymentMethodRequestable', () => {
|
|
134
|
+
* // Display an error
|
|
135
|
+
* });
|
|
136
|
+
* }
|
|
137
|
+
*
|
|
138
|
+
* async function generateClientToken(orderId: string) {
|
|
139
|
+
* const { generateBraintreeClientToken } = await graphQlClient.query(gql`
|
|
140
|
+
* query GenerateBraintreeClientToken($orderId: ID!) {
|
|
141
|
+
* generateBraintreeClientToken(orderId: $orderId)
|
|
142
|
+
* }
|
|
143
|
+
* `, { orderId });
|
|
144
|
+
* return generateBraintreeClientToken;
|
|
145
|
+
* }
|
|
146
|
+
*
|
|
147
|
+
* async submitPayment() {
|
|
148
|
+
* if (!dropin.isPaymentMethodRequestable()) {
|
|
149
|
+
* return;
|
|
150
|
+
* }
|
|
151
|
+
* showSubmitButton = false;
|
|
152
|
+
* processing = true;
|
|
153
|
+
*
|
|
154
|
+
* const paymentResult = await dropin.requestPaymentMethod();
|
|
155
|
+
*
|
|
156
|
+
* const { addPaymentToOrder } = await graphQlClient.query(gql`
|
|
157
|
+
* mutation AddPayment($input: PaymentInput!) {
|
|
158
|
+
* addPaymentToOrder(input: $input) {
|
|
159
|
+
* ... on Order {
|
|
160
|
+
* id
|
|
161
|
+
* payments {
|
|
162
|
+
* id
|
|
163
|
+
* amount
|
|
164
|
+
* errorMessage
|
|
165
|
+
* method
|
|
166
|
+
* state
|
|
167
|
+
* transactionId
|
|
168
|
+
* createdAt
|
|
169
|
+
* }
|
|
170
|
+
* }
|
|
171
|
+
* ... on ErrorResult {
|
|
172
|
+
* errorCode
|
|
173
|
+
* message
|
|
174
|
+
* }
|
|
175
|
+
* }
|
|
176
|
+
* }`, {
|
|
177
|
+
* input: {
|
|
178
|
+
* method: 'braintree', // The code of you Braintree PaymentMethod
|
|
179
|
+
* metadata: paymentResult,
|
|
180
|
+
* },
|
|
181
|
+
* },
|
|
182
|
+
* );
|
|
183
|
+
*
|
|
184
|
+
* switch (addPaymentToOrder?.__typename) {
|
|
185
|
+
* case 'Order':
|
|
186
|
+
* // Adding payment succeeded!
|
|
187
|
+
* break;
|
|
188
|
+
* case 'OrderStateTransitionError':
|
|
189
|
+
* case 'OrderPaymentStateError':
|
|
190
|
+
* case 'PaymentDeclinedError':
|
|
191
|
+
* case 'PaymentFailedError':
|
|
192
|
+
* // Display an error to the customer
|
|
193
|
+
* dropin.clearSelectedPaymentMethod();
|
|
194
|
+
* }
|
|
195
|
+
* }
|
|
196
|
+
* ```
|
|
197
|
+
* @docsCategory payments-plugin
|
|
198
|
+
* @docsPage BraintreePlugin
|
|
199
|
+
*/
|
|
200
|
+
let BraintreePlugin = BraintreePlugin_1 = class BraintreePlugin {
|
|
201
|
+
static init(options) {
|
|
202
|
+
this.options = options;
|
|
203
|
+
return BraintreePlugin_1;
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
BraintreePlugin.options = {};
|
|
207
|
+
BraintreePlugin = BraintreePlugin_1 = __decorate([
|
|
208
|
+
core_1.VendurePlugin({
|
|
209
|
+
imports: [core_1.PluginCommonModule],
|
|
210
|
+
providers: [
|
|
211
|
+
{
|
|
212
|
+
provide: constants_1.BRAINTREE_PLUGIN_OPTIONS,
|
|
213
|
+
useFactory: () => BraintreePlugin_1.options,
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
configuration: config => {
|
|
217
|
+
config.paymentOptions.paymentMethodHandlers.push(braintree_handler_1.braintreePaymentMethodHandler);
|
|
218
|
+
if (BraintreePlugin_1.options.storeCustomersInBraintree === true) {
|
|
219
|
+
config.customFields.Customer.push({
|
|
220
|
+
name: 'braintreeCustomerId',
|
|
221
|
+
type: 'string',
|
|
222
|
+
label: [{ languageCode: core_1.LanguageCode.en, value: 'Braintree Customer ID' }],
|
|
223
|
+
nullable: true,
|
|
224
|
+
public: false,
|
|
225
|
+
readonly: true,
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
return config;
|
|
229
|
+
},
|
|
230
|
+
shopApiExtensions: {
|
|
231
|
+
schema: apollo_server_core_1.gql `
|
|
232
|
+
extend type Query {
|
|
233
|
+
generateBraintreeClientToken(orderId: ID!): String!
|
|
234
|
+
}
|
|
235
|
+
`,
|
|
236
|
+
resolvers: [braintree_resolver_1.BraintreeResolver],
|
|
237
|
+
},
|
|
238
|
+
})
|
|
239
|
+
], BraintreePlugin);
|
|
240
|
+
exports.BraintreePlugin = BraintreePlugin;
|
|
241
|
+
//# sourceMappingURL=braintree.plugin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"braintree.plugin.js","sourceRoot":"","sources":["../../src/braintree/braintree.plugin.ts"],"names":[],"mappings":";;;;;;;;;;AAAA,wCAAsF;AACtF,2DAAyC;AAEzC,2DAAoE;AACpE,6DAAyD;AACzD,2CAAuD;AAGvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAuLG;AAgCH,IAAa,eAAe,uBAA5B,MAAa,eAAe;IAExB,MAAM,CAAC,IAAI,CAAC,OAA+B;QACvC,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,OAAO,iBAAe,CAAC;IAC3B,CAAC;CACJ,CAAA;AALU,uBAAO,GAA2B,EAAE,CAAC;AADnC,eAAe;IA/B3B,oBAAa,CAAC;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,wBAAG,CAAA;;;;SAIV;YACD,SAAS,EAAE,CAAC,sCAAiB,CAAC;SACjC;KACJ,CAAC;GACW,eAAe,CAM3B;AANY,0CAAe"}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ID, OrderService, RequestContext, TransactionalConnection } from '@vendure/core';
|
|
2
|
+
import { BraintreePluginOptions } from './types';
|
|
2
3
|
export declare class BraintreeResolver {
|
|
3
4
|
private connection;
|
|
4
5
|
private orderService;
|
|
5
|
-
|
|
6
|
+
private options;
|
|
7
|
+
constructor(connection: TransactionalConnection, orderService: OrderService, options: BraintreePluginOptions);
|
|
6
8
|
generateBraintreeClientToken(ctx: RequestContext, { orderId }: {
|
|
7
9
|
orderId: ID;
|
|
8
|
-
}): Promise<string
|
|
10
|
+
}): Promise<string>;
|
|
9
11
|
private getPaymentMethodArgs;
|
|
10
12
|
}
|