How to use the @adyen/api-library.CheckoutAPI function in @adyen/api-library

To help you get started, we’ve selected a few @adyen/api-library examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mrvautin / expressCart / routes / payments / adyen.js View on Github external
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';
github mrvautin / expressCart / routes / payments / adyen.js View on Github external
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({

@adyen/api-library

The Adyen API Library for NodeJS enables you to work with Adyen APIs.

MIT
Latest version published 11 days ago

Package Health Score

90 / 100
Full package analysis

Popular @adyen/api-library functions