elif
elif

Reputation: 1

Can't run Chargebee API with node.js

I'm new to this API so I'm trying to run it with node.js but It seems not to be working, so I'm stuck. Can anyone who had already used ChargeBee API with Node please help me. Thank you

Upvotes: 0

Views: 460

Answers (1)

Ajit Verma
Ajit Verma

Reputation: 66

Could you add more information regarding your issue with some code snippet.

Here is an example on how to use chargebee API in node:

var chargebee = require("chargebee");

chargebee.configure({site : "<<site_name>>",
  api_key : "<<api_key>>"});

  var getSubDetails = function(subId, callback){
    chargebee.subscription.retrieve(subId).request(
    function(error,result){
      if(error){
        //handle error
        console.log(error);
      }else{
        var subscription = result.subscription;
        var customer = result.customer;
        var card = result.card;
        callback(subscription, customer);
      }
    });
  }

  getSubDetails("<<subID>>", function(subscription, customer){// calling function by passing chargebee subscription ID.
     console.log(subscription);
     console.log(customer);
  });

Upvotes: 1

Related Questions