Happy Business Starts Here

Javascript (node.js) quickstart


Javascript (node.js) quickstart

I'm brand new to Zuora, and it took me quite a while to get a script to successfully connect and create some data. I'm going to post here the info that could have saved me more than a day.


Install module node_zuora. Figure out where it got installed and add 'export NODE_PATH=/usr/local/lib/node_module' to your .bash_profile if needed. 


npm install --global --verbose  zuora-soap



// https://github.com/joyent/node_zuora
var zuora = require('zuora-soap');
var os = require('os');
var config = require(os.homedir() + '/.zuora-sandbox-config.json');

zuora.connect(config, function(err, z) {
    if (err) return console.log('Error connecting:', err);
    var paymentDetails = {
        'Type': 'External',
        'Status': 'Processed',
        'EffectiveDate': '2016-08-01',
        'AccountId': '2c92c0f955e2bcfc0155e96053a00a44',
        'InvoiceNumber': 'INV00000004',
        'Amount': 1234.56,
        'AppliedInvoiceAmount': 1234.56,
        'PaymentMethodId': '2c92c0f85529afda01552c2247c23c1f',
    z.payment.create(paymentDetails, function(err, result) {
        if (err) return console.log(err.message);
        var paymentid = result[0]['Id'];
        var query = `select id from payment where id='${paymentid}'`;
        z.query(query, function(err, result) {
            if (err) return console.log(err.message);
            // inspect result

 The credentials and endpoint are in a json dot file in my home directory. That file also specifies where the wsdl is. Download the wsdl from your instance, Settings/Z-Billing Settings/Download the Zuora WSDL.



      "user":     "zuora_api_user@blahblah.com.apisandbox",
      "password": "password",
      "wsdl":     "/Users/bo/Dropbox/Canonical/zuora/zuora.a.78.0.wsdl",
      "//endpoint": "https://apisandbox.zuora.com/apps/services/a/78.0",
      "verboseLog": false

Some of the info on https://knowledgecenter.zuora.com/DC_Developers/SOAP_API/AB_Getting_started_with_the__SOAP_API is incorrect or old. Some of the tools that I found very helpful (wouldn't have needed all this firepower if I had been given the above code!)



Zuora Support Moderator

Re: Javascript (node.js) quickstart

@bolaurent, thanks for adding this!


I checked in with our documentation team and they're working on a project to get us clearer and more up-to-date API materials. In the interim, this is a great reference tool and I know the community will benefit as a whole.



If you found my answer helpful, please give me a kudo ↑
Help others find answers faster by accepting my post as a solution √

Newly Enrolled

Re: Javascript (node.js) quickstart

Great reference tool. I suggest this: javascript obfuscator