From 83a23d397da692a2e97f63eba3fd82d33c2c9fb7 Mon Sep 17 00:00:00 2001 From: Mark Moffat Date: Tue, 12 Nov 2019 22:11:02 +1030 Subject: [PATCH] Send optional address to Stripe for better compliance --- routes/payments/stripe.js | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/routes/payments/stripe.js b/routes/payments/stripe.js index 315f618..219a1b2 100644 --- a/routes/payments/stripe.js +++ b/routes/payments/stripe.js @@ -11,13 +11,26 @@ router.post('/checkout_action', (req, res, next) => { const config = req.app.config; const stripeConfig = common.getPaymentConfig(); - // charge via stripe - stripe.charges.create({ + // Create the Stripe payload + const chargePayload = { amount: numeral(req.session.totalCartAmount).format('0.00').replace('.', ''), - currency: stripeConfig.stripeCurrency, + currency: stripeConfig.stripeCurrency.toLowerCase(), source: req.body.stripeToken, - description: stripeConfig.stripeDescription - }, (err, charge) => { + description: stripeConfig.stripeDescription, + shipping: { + name: `${req.body.shipFirstname} ${req.body.shipLastname}`, + address: { + line1: req.body.shipAddr1, + line2: req.body.shipAddr2, + postal_code: req.body.shipPostcode, + state: req.body.shipState, + country: req.body.shipCountry + } + } + }; + + // charge via stripe + stripe.charges.create(chargePayload, (err, charge) => { if(err){ console.info(err.stack); req.session.messageType = 'danger';