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
});
}catch(ex){
console.log('Payment exception', ex.message);
req.session.messageType = 'danger';
router.post('/setup', async (req, res, next) => {
const adyenConfig = common.getPaymentConfig();
const client = new Client({
apiKey: adyenConfig.apiKey,
environment: adyenConfig.environment
});
const checkout = new CheckoutAPI(client);
let paymentsResponse;
try{
paymentsResponse = await checkout.paymentMethods({
amount: {
currency: 'AUD',
value: 0
},
countryCode: 'AU',
channel: 'Web',
merchantAccount: adyenConfig.merchantAccount
});
}catch(ex){
console.log('Exception getting supported payment methods', ex.message);
res.status(400).json({ message: 'Failed to retrieve payment methods.' + ex.message });
}
res.status(200).json({
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