Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
router.post('/checkout_action', async (req, res, next) => {
const db = req.app.db;
const config = req.app.config;
const adyenConfig = common.getPaymentConfig();
const client = new Client({
apiKey: adyenConfig.apiKey,
environment: adyenConfig.environment
});
const checkout = new CheckoutAPI(client);
let response;
try{
response = await checkout.payments({
shopperInteraction: 'Ecommerce',
amount: {
currency: adyenConfig.currency,
value: numeral(req.session.totalCartAmount).format('0.00').replace('.', '')
},
paymentMethod: JSON.parse(req.body.payment),
reference: adyenConfig.statementDescriptor,
merchantAccount: adyenConfig.merchantAccount,
shopperStatement: adyenConfig.statementDescriptor