Send optional address to Stripe for better compliance

master
Mark Moffat 2019-11-12 22:11:02 +10:30
parent e46f5a7f4b
commit 83a23d397d
1 changed files with 18 additions and 5 deletions

View File

@ -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';