Skip to content

Commit 6fe1782

Browse files
allow for description for payment intents
1 parent 3942580 commit 6fe1782

File tree

2 files changed

+24
-2
lines changed

2 files changed

+24
-2
lines changed

src/routes/customerPayment/create.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const permissions = tcMiddleware.permissions;
1313
const schema = {
1414
body: Joi.object().keys({
1515
receiptEmail: Joi.string().email(),
16+
description: Joi.string(),
1617
amount: Joi.number().integer().min(1).required(),
1718
currency: Joi.string().valid(_.values(CUSTOMER_PAYMENT_CURRENCY)).default(CUSTOMER_PAYMENT_CURRENCY.USD),
1819
paymentMethodId: Joi.string().required(),
@@ -25,14 +26,23 @@ module.exports = [
2526
validate(schema),
2627
permissions('customerPayment.create'),
2728
(req, res, next) => {
28-
const { amount, currency, reference, referenceId, paymentMethodId, receiptEmail } = req.body;
29+
const {
30+
amount,
31+
currency,
32+
reference,
33+
referenceId,
34+
paymentMethodId,
35+
receiptEmail,
36+
description,
37+
} = req.body;
2938
createCustomerPayment(
3039
amount,
3140
currency,
3241
paymentMethodId,
3342
reference,
3443
referenceId,
3544
receiptEmail,
45+
description,
3646
req.authUser.userId,
3747
req,
3848
)

src/services/customerPaymentService.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,21 @@ async function sendCustomerPaymentMessage(event, customerPayment, req) {
8080
* @param {string} reference the payment method id
8181
* @param {string} referenceId the payment method id
8282
* @param {string} receiptEmail the receipt email
83+
* @param {string} description the receipt description
8384
* @param {string} userId the payment method id
8485
* @param {object} req the request
8586
* @returns {Promise} the customer payment
8687
*/
8788
export async function createCustomerPayment(
88-
amount, currency, paymentMethodId, reference, referenceId, receiptEmail, userId, req,
89+
amount,
90+
currency,
91+
paymentMethodId,
92+
reference,
93+
referenceId,
94+
receiptEmail,
95+
description,
96+
userId,
97+
req,
8998
) {
9099
const intentBody = {
91100
amount,
@@ -98,6 +107,9 @@ export async function createCustomerPayment(
98107
if (receiptEmail) {
99108
intentBody.receipt_email = receiptEmail;
100109
}
110+
if (description) {
111+
intentBody.description = description;
112+
}
101113
const intent = await convertStripError(() => stripe.paymentIntents.create(intentBody));
102114
const customerPayment = await models.CustomerPayment.create({
103115
reference,

0 commit comments

Comments
 (0)