167
Views
2
Comments
Solved
Taking a JS code and using the JSONdeserialize

Hi! I'm developing a mobile app with IUGU payment method, for this, I need to build from scratch a plugin. I'm new in programming and OUTSYSTEMS. I don't know how to get the information from API like in the site: https://dev.iugu.com/reference#criar-fatura, that when I post this JS code: 

var data = JSON.stringify({
"ensure_workday_due_date": false,
"items": [
{
"description": "Teste",
"quantity": 1,
"price_cents": 10000
},
{
"description": "Teste1",
"quantity": 1,
"price_cents": 10000
}
],
"payer": {
"address": {
"zip_code": "zip_code",
"street": "street",
"number": "1490",
"district": "district",
"city": "city",
"state": "SP",
"country": "Brasil",
"complement": "Casa"
},
"cpf_cnpj": "cpf_cnpj",
"name": "Bruno"
},
"commissions": {
"cents": 5000
},
"email": "exemple@exemple.com.br",
"due_date": "2020-08-07"
});

var xhr = new XMLHttpRequest();

xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});

xhr.open("POST", "https://api.iugu.com/v1/invoices?api_token=");
xhr.setRequestHeader("content-type", "application/json");

returns a Json like this:

{"id":

"ID"

"due_date":

"2020-08-07"

"currency":

"BRL"

"discount_cents":

NULL

"email":

"example@example.com.br"

"items_total_cents":

20000

"notification_url":

NULL

"return_url":

NULL

"status":

"pending"

"tax_cents":

NULL

"total_cents":

20000

}

The code isn't the problem, but I'm not too good at programming and I don't know how to get this JSON data back to my mobile app. Anyone can help me with an article or documentation??


Best Regards



Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.