Gostaria de saber o que estou fazendo de errado pois tenho que obter uma resposta de uma solicitação a API da cielo
Segue código
I would like to know what I am doing wrong since I have to get a response from a request to sky API
Follow code
export function button1_click(event, $w) {
post_PagamentoCielo()
.then(retornoCielo => {
$w(“#result”).text = JSON.stringify(retornoCielo);
});
}
import {
fetch
} from ‘wix-fetch’;
import wixHttpFunctions from ‘wix-http-functions’;
export function post_PagamentoCielo() {
const url = ‘https://cieloecommerce.cielo.com.br/api/public/v1/orders’;
const request = {
method: “POST”,
header: {
“MerchantId”: “xxxxxxx-xxxxxxxxxxxxxxxxxxxxx-xxxxxxxxx”,
“Content-Type”: “application/json”
},
body: {
“OrderNumber”: “”,
“SoftDescriptor”: “TOUR”,
“Cart”: {
“Discount”: {
“Type”: “Percent”,
“Value”: 0
},
“Items”: [{
“Name”: “Tour Pantanal”,
“Description”: “Tour”,
“UnitPrice”: 25000,
“Quantity”: 3,
“Type”: “Service”,
“Sku”: “TOURPANTANAL”,
“Weight”: 0
}]
},
“Shipping”: {
“SourceZipCode”: “”,
“TargetZipCode”: “”,
“Type”: “WithoutShipping”,
“Services”: [{
“Name”: “Teste”,
“Price”: 0,
“Deadline”: 0,
“Carrier”: null
}],
“Address”: {
“Street”: “Teste”,
“Number”: “1”,
“Complement”: “Confiança”,
“District”: “Cuiabá”,
“City”: “Cuiabá”,
“State”: “MtT”
}
},
“Payment”: {
“BoletoDiscount”: 0,
“DebitDiscount”: 0,
“Installments”: 2,
“MaxNumberOfInstallments”: 6
},
“Customer”: {
“Identity”: “0000000000000”,
“FullName”: “Antonio da Paz Rosa Neto”,
“Email”: “adm.antonioneto@hotmail.com”,
“Phone”: “65999203245”
},
“Options”: {
“AntifraudEnabled”: false ,
“ReturnUrl”: “http://www.google.com.br”
},
“Settings”: null
}
}
console.log(url);
console.log(JSON.stringify(request));
return fetch(url, request).then(response => response.json())
}