cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass InvoiceNumber in json format in node js

Hello All,

I want to pass order details with invoiceNumber in Json format using Node js. I am using 

createTransactionRequest Method but I can't see order object in json format, it is available in XML format. Below is my code  I have trived this way but it's not working for me.

 
"createTransactionRequest": {
"merchantAuthentication": {
"name": apiLoginID,
"transactionKey": transactionKey
},
"refId": "123456",
"transactionRequest": {
"transactionType": "authCaptureTransaction",
"amount": data.amount,
"payment": {
"opaqueData": data.opaqueData
},
"profile": {createProfile: true},
"order":{
"invoiceNumber": "INV-12345",
"description": "Product Description",
},
"customer": {
type: 'individual',
id: order.GP_customer,
"email" : order.email
},
 


Can you please help me? how can i pass order in json format?

Thanks
 

Jsgreengalaxy
Member
4 REPLIES 4

That response is a string too, if you want to send the response prettified, for some awkward reason, you could use something like JSON.stringify(anObject, null, 3)

It's important that you set the Content-Type header to application/json, too.

var http = require('http');

var app = http.createServer(function(req,res){    res.setHeader('Content-Type', 'application/json');    res.end(JSON.stringify({ a: 1 }));
});app.listen(3000);

// > {"a":1}
Ryan4
Member

jason.stringify use the following

var http = require('http');

var app = http.createServer(function(req,res){    res.setHeader('Content-Type', 'application/json');    res.end(JSON.stringify({ a: 1 }));
});app.listen(3000);

// > {"a":1}

code

OvidNeil
Member

type header as Application/jason

jason.stringify place the following code

var http = require('http');

var app = http.createServer(function(req,res){    res.setHeader('Content-Type', 'application/json');    res.end(JSON.stringify({ a: 1 }));
});app.listen(3000);

// > {"a":1}
OvidNeil
Member

jason.stringify set the header as application/jason

place the following code

var http = require('http');

var app = http.createServer(function(req,res){    res.setHeader('Content-Type', 'application/json');    res.end(JSON.stringify({ a: 1 }));
});app.listen(3000);

// > {"a":1}
OvidNeil
Member