nodejs external api access

I’d like to access a remote api using node.js.
Here is a code example:

Mollie = require('mollie-api-node');

mollie = new Mollie.API.Client;
mollie.setApiKey('test_JAf68QKVQBJg7gdkFECqT84pSzev5D');

mollie.payments.create({
    amount:      10.00,
    description: 'My first payment',
    redirectUrl: 'https://webshop.example.org/order/12345/',
    metadata: {
        orderId: '12345'
    }
},  function (payment) {
    if (payment.error) {
        console.error(payment.error);
        return response.end();
    }

    /*
     * Send the customer off to complete the payment.
     */
    response.writeHead(302, {
        Location: payment.getPaymentUrl()
    });
    return response.end();
});

Is this possible from either our workflow or OL Connect? I can't find a place to install the api currently.

Hello leeflank,

There is no way to use node.js directly from within workflow or Connect, at least not natively. You would have to use the “External Program” action task and call ‘node myfile.js’, then parse the return it gives.

However, note that this all has to be syncronous, as Workflow cannot wait for async events.

You can also do this directly from the scripting engine in Workflow, however. Here’s a how-to that describes the method (it’s not as sexy as using Node, but it does work): http://learn.objectiflune.com/en-us/planetpress-connect/howto/scripts-communicate-with-http-api