-
Notifications
You must be signed in to change notification settings - Fork 4
/
emitirNotaFiscal.js
92 lines (87 loc) · 2.42 KB
/
emitirNotaFiscal.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var data = JSON.stringify({
"ID": 1137,
"url_notificacao": "https://webmaniabr.com/retorno.php",
"operacao": 1,
"natureza_operacao": "Venda de produção do estabelecimento",
"modelo": 1,
"finalidade": 1,
"ambiente": 2,
"cliente": {
"cpf": "000.000.000-00",
"nome_completo": "Miguel Pereira da Silva",
"endereco": "Av. Anita Garibaldi",
"complemento": "Sala 809 Royal",
"numero": 850,
"bairro": "Ahú",
"cidade": "Curitiba",
"uf": "PR",
"cep": "80540-180",
"telefone": "(41) 4063-9102",
"email": "suporte@webmaniabr.com"
},
"produtos": [
{
"nome": "Camisetas Night Run",
"sku": "camiseta-night-run",
"ean": "0789602015376",
"ncm": "6109.10.00",
"cest": "28.038.00",
"cnpj_produtor": "00.000.000/0000-00",
"quantidade": 3,
"unidade": "UN",
"peso": "0.800",
"origem": 0,
"subtotal": "44.90",
"total": "134.70",
"classe_imposto": "REF1637"
},
{
"nome": "Camisetas 10 Milhas",
"sku": "camisetas-10-milhas",
"ean": "0789602015376",
"ncm": "6109.10.00",
"cest": "28.038.00",
"cnpj_produtor": "00.000.000/0000-00",
"quantidade": "1",
"unidade": "UN",
"peso": "0.200",
"origem": 0,
"subtotal": "29.90",
"total": "29.90",
"classe_imposto": "REF1637"
}
],
"pedido": {
"pagamento": 0,
"presenca": 2,
"modalidade_frete": 0,
"frete": "12.56",
"desconto": "10.00",
"total": "174.60"
},
"transporte": {
"cnpj": "00.000.000/0000-00",
"razao_social": "Transportes LTDA",
"ie": "123.456.789.123",
"endereco": "Av. Anita Garibaldi",
"uf": "PR",
"cidade": "Curitiba",
"cep": "80540-180"
}
});
var XMLHttpRequest = require("xmlhttprequest").XMLHttpRequest;
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === 4) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://webmaniabr.com/api/1/nfe/emissao/");
xhr.setRequestHeader("cache-control", "no-cache");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-consumer-key", "SEU_CONSUMER_KEY");
xhr.setRequestHeader("x-consumer-secret", "SEU_CONSUMER_SECRET");
xhr.setRequestHeader("x-access-token", "SEU_ACCESS_TOKEN");
xhr.setRequestHeader("x-access-token-secret", "SEU_ACCESS_TOKEN_SECRET");
xhr.send(data);