@sinnu-dev/sdk 0.0.0-stage → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +161 -2
- package/dist/index.cjs +895 -0
- package/dist/index.d.cts +1285 -0
- package/dist/index.d.ts +1285 -0
- package/dist/index.js +850 -0
- package/package.json +63 -5
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,1285 @@
|
|
|
1
|
+
import { Client, FetchResponse, ParseAsResponse } from 'openapi-fetch';
|
|
2
|
+
import { SuccessResponse, ResponseObjectMap } from 'openapi-typescript-helpers';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* This file was auto-generated by openapi-typescript.
|
|
6
|
+
* Do not make direct changes to the file.
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
interface paths {
|
|
10
|
+
"/api/customers/": {
|
|
11
|
+
parameters: {
|
|
12
|
+
query?: never;
|
|
13
|
+
header?: never;
|
|
14
|
+
path?: never;
|
|
15
|
+
cookie?: never;
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Listar clientes
|
|
19
|
+
* @description Lista os clientes da empresa autenticada no envelope paginado `{ data, total, page, pageSize }`.
|
|
20
|
+
*/
|
|
21
|
+
get: operations["customers_list"];
|
|
22
|
+
put?: never;
|
|
23
|
+
/**
|
|
24
|
+
* Cadastrar cliente
|
|
25
|
+
* @description Cadastra um cliente na empresa autenticada. O CPF ou CNPJ é único por empresa.
|
|
26
|
+
*/
|
|
27
|
+
post: operations["customers_create"];
|
|
28
|
+
delete?: never;
|
|
29
|
+
options?: never;
|
|
30
|
+
head?: never;
|
|
31
|
+
patch?: never;
|
|
32
|
+
trace?: never;
|
|
33
|
+
};
|
|
34
|
+
"/api/customers/{id}/": {
|
|
35
|
+
parameters: {
|
|
36
|
+
query?: never;
|
|
37
|
+
header?: never;
|
|
38
|
+
path?: never;
|
|
39
|
+
cookie?: never;
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* Consultar cliente
|
|
43
|
+
* @description Retorna um cliente da empresa autenticada.
|
|
44
|
+
*/
|
|
45
|
+
get: operations["customers_retrieve"];
|
|
46
|
+
put?: never;
|
|
47
|
+
post?: never;
|
|
48
|
+
delete?: never;
|
|
49
|
+
options?: never;
|
|
50
|
+
head?: never;
|
|
51
|
+
/**
|
|
52
|
+
* Atualizar cliente
|
|
53
|
+
* @description Atualiza parcialmente um cliente da empresa autenticada.
|
|
54
|
+
*/
|
|
55
|
+
patch: operations["customers_partial_update"];
|
|
56
|
+
trace?: never;
|
|
57
|
+
};
|
|
58
|
+
"/api/payment-links": {
|
|
59
|
+
parameters: {
|
|
60
|
+
query?: never;
|
|
61
|
+
header?: never;
|
|
62
|
+
path?: never;
|
|
63
|
+
cookie?: never;
|
|
64
|
+
};
|
|
65
|
+
/**
|
|
66
|
+
* Listar links de pagamento
|
|
67
|
+
* @description Lista os links de pagamento da empresa autenticada no envelope paginado do sinnu `{ data, total, page, pageSize }`.
|
|
68
|
+
*/
|
|
69
|
+
get: operations["paymentLinks_list"];
|
|
70
|
+
put?: never;
|
|
71
|
+
/**
|
|
72
|
+
* Criar link de pagamento
|
|
73
|
+
* @description Cria um link de pagamento para a empresa autenticada. Use este recurso para gerar cobranças compartilháveis com suporte a Pix e cartão de crédito.
|
|
74
|
+
*/
|
|
75
|
+
post: operations["paymentLinks_create"];
|
|
76
|
+
delete?: never;
|
|
77
|
+
options?: never;
|
|
78
|
+
head?: never;
|
|
79
|
+
patch?: never;
|
|
80
|
+
trace?: never;
|
|
81
|
+
};
|
|
82
|
+
"/api/payment-links/{id}": {
|
|
83
|
+
parameters: {
|
|
84
|
+
query?: never;
|
|
85
|
+
header?: never;
|
|
86
|
+
path?: never;
|
|
87
|
+
cookie?: never;
|
|
88
|
+
};
|
|
89
|
+
/**
|
|
90
|
+
* Consultar link de pagamento
|
|
91
|
+
* @description Retorna os detalhes de um link de pagamento da empresa autenticada.
|
|
92
|
+
*/
|
|
93
|
+
get: operations["paymentLinks_retrieve"];
|
|
94
|
+
put?: never;
|
|
95
|
+
post?: never;
|
|
96
|
+
/**
|
|
97
|
+
* Arquivar link de pagamento
|
|
98
|
+
* @description Arquiva um link de pagamento da empresa autenticada.
|
|
99
|
+
*/
|
|
100
|
+
delete: operations["paymentLinks_destroy"];
|
|
101
|
+
options?: never;
|
|
102
|
+
head?: never;
|
|
103
|
+
/**
|
|
104
|
+
* Atualizar link de pagamento
|
|
105
|
+
* @description Atualiza um link de pagamento da empresa autenticada.
|
|
106
|
+
*/
|
|
107
|
+
patch: operations["paymentLinks_partialUpdate"];
|
|
108
|
+
trace?: never;
|
|
109
|
+
};
|
|
110
|
+
"/api/payment-links/{id}/transactions": {
|
|
111
|
+
parameters: {
|
|
112
|
+
query?: never;
|
|
113
|
+
header?: never;
|
|
114
|
+
path?: never;
|
|
115
|
+
cookie?: never;
|
|
116
|
+
};
|
|
117
|
+
/**
|
|
118
|
+
* Listar transações do link
|
|
119
|
+
* @description Lista as transações originadas por um link de pagamento da empresa autenticada.
|
|
120
|
+
*/
|
|
121
|
+
get: operations["paymentLinks_transactions"];
|
|
122
|
+
put?: never;
|
|
123
|
+
post?: never;
|
|
124
|
+
delete?: never;
|
|
125
|
+
options?: never;
|
|
126
|
+
head?: never;
|
|
127
|
+
patch?: never;
|
|
128
|
+
trace?: never;
|
|
129
|
+
};
|
|
130
|
+
"/api/transactions/": {
|
|
131
|
+
parameters: {
|
|
132
|
+
query?: never;
|
|
133
|
+
header?: never;
|
|
134
|
+
path?: never;
|
|
135
|
+
cookie?: never;
|
|
136
|
+
};
|
|
137
|
+
/**
|
|
138
|
+
* Listar transações
|
|
139
|
+
* @description Lista transações da empresa autenticada no envelope paginado `{ data, total, page, pageSize }`. Use `status`, `customer` e `search` para filtrar.
|
|
140
|
+
*/
|
|
141
|
+
get: operations["transactions_list"];
|
|
142
|
+
put?: never;
|
|
143
|
+
post?: never;
|
|
144
|
+
delete?: never;
|
|
145
|
+
options?: never;
|
|
146
|
+
head?: never;
|
|
147
|
+
patch?: never;
|
|
148
|
+
trace?: never;
|
|
149
|
+
};
|
|
150
|
+
"/api/transactions/{id}/": {
|
|
151
|
+
parameters: {
|
|
152
|
+
query?: never;
|
|
153
|
+
header?: never;
|
|
154
|
+
path?: never;
|
|
155
|
+
cookie?: never;
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Consultar transação
|
|
159
|
+
* @description Retorna uma transação da empresa autenticada em formato flat.
|
|
160
|
+
*/
|
|
161
|
+
get: operations["transactions_retrieve"];
|
|
162
|
+
put?: never;
|
|
163
|
+
post?: never;
|
|
164
|
+
delete?: never;
|
|
165
|
+
options?: never;
|
|
166
|
+
head?: never;
|
|
167
|
+
patch?: never;
|
|
168
|
+
trace?: never;
|
|
169
|
+
};
|
|
170
|
+
"/api/transactions/{id}/refund/": {
|
|
171
|
+
parameters: {
|
|
172
|
+
query?: never;
|
|
173
|
+
header?: never;
|
|
174
|
+
path?: never;
|
|
175
|
+
cookie?: never;
|
|
176
|
+
};
|
|
177
|
+
get?: never;
|
|
178
|
+
put?: never;
|
|
179
|
+
/**
|
|
180
|
+
* Estornar transação
|
|
181
|
+
* @description Solicita o estorno total de uma transação paga. Exige o escopo `transactions:refund` na chave de API; o `read` não concede estorno. `reason` e `note` são opcionais e servem para registro interno. Reenvios podem usar `Idempotency-Key`.
|
|
182
|
+
*/
|
|
183
|
+
post: operations["transactions_refund"];
|
|
184
|
+
delete?: never;
|
|
185
|
+
options?: never;
|
|
186
|
+
head?: never;
|
|
187
|
+
patch?: never;
|
|
188
|
+
trace?: never;
|
|
189
|
+
};
|
|
190
|
+
}
|
|
191
|
+
interface components {
|
|
192
|
+
schemas: {
|
|
193
|
+
/**
|
|
194
|
+
* @description * `absorb` - Eu absorvo
|
|
195
|
+
* * `pass_to_customer` - Cliente paga
|
|
196
|
+
* @enum {string}
|
|
197
|
+
*/
|
|
198
|
+
InterestModeEnum: "absorb" | "pass_to_customer";
|
|
199
|
+
PaginatedPaymentLink: {
|
|
200
|
+
total: number;
|
|
201
|
+
page: number;
|
|
202
|
+
pageSize: number;
|
|
203
|
+
data: components["schemas"]["PaymentLinkRead"][];
|
|
204
|
+
};
|
|
205
|
+
PaginatedPaymentLinkTransaction: {
|
|
206
|
+
total: number;
|
|
207
|
+
page: number;
|
|
208
|
+
pageSize: number;
|
|
209
|
+
data: components["schemas"]["PaymentLinkTransactionItem"][];
|
|
210
|
+
};
|
|
211
|
+
PaginatedSinnuCustomerList: {
|
|
212
|
+
data: components["schemas"]["SinnuCustomer"][];
|
|
213
|
+
/** @example 123 */
|
|
214
|
+
total: number;
|
|
215
|
+
/** @example 1 */
|
|
216
|
+
page: number;
|
|
217
|
+
/** @example 20 */
|
|
218
|
+
pageSize: number;
|
|
219
|
+
};
|
|
220
|
+
PaginatedSinnuTransactionList: {
|
|
221
|
+
data: components["schemas"]["SinnuTransaction"][];
|
|
222
|
+
/** @example 123 */
|
|
223
|
+
total: number;
|
|
224
|
+
/** @example 1 */
|
|
225
|
+
page: number;
|
|
226
|
+
/** @example 20 */
|
|
227
|
+
pageSize: number;
|
|
228
|
+
};
|
|
229
|
+
/** @description Body para atualizar parcialmente um link de pagamento. */
|
|
230
|
+
PatchedPaymentLinkWrite: {
|
|
231
|
+
/** @description Título exibido no checkout hospedado. */
|
|
232
|
+
title?: string;
|
|
233
|
+
/** @description Descrição exibida no checkout. */
|
|
234
|
+
description?: string;
|
|
235
|
+
/** Format: uri */
|
|
236
|
+
imageUrl?: string | null;
|
|
237
|
+
/** @description Modo de preço. No contrato público atual, use sempre `fixed`. */
|
|
238
|
+
priceMode?: components["schemas"]["PriceModeEnum"];
|
|
239
|
+
/** @description Valor fixo do link em centavos. Obrigatório para `priceMode: fixed`. */
|
|
240
|
+
amountCents?: number | null;
|
|
241
|
+
/** @description Reservado para modos de preço futuros. Não use no contrato público atual. */
|
|
242
|
+
minAmountCents?: number | null;
|
|
243
|
+
/** @description Reservado para modos de preço futuros. Não use no contrato público atual. */
|
|
244
|
+
maxAmountCents?: number | null;
|
|
245
|
+
/** @description Métodos aceitos no checkout. Envie `pix`, `credit_card` ou ambos. */
|
|
246
|
+
methods?: ("pix" | "credit_card")[];
|
|
247
|
+
/** @description Número máximo de parcelas para cartão. Use 1 quando o link aceitar apenas Pix. */
|
|
248
|
+
maxInstallments?: number;
|
|
249
|
+
/** @description Define quem absorve juros de parcelamento: `absorb` ou `pass_to_customer`. */
|
|
250
|
+
interestMode?: components["schemas"]["InterestModeEnum"];
|
|
251
|
+
/** @description Status do link: active, paused ou archived. */
|
|
252
|
+
status?: components["schemas"]["Status50eEnum"];
|
|
253
|
+
/** @description Modo de 3DS para cartão: `always` ou `contingency`. */
|
|
254
|
+
threeDsMode?: components["schemas"]["ThreeDsModeEnum"];
|
|
255
|
+
/** @description Tags livres para organização interna do link. */
|
|
256
|
+
tags?: string[];
|
|
257
|
+
/** @description Para onde o checkout leva o comprador depois do pagamento confirmado (cartão aprovado ou Pix pago), com `transactionId`, `reference` e `status=approved` na query. Aceita `https://` ou o esquema do seu app (`meuapp://pedido`). O retorno é liberado por empresa: confirme com a Sinnu se já está ativo para a sua. Confirme o pagamento pela API ou pelo webhook: os parâmetros da URL podem ser alterados pelo comprador. */
|
|
258
|
+
redirectUrl?: string | null;
|
|
259
|
+
/** @description Código do produto no seu sistema. Volta como `externalRef` do item em cada venda do link. */
|
|
260
|
+
externalReference?: string | null;
|
|
261
|
+
/**
|
|
262
|
+
* Format: uuid
|
|
263
|
+
* @description ID de um cliente já cadastrado para vincular ao link.
|
|
264
|
+
*/
|
|
265
|
+
linkedCustomer?: string | null;
|
|
266
|
+
};
|
|
267
|
+
/** @description Cliente da sua empresa. Expõe apenas os dados principais de cadastro e um único documento principal (CPF ou CNPJ). */
|
|
268
|
+
PatchedSinnuCustomer: {
|
|
269
|
+
/** Format: uuid */
|
|
270
|
+
readonly id?: string;
|
|
271
|
+
name?: string;
|
|
272
|
+
/** Format: email */
|
|
273
|
+
email?: string;
|
|
274
|
+
phone?: string;
|
|
275
|
+
/** @description Documento principal do cliente: CPF ou CNPJ, somente dígitos ou formatado. */
|
|
276
|
+
document?: string | null;
|
|
277
|
+
/** @description Tipo do documento principal: `pf` para CPF ou `pj` para CNPJ. */
|
|
278
|
+
type?: components["schemas"]["SinnuCustomerTypeEnum"];
|
|
279
|
+
/** Format: date-time */
|
|
280
|
+
readonly createdAt?: string;
|
|
281
|
+
/** @description Endereço em linha livre, opcional. */
|
|
282
|
+
address?: string | null;
|
|
283
|
+
/** @description Observações internas sobre o cliente, opcionais. */
|
|
284
|
+
notes?: string | null;
|
|
285
|
+
};
|
|
286
|
+
/** @description Link de pagamento público da empresa autenticada. Use o `slug` para montar a URL do checkout hospedado. */
|
|
287
|
+
PaymentLinkRead: {
|
|
288
|
+
/** Format: uuid */
|
|
289
|
+
readonly id: string;
|
|
290
|
+
readonly slug: string;
|
|
291
|
+
/** @description Título exibido no checkout hospedado. */
|
|
292
|
+
readonly title: string;
|
|
293
|
+
/** @description Descrição exibida no checkout. */
|
|
294
|
+
readonly description: string;
|
|
295
|
+
/** Format: uri */
|
|
296
|
+
readonly imageUrl: string | null;
|
|
297
|
+
/** @description Modo de preço. No contrato público atual, use sempre `fixed`. */
|
|
298
|
+
readonly priceMode: components["schemas"]["PriceModeEnum"];
|
|
299
|
+
/** @description Valor fixo do link em centavos. Obrigatório para `priceMode: fixed`. */
|
|
300
|
+
readonly amountCents: number | null;
|
|
301
|
+
/** @description Reservado para modos de preço futuros. Não use no contrato público atual. */
|
|
302
|
+
readonly minAmountCents: number | null;
|
|
303
|
+
/** @description Reservado para modos de preço futuros. Não use no contrato público atual. */
|
|
304
|
+
readonly maxAmountCents: number | null;
|
|
305
|
+
/** @description Métodos aceitos no checkout. Envie `pix`, `credit_card` ou ambos. */
|
|
306
|
+
readonly methods: ("pix" | "credit_card")[];
|
|
307
|
+
/** @description Número máximo de parcelas para cartão. Use 1 quando o link aceitar apenas Pix. */
|
|
308
|
+
readonly maxInstallments: number;
|
|
309
|
+
/** @description Define quem absorve juros de parcelamento: `absorb` ou `pass_to_customer`. */
|
|
310
|
+
readonly interestMode: components["schemas"]["InterestModeEnum"];
|
|
311
|
+
/** @description Status do link: active, paused ou archived. */
|
|
312
|
+
readonly status: components["schemas"]["Status50eEnum"];
|
|
313
|
+
/** @description Modo de 3DS para cartão: `always` ou `contingency`. */
|
|
314
|
+
readonly threeDsMode: components["schemas"]["ThreeDsModeEnum"];
|
|
315
|
+
/** @description Tags livres para organização interna do link. */
|
|
316
|
+
readonly tags: string[];
|
|
317
|
+
/** @description Para onde o checkout leva o comprador depois do pagamento confirmado (cartão aprovado ou Pix pago), com `transactionId`, `reference` e `status=approved` na query. Aceita `https://` ou o esquema do seu app (`meuapp://pedido`). O retorno é liberado por empresa: confirme com a Sinnu se já está ativo para a sua. Confirme o pagamento pela API ou pelo webhook: os parâmetros da URL podem ser alterados pelo comprador. */
|
|
318
|
+
readonly redirectUrl: string | null;
|
|
319
|
+
/** @description Código do produto no seu sistema. Volta como `externalRef` do item em cada venda do link. */
|
|
320
|
+
readonly externalReference: string | null;
|
|
321
|
+
/** @description ID do cliente vinculado ao link, quando houver. */
|
|
322
|
+
readonly linkedCustomerId: string | null;
|
|
323
|
+
readonly companyId: number | null;
|
|
324
|
+
readonly companyName: string | null;
|
|
325
|
+
readonly sellerEmail: string | null;
|
|
326
|
+
/** Format: date-time */
|
|
327
|
+
readonly createdAt: string;
|
|
328
|
+
/** Format: date-time */
|
|
329
|
+
readonly updatedAt: string;
|
|
330
|
+
};
|
|
331
|
+
PaymentLinkTransactionCustomer: {
|
|
332
|
+
id: string;
|
|
333
|
+
name: string;
|
|
334
|
+
/** Format: email */
|
|
335
|
+
email: string;
|
|
336
|
+
};
|
|
337
|
+
PaymentLinkTransactionItem: {
|
|
338
|
+
/** Format: uuid */
|
|
339
|
+
id: string;
|
|
340
|
+
/** Format: double */
|
|
341
|
+
amount: number;
|
|
342
|
+
status: string;
|
|
343
|
+
paymentMethod: string;
|
|
344
|
+
installments: number;
|
|
345
|
+
customer: components["schemas"]["PaymentLinkTransactionCustomer"];
|
|
346
|
+
/** Format: date-time */
|
|
347
|
+
createdAt: string;
|
|
348
|
+
/** Format: date-time */
|
|
349
|
+
paidAt: string | null;
|
|
350
|
+
};
|
|
351
|
+
/** @description Body para criar um link de pagamento. Use `priceMode: fixed` e envie o valor em `amountCents`. */
|
|
352
|
+
PaymentLinkWrite: {
|
|
353
|
+
/** @description Título exibido no checkout hospedado. */
|
|
354
|
+
title: string;
|
|
355
|
+
/** @description Descrição exibida no checkout. */
|
|
356
|
+
description?: string;
|
|
357
|
+
/** Format: uri */
|
|
358
|
+
imageUrl?: string | null;
|
|
359
|
+
/** @description Modo de preço. No contrato público atual, use sempre `fixed`. */
|
|
360
|
+
priceMode?: components["schemas"]["PriceModeEnum"];
|
|
361
|
+
/** @description Valor fixo do link em centavos. Obrigatório para `priceMode: fixed`. */
|
|
362
|
+
amountCents?: number | null;
|
|
363
|
+
/** @description Reservado para modos de preço futuros. Não use no contrato público atual. */
|
|
364
|
+
minAmountCents?: number | null;
|
|
365
|
+
/** @description Reservado para modos de preço futuros. Não use no contrato público atual. */
|
|
366
|
+
maxAmountCents?: number | null;
|
|
367
|
+
/** @description Métodos aceitos no checkout. Envie `pix`, `credit_card` ou ambos. */
|
|
368
|
+
methods?: ("pix" | "credit_card")[];
|
|
369
|
+
/** @description Número máximo de parcelas para cartão. Use 1 quando o link aceitar apenas Pix. */
|
|
370
|
+
maxInstallments?: number;
|
|
371
|
+
/** @description Define quem absorve juros de parcelamento: `absorb` ou `pass_to_customer`. */
|
|
372
|
+
interestMode?: components["schemas"]["InterestModeEnum"];
|
|
373
|
+
/** @description Status do link: active, paused ou archived. */
|
|
374
|
+
status?: components["schemas"]["Status50eEnum"];
|
|
375
|
+
/** @description Modo de 3DS para cartão: `always` ou `contingency`. */
|
|
376
|
+
threeDsMode?: components["schemas"]["ThreeDsModeEnum"];
|
|
377
|
+
/** @description Tags livres para organização interna do link. */
|
|
378
|
+
tags?: string[];
|
|
379
|
+
/** @description Para onde o checkout leva o comprador depois do pagamento confirmado (cartão aprovado ou Pix pago), com `transactionId`, `reference` e `status=approved` na query. Aceita `https://` ou o esquema do seu app (`meuapp://pedido`). O retorno é liberado por empresa: confirme com a Sinnu se já está ativo para a sua. Confirme o pagamento pela API ou pelo webhook: os parâmetros da URL podem ser alterados pelo comprador. */
|
|
380
|
+
redirectUrl?: string | null;
|
|
381
|
+
/** @description Código do produto no seu sistema. Volta como `externalRef` do item em cada venda do link. */
|
|
382
|
+
externalReference?: string | null;
|
|
383
|
+
/**
|
|
384
|
+
* Format: uuid
|
|
385
|
+
* @description ID de um cliente já cadastrado para vincular ao link.
|
|
386
|
+
*/
|
|
387
|
+
linkedCustomer?: string | null;
|
|
388
|
+
};
|
|
389
|
+
/**
|
|
390
|
+
* @description * `fixed` - Fixo
|
|
391
|
+
* @enum {string}
|
|
392
|
+
*/
|
|
393
|
+
PriceModeEnum: "fixed";
|
|
394
|
+
/** @description Cliente da sua empresa. Expõe apenas os dados principais de cadastro e um único documento principal (CPF ou CNPJ). */
|
|
395
|
+
SinnuCustomer: {
|
|
396
|
+
/** Format: uuid */
|
|
397
|
+
readonly id: string;
|
|
398
|
+
name: string;
|
|
399
|
+
/** Format: email */
|
|
400
|
+
email: string;
|
|
401
|
+
phone: string;
|
|
402
|
+
/** @description Documento principal do cliente: CPF ou CNPJ, somente dígitos ou formatado. */
|
|
403
|
+
document?: string | null;
|
|
404
|
+
/** @description Tipo do documento principal: `pf` para CPF ou `pj` para CNPJ. */
|
|
405
|
+
type?: components["schemas"]["SinnuCustomerTypeEnum"];
|
|
406
|
+
/** Format: date-time */
|
|
407
|
+
readonly createdAt: string;
|
|
408
|
+
/** @description Endereço em linha livre, opcional. */
|
|
409
|
+
address?: string | null;
|
|
410
|
+
/** @description Observações internas sobre o cliente, opcionais. */
|
|
411
|
+
notes?: string | null;
|
|
412
|
+
};
|
|
413
|
+
/**
|
|
414
|
+
* @description * `pf` - pf
|
|
415
|
+
* * `pj` - pj
|
|
416
|
+
* @enum {string}
|
|
417
|
+
*/
|
|
418
|
+
SinnuCustomerTypeEnum: "pf" | "pj";
|
|
419
|
+
/** @description Pedido de estorno. O estorno é sempre do valor total; não há campo de valor. */
|
|
420
|
+
SinnuRefundRequest: {
|
|
421
|
+
/** @description Motivo do estorno, opcional. */
|
|
422
|
+
reason?: string;
|
|
423
|
+
/** @description Observação sobre o estorno, opcional. */
|
|
424
|
+
note?: string;
|
|
425
|
+
};
|
|
426
|
+
/** @description Transação da empresa autenticada. Valores monetários são inteiros em centavos. */
|
|
427
|
+
SinnuTransaction: {
|
|
428
|
+
readonly id: string;
|
|
429
|
+
/** @description Valor bruto cobrado do pagador, em centavos. */
|
|
430
|
+
readonly amount: number;
|
|
431
|
+
/** @description Valor líquido da empresa, em centavos. */
|
|
432
|
+
readonly net: number;
|
|
433
|
+
/** @description Preço do produto, em centavos, antes dos juros de parcelamento. */
|
|
434
|
+
readonly productAmount: number;
|
|
435
|
+
/** @description Juros do parcelamento, em centavos. */
|
|
436
|
+
readonly interestAmount: number;
|
|
437
|
+
/** @description Quem paga os juros do parcelamento: `absorb` ou `pass_to_customer`. */
|
|
438
|
+
readonly interestMode: string | null;
|
|
439
|
+
readonly mdrAmount: number;
|
|
440
|
+
readonly fixedFeeAmount: number;
|
|
441
|
+
readonly otherFeeAmount: number;
|
|
442
|
+
readonly totalFeeAmount: number;
|
|
443
|
+
/** @description Status da transação: pending, approved, refused, refunded ou chargeback. */
|
|
444
|
+
readonly status: string;
|
|
445
|
+
/** @description Método de pagamento: pix ou credit_card. */
|
|
446
|
+
readonly method: string;
|
|
447
|
+
/** @description Pagador da transação: `{ id, name, email }`. */
|
|
448
|
+
readonly customer: {
|
|
449
|
+
[key: string]: unknown;
|
|
450
|
+
};
|
|
451
|
+
/** @description Descrição da venda. Vazia quando não informada. */
|
|
452
|
+
readonly description: string;
|
|
453
|
+
readonly installments: number;
|
|
454
|
+
/** Format: date-time */
|
|
455
|
+
readonly createdAt: string;
|
|
456
|
+
/** Format: date-time */
|
|
457
|
+
readonly paidAt: string | null;
|
|
458
|
+
/** @description Pedido do seu sistema para esta venda: o `?ref=` com que o checkout foi aberto, ou o `exId` da cobrança criada pela API. `null` quando não informado. */
|
|
459
|
+
readonly reference: string | null;
|
|
460
|
+
};
|
|
461
|
+
/**
|
|
462
|
+
* @description * `active` - Ativo
|
|
463
|
+
* * `paused` - Pausado
|
|
464
|
+
* * `archived` - Arquivado
|
|
465
|
+
* @enum {string}
|
|
466
|
+
*/
|
|
467
|
+
Status50eEnum: "active" | "paused" | "archived";
|
|
468
|
+
/**
|
|
469
|
+
* @description * `always` - Sempre
|
|
470
|
+
* * `contingency` - Contingência
|
|
471
|
+
* @enum {string}
|
|
472
|
+
*/
|
|
473
|
+
ThreeDsModeEnum: "always" | "contingency";
|
|
474
|
+
};
|
|
475
|
+
responses: never;
|
|
476
|
+
parameters: never;
|
|
477
|
+
requestBodies: never;
|
|
478
|
+
headers: never;
|
|
479
|
+
pathItems: never;
|
|
480
|
+
}
|
|
481
|
+
interface operations {
|
|
482
|
+
customers_list: {
|
|
483
|
+
parameters: {
|
|
484
|
+
query?: {
|
|
485
|
+
/** @description Which field to use when ordering the results. */
|
|
486
|
+
ordering?: string;
|
|
487
|
+
/** @description Número da página (1-based; default 1). */
|
|
488
|
+
page?: number;
|
|
489
|
+
/** @description Tamanho da página (default 20, máx. 100). */
|
|
490
|
+
pageSize?: number;
|
|
491
|
+
/** @description Busca por nome, e-mail, telefone ou documento. */
|
|
492
|
+
search?: string;
|
|
493
|
+
};
|
|
494
|
+
header?: never;
|
|
495
|
+
path?: never;
|
|
496
|
+
cookie?: never;
|
|
497
|
+
};
|
|
498
|
+
requestBody?: never;
|
|
499
|
+
responses: {
|
|
500
|
+
200: {
|
|
501
|
+
headers: {
|
|
502
|
+
[name: string]: unknown;
|
|
503
|
+
};
|
|
504
|
+
content: {
|
|
505
|
+
"application/json": components["schemas"]["PaginatedSinnuCustomerList"];
|
|
506
|
+
};
|
|
507
|
+
};
|
|
508
|
+
};
|
|
509
|
+
};
|
|
510
|
+
customers_create: {
|
|
511
|
+
parameters: {
|
|
512
|
+
query?: never;
|
|
513
|
+
header?: never;
|
|
514
|
+
path?: never;
|
|
515
|
+
cookie?: never;
|
|
516
|
+
};
|
|
517
|
+
requestBody: {
|
|
518
|
+
content: {
|
|
519
|
+
"application/json": components["schemas"]["SinnuCustomer"];
|
|
520
|
+
"application/x-www-form-urlencoded": components["schemas"]["SinnuCustomer"];
|
|
521
|
+
"multipart/form-data": components["schemas"]["SinnuCustomer"];
|
|
522
|
+
};
|
|
523
|
+
};
|
|
524
|
+
responses: {
|
|
525
|
+
201: {
|
|
526
|
+
headers: {
|
|
527
|
+
[name: string]: unknown;
|
|
528
|
+
};
|
|
529
|
+
content: {
|
|
530
|
+
"application/json": components["schemas"]["SinnuCustomer"];
|
|
531
|
+
};
|
|
532
|
+
};
|
|
533
|
+
};
|
|
534
|
+
};
|
|
535
|
+
customers_retrieve: {
|
|
536
|
+
parameters: {
|
|
537
|
+
query?: never;
|
|
538
|
+
header?: never;
|
|
539
|
+
path: {
|
|
540
|
+
id: string;
|
|
541
|
+
};
|
|
542
|
+
cookie?: never;
|
|
543
|
+
};
|
|
544
|
+
requestBody?: never;
|
|
545
|
+
responses: {
|
|
546
|
+
200: {
|
|
547
|
+
headers: {
|
|
548
|
+
[name: string]: unknown;
|
|
549
|
+
};
|
|
550
|
+
content: {
|
|
551
|
+
"application/json": components["schemas"]["SinnuCustomer"];
|
|
552
|
+
};
|
|
553
|
+
};
|
|
554
|
+
};
|
|
555
|
+
};
|
|
556
|
+
customers_partial_update: {
|
|
557
|
+
parameters: {
|
|
558
|
+
query?: never;
|
|
559
|
+
header?: never;
|
|
560
|
+
path: {
|
|
561
|
+
id: string;
|
|
562
|
+
};
|
|
563
|
+
cookie?: never;
|
|
564
|
+
};
|
|
565
|
+
requestBody?: {
|
|
566
|
+
content: {
|
|
567
|
+
"application/json": components["schemas"]["PatchedSinnuCustomer"];
|
|
568
|
+
"application/x-www-form-urlencoded": components["schemas"]["PatchedSinnuCustomer"];
|
|
569
|
+
"multipart/form-data": components["schemas"]["PatchedSinnuCustomer"];
|
|
570
|
+
};
|
|
571
|
+
};
|
|
572
|
+
responses: {
|
|
573
|
+
200: {
|
|
574
|
+
headers: {
|
|
575
|
+
[name: string]: unknown;
|
|
576
|
+
};
|
|
577
|
+
content: {
|
|
578
|
+
"application/json": components["schemas"]["SinnuCustomer"];
|
|
579
|
+
};
|
|
580
|
+
};
|
|
581
|
+
};
|
|
582
|
+
};
|
|
583
|
+
paymentLinks_list: {
|
|
584
|
+
parameters: {
|
|
585
|
+
query?: {
|
|
586
|
+
page?: number;
|
|
587
|
+
pageSize?: number;
|
|
588
|
+
};
|
|
589
|
+
header?: never;
|
|
590
|
+
path?: never;
|
|
591
|
+
cookie?: never;
|
|
592
|
+
};
|
|
593
|
+
requestBody?: never;
|
|
594
|
+
responses: {
|
|
595
|
+
200: {
|
|
596
|
+
headers: {
|
|
597
|
+
[name: string]: unknown;
|
|
598
|
+
};
|
|
599
|
+
content: {
|
|
600
|
+
"application/json": components["schemas"]["PaginatedPaymentLink"];
|
|
601
|
+
};
|
|
602
|
+
};
|
|
603
|
+
/** @description Sua chave de API não tem permissão para consultar este recurso. */
|
|
604
|
+
403: {
|
|
605
|
+
headers: {
|
|
606
|
+
[name: string]: unknown;
|
|
607
|
+
};
|
|
608
|
+
content?: never;
|
|
609
|
+
};
|
|
610
|
+
};
|
|
611
|
+
};
|
|
612
|
+
paymentLinks_create: {
|
|
613
|
+
parameters: {
|
|
614
|
+
query?: never;
|
|
615
|
+
header?: never;
|
|
616
|
+
path?: never;
|
|
617
|
+
cookie?: never;
|
|
618
|
+
};
|
|
619
|
+
requestBody: {
|
|
620
|
+
content: {
|
|
621
|
+
"application/json": components["schemas"]["PaymentLinkWrite"];
|
|
622
|
+
"application/x-www-form-urlencoded": components["schemas"]["PaymentLinkWrite"];
|
|
623
|
+
"multipart/form-data": components["schemas"]["PaymentLinkWrite"];
|
|
624
|
+
};
|
|
625
|
+
};
|
|
626
|
+
responses: {
|
|
627
|
+
201: {
|
|
628
|
+
headers: {
|
|
629
|
+
[name: string]: unknown;
|
|
630
|
+
};
|
|
631
|
+
content: {
|
|
632
|
+
"application/json": components["schemas"]["PaymentLinkRead"];
|
|
633
|
+
};
|
|
634
|
+
};
|
|
635
|
+
/** @description Sua chave de API não tem permissão para criar ou alterar links de pagamento. */
|
|
636
|
+
403: {
|
|
637
|
+
headers: {
|
|
638
|
+
[name: string]: unknown;
|
|
639
|
+
};
|
|
640
|
+
content?: never;
|
|
641
|
+
};
|
|
642
|
+
};
|
|
643
|
+
};
|
|
644
|
+
paymentLinks_retrieve: {
|
|
645
|
+
parameters: {
|
|
646
|
+
query?: never;
|
|
647
|
+
header?: never;
|
|
648
|
+
path: {
|
|
649
|
+
id: string;
|
|
650
|
+
};
|
|
651
|
+
cookie?: never;
|
|
652
|
+
};
|
|
653
|
+
requestBody?: never;
|
|
654
|
+
responses: {
|
|
655
|
+
200: {
|
|
656
|
+
headers: {
|
|
657
|
+
[name: string]: unknown;
|
|
658
|
+
};
|
|
659
|
+
content: {
|
|
660
|
+
"application/json": components["schemas"]["PaymentLinkRead"];
|
|
661
|
+
};
|
|
662
|
+
};
|
|
663
|
+
/** @description Sua chave de API não tem permissão para consultar este recurso. */
|
|
664
|
+
403: {
|
|
665
|
+
headers: {
|
|
666
|
+
[name: string]: unknown;
|
|
667
|
+
};
|
|
668
|
+
content?: never;
|
|
669
|
+
};
|
|
670
|
+
};
|
|
671
|
+
};
|
|
672
|
+
paymentLinks_destroy: {
|
|
673
|
+
parameters: {
|
|
674
|
+
query?: never;
|
|
675
|
+
header?: never;
|
|
676
|
+
path: {
|
|
677
|
+
id: string;
|
|
678
|
+
};
|
|
679
|
+
cookie?: never;
|
|
680
|
+
};
|
|
681
|
+
requestBody?: never;
|
|
682
|
+
responses: {
|
|
683
|
+
/** @description No response body */
|
|
684
|
+
204: {
|
|
685
|
+
headers: {
|
|
686
|
+
[name: string]: unknown;
|
|
687
|
+
};
|
|
688
|
+
content?: never;
|
|
689
|
+
};
|
|
690
|
+
/** @description Sua chave de API não tem permissão para criar ou alterar links de pagamento. */
|
|
691
|
+
403: {
|
|
692
|
+
headers: {
|
|
693
|
+
[name: string]: unknown;
|
|
694
|
+
};
|
|
695
|
+
content?: never;
|
|
696
|
+
};
|
|
697
|
+
};
|
|
698
|
+
};
|
|
699
|
+
paymentLinks_partialUpdate: {
|
|
700
|
+
parameters: {
|
|
701
|
+
query?: never;
|
|
702
|
+
header?: never;
|
|
703
|
+
path: {
|
|
704
|
+
id: string;
|
|
705
|
+
};
|
|
706
|
+
cookie?: never;
|
|
707
|
+
};
|
|
708
|
+
requestBody?: {
|
|
709
|
+
content: {
|
|
710
|
+
"application/json": components["schemas"]["PatchedPaymentLinkWrite"];
|
|
711
|
+
"application/x-www-form-urlencoded": components["schemas"]["PatchedPaymentLinkWrite"];
|
|
712
|
+
"multipart/form-data": components["schemas"]["PatchedPaymentLinkWrite"];
|
|
713
|
+
};
|
|
714
|
+
};
|
|
715
|
+
responses: {
|
|
716
|
+
200: {
|
|
717
|
+
headers: {
|
|
718
|
+
[name: string]: unknown;
|
|
719
|
+
};
|
|
720
|
+
content: {
|
|
721
|
+
"application/json": components["schemas"]["PaymentLinkRead"];
|
|
722
|
+
};
|
|
723
|
+
};
|
|
724
|
+
/** @description Sua chave de API não tem permissão para criar ou alterar links de pagamento. */
|
|
725
|
+
403: {
|
|
726
|
+
headers: {
|
|
727
|
+
[name: string]: unknown;
|
|
728
|
+
};
|
|
729
|
+
content?: never;
|
|
730
|
+
};
|
|
731
|
+
};
|
|
732
|
+
};
|
|
733
|
+
paymentLinks_transactions: {
|
|
734
|
+
parameters: {
|
|
735
|
+
query?: {
|
|
736
|
+
page?: number;
|
|
737
|
+
pageSize?: number;
|
|
738
|
+
};
|
|
739
|
+
header?: never;
|
|
740
|
+
path: {
|
|
741
|
+
id: string;
|
|
742
|
+
};
|
|
743
|
+
cookie?: never;
|
|
744
|
+
};
|
|
745
|
+
requestBody?: never;
|
|
746
|
+
responses: {
|
|
747
|
+
200: {
|
|
748
|
+
headers: {
|
|
749
|
+
[name: string]: unknown;
|
|
750
|
+
};
|
|
751
|
+
content: {
|
|
752
|
+
"application/json": components["schemas"]["PaginatedPaymentLinkTransaction"];
|
|
753
|
+
};
|
|
754
|
+
};
|
|
755
|
+
/** @description Sua chave de API não tem permissão para consultar este recurso. */
|
|
756
|
+
403: {
|
|
757
|
+
headers: {
|
|
758
|
+
[name: string]: unknown;
|
|
759
|
+
};
|
|
760
|
+
content?: never;
|
|
761
|
+
};
|
|
762
|
+
};
|
|
763
|
+
};
|
|
764
|
+
transactions_list: {
|
|
765
|
+
parameters: {
|
|
766
|
+
query?: {
|
|
767
|
+
/** @description Filtra as transações por ID do cliente (Customer.id, UUID). */
|
|
768
|
+
customer?: string;
|
|
769
|
+
/** @description Número da página (1-based, default 1). */
|
|
770
|
+
page?: number;
|
|
771
|
+
/** @description Itens por página (default 20, máx. 100). */
|
|
772
|
+
pageSize?: number;
|
|
773
|
+
/** @description Busca por nome/e-mail do cliente ou descrição. */
|
|
774
|
+
search?: string;
|
|
775
|
+
/** @description Filtra pelo status do painel: approved | pending | refused | refunded | chargeback. */
|
|
776
|
+
status?: string;
|
|
777
|
+
};
|
|
778
|
+
header?: never;
|
|
779
|
+
path?: never;
|
|
780
|
+
cookie?: never;
|
|
781
|
+
};
|
|
782
|
+
requestBody?: never;
|
|
783
|
+
responses: {
|
|
784
|
+
200: {
|
|
785
|
+
headers: {
|
|
786
|
+
[name: string]: unknown;
|
|
787
|
+
};
|
|
788
|
+
content: {
|
|
789
|
+
"application/json": components["schemas"]["PaginatedSinnuTransactionList"];
|
|
790
|
+
};
|
|
791
|
+
};
|
|
792
|
+
/** @description Sua chave de API não tem permissão para consultar transações. */
|
|
793
|
+
403: {
|
|
794
|
+
headers: {
|
|
795
|
+
[name: string]: unknown;
|
|
796
|
+
};
|
|
797
|
+
content?: never;
|
|
798
|
+
};
|
|
799
|
+
};
|
|
800
|
+
};
|
|
801
|
+
transactions_retrieve: {
|
|
802
|
+
parameters: {
|
|
803
|
+
query?: never;
|
|
804
|
+
header?: never;
|
|
805
|
+
path: {
|
|
806
|
+
id: string;
|
|
807
|
+
};
|
|
808
|
+
cookie?: never;
|
|
809
|
+
};
|
|
810
|
+
requestBody?: never;
|
|
811
|
+
responses: {
|
|
812
|
+
200: {
|
|
813
|
+
headers: {
|
|
814
|
+
[name: string]: unknown;
|
|
815
|
+
};
|
|
816
|
+
content: {
|
|
817
|
+
"application/json": components["schemas"]["SinnuTransaction"];
|
|
818
|
+
};
|
|
819
|
+
};
|
|
820
|
+
/** @description Sua chave de API não tem permissão para consultar transações. */
|
|
821
|
+
403: {
|
|
822
|
+
headers: {
|
|
823
|
+
[name: string]: unknown;
|
|
824
|
+
};
|
|
825
|
+
content?: never;
|
|
826
|
+
};
|
|
827
|
+
};
|
|
828
|
+
};
|
|
829
|
+
transactions_refund: {
|
|
830
|
+
parameters: {
|
|
831
|
+
query?: never;
|
|
832
|
+
header?: {
|
|
833
|
+
/** @description Chave de idempotência: reenvios com a mesma chave numa transação já estornada retornam a transação atual sem reexecutar o estorno. */
|
|
834
|
+
"Idempotency-Key"?: string;
|
|
835
|
+
};
|
|
836
|
+
path: {
|
|
837
|
+
id: string;
|
|
838
|
+
};
|
|
839
|
+
cookie?: never;
|
|
840
|
+
};
|
|
841
|
+
requestBody?: {
|
|
842
|
+
content: {
|
|
843
|
+
"application/json": components["schemas"]["SinnuRefundRequest"];
|
|
844
|
+
"application/x-www-form-urlencoded": components["schemas"]["SinnuRefundRequest"];
|
|
845
|
+
"multipart/form-data": components["schemas"]["SinnuRefundRequest"];
|
|
846
|
+
};
|
|
847
|
+
};
|
|
848
|
+
responses: {
|
|
849
|
+
200: {
|
|
850
|
+
headers: {
|
|
851
|
+
[name: string]: unknown;
|
|
852
|
+
};
|
|
853
|
+
content: {
|
|
854
|
+
"application/json": components["schemas"]["SinnuTransaction"];
|
|
855
|
+
};
|
|
856
|
+
};
|
|
857
|
+
/** @description Sua chave de API não tem o escopo `transactions:refund`, exigido para solicitar estorno. */
|
|
858
|
+
403: {
|
|
859
|
+
headers: {
|
|
860
|
+
[name: string]: unknown;
|
|
861
|
+
};
|
|
862
|
+
content?: never;
|
|
863
|
+
};
|
|
864
|
+
};
|
|
865
|
+
};
|
|
866
|
+
}
|
|
867
|
+
|
|
868
|
+
/** URL de produção padrão da API sinnu. */
|
|
869
|
+
declare const DEFAULT_BASE_URL = "https://api.sinnu.com.br";
|
|
870
|
+
interface SinnuOptions {
|
|
871
|
+
/**
|
|
872
|
+
* API key secreta do servidor (`sk_live_...`).
|
|
873
|
+
* Enviada como `Authorization: Bearer <apiKey>`.
|
|
874
|
+
*/
|
|
875
|
+
apiKey: string;
|
|
876
|
+
/** Base URL da API. Default: {@link DEFAULT_BASE_URL}. */
|
|
877
|
+
baseUrl?: string;
|
|
878
|
+
/**
|
|
879
|
+
* Base URL do checkout hosted (`pay.sinnu.com.br`). Usada por
|
|
880
|
+
* `sinnu.checkout.url(slug)`. Default em produção.
|
|
881
|
+
*/
|
|
882
|
+
checkoutBaseUrl?: string;
|
|
883
|
+
/** Headers extras enviados em toda requisição. */
|
|
884
|
+
headers?: Record<string, string>;
|
|
885
|
+
/** Implementação de fetch customizada (ex.: para Node < 18 ou testes). */
|
|
886
|
+
fetch?: typeof fetch;
|
|
887
|
+
}
|
|
888
|
+
/**
|
|
889
|
+
* Cria o client HTTP tipado (openapi-fetch) com a auth por API key já aplicada.
|
|
890
|
+
* Normalmente você usa a classe {@link SinnuClient} em vez desta função.
|
|
891
|
+
*/
|
|
892
|
+
declare function createTypedClient(options: SinnuOptions): Client<paths>;
|
|
893
|
+
/**
|
|
894
|
+
* Desempacota uma resposta do openapi-fetch: devolve `data` em caso de sucesso
|
|
895
|
+
* ou lança um {@link SinnuError} tipado em caso de falha.
|
|
896
|
+
*/
|
|
897
|
+
declare function unwrap<T extends Record<string | number, unknown>, Options, Media extends `${string}/${string}`>(p: Promise<FetchResponse<T, Options, Media>>): Promise<ParseAsResponse<SuccessResponse<ResponseObjectMap<T>, Media>, Options>>;
|
|
898
|
+
type TypedClient = Client<paths>;
|
|
899
|
+
interface RawRequestOptions {
|
|
900
|
+
method?: "GET" | "POST" | "PUT" | "PATCH" | "DELETE";
|
|
901
|
+
/** Query string params (valores serializados; undefined é omitido). */
|
|
902
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
903
|
+
/** Corpo JSON da requisição. */
|
|
904
|
+
body?: unknown;
|
|
905
|
+
}
|
|
906
|
+
/**
|
|
907
|
+
* Cliente de baixo nível para recursos do SDK que usam o contrato público atual.
|
|
908
|
+
* Aplica a mesma auth por API key e normaliza erros em {@link SinnuError}.
|
|
909
|
+
*/
|
|
910
|
+
declare class RawHttp {
|
|
911
|
+
private readonly baseUrl;
|
|
912
|
+
private readonly apiKey;
|
|
913
|
+
private readonly extraHeaders;
|
|
914
|
+
private readonly fetchImpl;
|
|
915
|
+
constructor(baseUrl: string, apiKey: string, extraHeaders: Record<string, string>, fetchImpl: typeof fetch);
|
|
916
|
+
request<T>(path: string, options?: RawRequestOptions): Promise<T>;
|
|
917
|
+
}
|
|
918
|
+
|
|
919
|
+
/** URL pública padrão do checkout hosted do sinnu. */
|
|
920
|
+
declare const DEFAULT_CHECKOUT_BASE_URL = "https://pay.sinnu.com.br";
|
|
921
|
+
interface CheckoutUrlOptions {
|
|
922
|
+
/**
|
|
923
|
+
* Base URL do checkout hosted. Default: {@link DEFAULT_CHECKOUT_BASE_URL}.
|
|
924
|
+
* Útil para apontar para staging/local.
|
|
925
|
+
*/
|
|
926
|
+
checkoutBaseUrl?: string;
|
|
927
|
+
/**
|
|
928
|
+
* Pedido do seu sistema para ESTA venda. Vai como `?ref=` na URL, fica gravado
|
|
929
|
+
* na venda e volta como `reference` na transação, no webhook e no retorno para
|
|
930
|
+
* o `redirectUrl` do link. Até 255 caracteres.
|
|
931
|
+
*/
|
|
932
|
+
reference?: string;
|
|
933
|
+
/**
|
|
934
|
+
* Query params extras anexados à URL (ex.: `utm_source`).
|
|
935
|
+
* Valores `undefined` são omitidos.
|
|
936
|
+
*/
|
|
937
|
+
query?: Record<string, string | number | boolean | undefined>;
|
|
938
|
+
}
|
|
939
|
+
/** Recurso de checkout: construtor de URL pública hosted por slug. */
|
|
940
|
+
declare class Checkout {
|
|
941
|
+
private readonly options;
|
|
942
|
+
constructor(options?: CheckoutUrlOptions);
|
|
943
|
+
/**
|
|
944
|
+
* Monta a URL pública do checkout hosted para um `slug` (8 chars) gerado
|
|
945
|
+
* ao criar um link (`sinnu.links.create(...).url` já vem pronto; este
|
|
946
|
+
* helper é útil quando você só tem o slug).
|
|
947
|
+
*
|
|
948
|
+
* @example
|
|
949
|
+
* const url = sinnu.checkout.url("abcd1234", { reference: "pedido-123" });
|
|
950
|
+
* // => "https://pay.sinnu.com.br/abcd1234?ref=pedido-123"
|
|
951
|
+
*/
|
|
952
|
+
url(slug: string, options?: CheckoutUrlOptions): string;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/** Página de uma listagem da API sinnu. */
|
|
956
|
+
interface Page<T> {
|
|
957
|
+
data: T[];
|
|
958
|
+
total: number;
|
|
959
|
+
page: number;
|
|
960
|
+
pageSize: number;
|
|
961
|
+
}
|
|
962
|
+
/** Parâmetros de paginação aceitos pelas listagens. */
|
|
963
|
+
interface PageParams {
|
|
964
|
+
page?: number;
|
|
965
|
+
pageSize?: number;
|
|
966
|
+
}
|
|
967
|
+
/**
|
|
968
|
+
* Itera, página a página, sobre um endpoint paginado.
|
|
969
|
+
*
|
|
970
|
+
* @param fetchPage Função que recebe o número da página e devolve uma `Page<T>`.
|
|
971
|
+
* @example
|
|
972
|
+
* for await (const tx of paginate((page) => sinnu.transactions.list({ page }))) {
|
|
973
|
+
* console.log(tx.id);
|
|
974
|
+
* }
|
|
975
|
+
*/
|
|
976
|
+
declare function paginate<T>(fetchPage: (page: number) => Promise<Page<T>>): AsyncGenerator<T, void, undefined>;
|
|
977
|
+
/** Coleta todas as páginas em um único array (cuidado com listas muito grandes). */
|
|
978
|
+
declare function collectAll<T>(fetchPage: (page: number) => Promise<Page<T>>): Promise<T[]>;
|
|
979
|
+
|
|
980
|
+
type PaymentMethod = "pix" | "credit_card" | "applepay" | "googlepay";
|
|
981
|
+
type PriceMode = "fixed";
|
|
982
|
+
type InterestMode = "absorb" | "pass_to_customer";
|
|
983
|
+
type PaymentLinkStatus = "active" | "paused" | "archived";
|
|
984
|
+
type ThreeDsMode = "always" | "contingency";
|
|
985
|
+
type TransactionStatus = "approved" | "pending" | "refused" | "refunded" | "chargeback" | (string & {});
|
|
986
|
+
interface PaymentLink {
|
|
987
|
+
id: string;
|
|
988
|
+
slug: string;
|
|
989
|
+
title: string;
|
|
990
|
+
description: string;
|
|
991
|
+
imageUrl: string | null;
|
|
992
|
+
priceMode: PriceMode;
|
|
993
|
+
amountCents: number | null;
|
|
994
|
+
minAmountCents: number | null;
|
|
995
|
+
maxAmountCents: number | null;
|
|
996
|
+
methods: PaymentMethod[];
|
|
997
|
+
maxInstallments: number;
|
|
998
|
+
interestMode: InterestMode;
|
|
999
|
+
status: PaymentLinkStatus;
|
|
1000
|
+
threeDsMode: ThreeDsMode;
|
|
1001
|
+
tags: string[];
|
|
1002
|
+
/** Retorno depois do pagamento confirmado: `https://` ou deep link do app. */
|
|
1003
|
+
redirectUrl: string | null;
|
|
1004
|
+
/** Código do produto no seu sistema; volta como `externalRef` do item. */
|
|
1005
|
+
externalReference: string | null;
|
|
1006
|
+
linkedCustomerId: string | null;
|
|
1007
|
+
companyId?: number | null;
|
|
1008
|
+
companyName?: string | null;
|
|
1009
|
+
sellerEmail?: string | null;
|
|
1010
|
+
createdAt: string;
|
|
1011
|
+
updatedAt: string;
|
|
1012
|
+
}
|
|
1013
|
+
interface CreatePaymentLinkBody {
|
|
1014
|
+
title: string;
|
|
1015
|
+
description?: string;
|
|
1016
|
+
imageUrl?: string | null;
|
|
1017
|
+
priceMode?: PriceMode;
|
|
1018
|
+
amountCents: number;
|
|
1019
|
+
methods?: PaymentMethod[];
|
|
1020
|
+
maxInstallments?: number;
|
|
1021
|
+
interestMode?: InterestMode;
|
|
1022
|
+
status?: PaymentLinkStatus;
|
|
1023
|
+
threeDsMode?: ThreeDsMode;
|
|
1024
|
+
tags?: string[];
|
|
1025
|
+
/**
|
|
1026
|
+
* Para onde o checkout leva o comprador depois do pagamento confirmado, com
|
|
1027
|
+
* `transactionId`, `reference` e `status=approved` na query. `https://` ou o
|
|
1028
|
+
* esquema do seu app (`meuapp://pedido`).
|
|
1029
|
+
*/
|
|
1030
|
+
redirectUrl?: string | null;
|
|
1031
|
+
/** Código do produto no seu sistema; volta como `externalRef` do item. */
|
|
1032
|
+
externalReference?: string | null;
|
|
1033
|
+
linkedCustomer?: string | null;
|
|
1034
|
+
}
|
|
1035
|
+
type UpdatePaymentLinkBody = Partial<CreatePaymentLinkBody>;
|
|
1036
|
+
interface PaymentLinkTransaction {
|
|
1037
|
+
id: string;
|
|
1038
|
+
amount: number;
|
|
1039
|
+
status: string;
|
|
1040
|
+
paymentMethod: string;
|
|
1041
|
+
installments: number;
|
|
1042
|
+
customer: {
|
|
1043
|
+
id: string;
|
|
1044
|
+
name: string;
|
|
1045
|
+
email: string;
|
|
1046
|
+
};
|
|
1047
|
+
createdAt: string;
|
|
1048
|
+
paidAt: string | null;
|
|
1049
|
+
}
|
|
1050
|
+
interface Transaction {
|
|
1051
|
+
id: string;
|
|
1052
|
+
amount: number;
|
|
1053
|
+
net: number;
|
|
1054
|
+
productAmount: number;
|
|
1055
|
+
interestAmount: number;
|
|
1056
|
+
interestMode: InterestMode | null;
|
|
1057
|
+
mdrAmount: number;
|
|
1058
|
+
fixedFeeAmount: number;
|
|
1059
|
+
otherFeeAmount: number;
|
|
1060
|
+
totalFeeAmount: number;
|
|
1061
|
+
status: TransactionStatus;
|
|
1062
|
+
method: PaymentMethod | (string & {});
|
|
1063
|
+
customer: {
|
|
1064
|
+
id?: string;
|
|
1065
|
+
name?: string;
|
|
1066
|
+
email?: string;
|
|
1067
|
+
[key: string]: unknown;
|
|
1068
|
+
};
|
|
1069
|
+
description: string;
|
|
1070
|
+
installments: number;
|
|
1071
|
+
createdAt: string;
|
|
1072
|
+
paidAt: string | null;
|
|
1073
|
+
/** Pedido do seu sistema para esta venda (`?ref=` do checkout). */
|
|
1074
|
+
reference: string | null;
|
|
1075
|
+
}
|
|
1076
|
+
|
|
1077
|
+
interface ListPaymentLinksParams extends PageParams {
|
|
1078
|
+
}
|
|
1079
|
+
declare class Links {
|
|
1080
|
+
private readonly http;
|
|
1081
|
+
constructor(http: RawHttp);
|
|
1082
|
+
/** Cria um link de pagamento (valor em centavos). */
|
|
1083
|
+
create(body: CreatePaymentLinkBody): Promise<PaymentLink>;
|
|
1084
|
+
/** Busca um link de pagamento pelo id. */
|
|
1085
|
+
get(id: string): Promise<PaymentLink>;
|
|
1086
|
+
/** Atualiza parcialmente um link de pagamento. */
|
|
1087
|
+
update(id: string, body: UpdatePaymentLinkBody): Promise<PaymentLink>;
|
|
1088
|
+
/** Arquiva um link de pagamento. */
|
|
1089
|
+
archive(id: string): Promise<void>;
|
|
1090
|
+
/** Lista links de pagamento (paginado). */
|
|
1091
|
+
list(params?: ListPaymentLinksParams): Promise<Page<PaymentLink>>;
|
|
1092
|
+
/** Lista transações de um link de pagamento (paginado). */
|
|
1093
|
+
transactions(id: string, params?: PageParams): Promise<Page<PaymentLinkTransaction>>;
|
|
1094
|
+
/** Itera todos os links de pagamento, página a página. */
|
|
1095
|
+
listAll(params?: ListPaymentLinksParams): AsyncGenerator<PaymentLink>;
|
|
1096
|
+
}
|
|
1097
|
+
|
|
1098
|
+
interface ListTransactionsParams extends PageParams {
|
|
1099
|
+
/** Filtra por status (approved, pending, refused, refunded, chargeback). */
|
|
1100
|
+
status?: string;
|
|
1101
|
+
/** Busca por nome/e-mail do cliente ou descrição. */
|
|
1102
|
+
search?: string;
|
|
1103
|
+
/** Filtra por ID do cliente. */
|
|
1104
|
+
customer?: string;
|
|
1105
|
+
}
|
|
1106
|
+
interface RefundTransactionBody {
|
|
1107
|
+
reason?: string;
|
|
1108
|
+
note?: string;
|
|
1109
|
+
}
|
|
1110
|
+
declare class Transactions {
|
|
1111
|
+
private readonly http;
|
|
1112
|
+
constructor(http: RawHttp);
|
|
1113
|
+
/** Lista transações (paginado, com filtro opcional por status). */
|
|
1114
|
+
list(params?: ListTransactionsParams): Promise<Page<Transaction>>;
|
|
1115
|
+
/** Busca uma transação pelo id. */
|
|
1116
|
+
get(id: string): Promise<Transaction>;
|
|
1117
|
+
/** Estorna (refund) uma transação, sempre pelo valor total. Exige o escopo `transactions:refund` na chave. */
|
|
1118
|
+
refund(id: string, body?: RefundTransactionBody): Promise<Transaction>;
|
|
1119
|
+
/** Itera todas as transações, página a página. */
|
|
1120
|
+
listAll(params?: ListTransactionsParams): AsyncGenerator<Transaction>;
|
|
1121
|
+
}
|
|
1122
|
+
|
|
1123
|
+
/** Payload de erro padrão da API sinnu: `{ status: "error", message: "..." }`. */
|
|
1124
|
+
interface SinnuApiErrorBody {
|
|
1125
|
+
status?: string;
|
|
1126
|
+
message?: string;
|
|
1127
|
+
[key: string]: unknown;
|
|
1128
|
+
}
|
|
1129
|
+
/** Erro base de qualquer resposta de falha da API sinnu. */
|
|
1130
|
+
declare class SinnuError extends Error {
|
|
1131
|
+
/** Status HTTP da resposta (0 quando o erro é de rede/transporte). */
|
|
1132
|
+
readonly statusCode: number;
|
|
1133
|
+
/** Corpo de erro retornado pela API, quando houver. */
|
|
1134
|
+
readonly body?: SinnuApiErrorBody;
|
|
1135
|
+
/** Resposta `fetch` crua, quando disponível. */
|
|
1136
|
+
readonly response?: Response;
|
|
1137
|
+
constructor(message: string, statusCode: number, body?: SinnuApiErrorBody, response?: Response);
|
|
1138
|
+
}
|
|
1139
|
+
/** 401 (chave ausente, inválida ou expirada) ou 403 (chave sem permissão). */
|
|
1140
|
+
declare class SinnuAuthError extends SinnuError {
|
|
1141
|
+
constructor(message: string, statusCode?: 401 | 403, body?: SinnuApiErrorBody, response?: Response);
|
|
1142
|
+
}
|
|
1143
|
+
/** 404: recurso não encontrado. */
|
|
1144
|
+
declare class SinnuNotFoundError extends SinnuError {
|
|
1145
|
+
constructor(message: string, body?: SinnuApiErrorBody, response?: Response);
|
|
1146
|
+
}
|
|
1147
|
+
/** 400/422: payload inválido (validação). */
|
|
1148
|
+
declare class SinnuValidationError extends SinnuError {
|
|
1149
|
+
constructor(message: string, statusCode: number, body?: SinnuApiErrorBody, response?: Response);
|
|
1150
|
+
}
|
|
1151
|
+
/** 429: limite de requisições atingido. */
|
|
1152
|
+
declare class SinnuRateLimitError extends SinnuError {
|
|
1153
|
+
constructor(message: string, body?: SinnuApiErrorBody, response?: Response);
|
|
1154
|
+
}
|
|
1155
|
+
|
|
1156
|
+
/** Header padrão onde a Sinnu envia a assinatura HMAC do webhook. */
|
|
1157
|
+
declare const SINNU_SIGNATURE_HEADER = "x-sinnu-signature";
|
|
1158
|
+
type SinnuWebhookEventType = "transaction.approved" | "transaction.declined" | "transaction.refunded" | "transaction.canceled" | "transaction.changed" | "transaction.chargeback" | "withdrawal.approved" | "account.changed" | "account.approved" | "account.declined" | (string & {});
|
|
1159
|
+
/** Envelope de um evento de webhook da Sinnu. */
|
|
1160
|
+
interface SinnuWebhookEvent<T = Record<string, unknown>> {
|
|
1161
|
+
version?: string;
|
|
1162
|
+
/** Tipo do evento, por exemplo `transaction.approved`. */
|
|
1163
|
+
type: SinnuWebhookEventType;
|
|
1164
|
+
/** Carga útil do evento. */
|
|
1165
|
+
data: T;
|
|
1166
|
+
[key: string]: unknown;
|
|
1167
|
+
}
|
|
1168
|
+
/** Link de pagamento que originou a venda. O título é o nome do produto. */
|
|
1169
|
+
interface SinnuWebhookLink {
|
|
1170
|
+
id: string;
|
|
1171
|
+
title: string;
|
|
1172
|
+
}
|
|
1173
|
+
/** Item vendido. `unitPrice` em reais, como `amount`. */
|
|
1174
|
+
interface SinnuWebhookItem {
|
|
1175
|
+
title: string;
|
|
1176
|
+
quantity: number;
|
|
1177
|
+
unitPrice: number | null;
|
|
1178
|
+
externalRef: string | null;
|
|
1179
|
+
}
|
|
1180
|
+
/** Membro da equipe responsável pela venda, escolhido no link. */
|
|
1181
|
+
interface SinnuWebhookSalesperson {
|
|
1182
|
+
id: number;
|
|
1183
|
+
name: string;
|
|
1184
|
+
email: string;
|
|
1185
|
+
}
|
|
1186
|
+
/** Comprador. O documento sai sempre mascarado. */
|
|
1187
|
+
interface SinnuWebhookCustomer {
|
|
1188
|
+
name: string;
|
|
1189
|
+
email: string;
|
|
1190
|
+
document: string | null;
|
|
1191
|
+
phone: string | null;
|
|
1192
|
+
}
|
|
1193
|
+
/** `data` dos eventos `transaction.*`. Valores em reais. */
|
|
1194
|
+
interface SinnuTransactionWebhookData {
|
|
1195
|
+
id: string;
|
|
1196
|
+
status: string;
|
|
1197
|
+
amount: number;
|
|
1198
|
+
currency: string;
|
|
1199
|
+
installments: number;
|
|
1200
|
+
paymentMethod: string;
|
|
1201
|
+
createdAt: string;
|
|
1202
|
+
card: {
|
|
1203
|
+
lastDigits: string;
|
|
1204
|
+
brand: string;
|
|
1205
|
+
} | null;
|
|
1206
|
+
customer: SinnuWebhookCustomer;
|
|
1207
|
+
/** `null` quando a cobrança foi criada pela API, sem link. */
|
|
1208
|
+
link: SinnuWebhookLink | null;
|
|
1209
|
+
/** Pedido do seu sistema para esta venda (`?ref=` do checkout). */
|
|
1210
|
+
reference: string | null;
|
|
1211
|
+
items: SinnuWebhookItem[];
|
|
1212
|
+
/** `null` quando o link não tem vendedor responsável. */
|
|
1213
|
+
salesperson: SinnuWebhookSalesperson | null;
|
|
1214
|
+
}
|
|
1215
|
+
/** Erro lançado quando a assinatura de um webhook é inválida ou ausente. */
|
|
1216
|
+
declare class SinnuWebhookSignatureError extends SinnuError {
|
|
1217
|
+
constructor(message: string);
|
|
1218
|
+
}
|
|
1219
|
+
interface VerifyWebhookOptions {
|
|
1220
|
+
/**
|
|
1221
|
+
* Corpo cru da requisição, exatamente como recebido. Não use JSON já parseado.
|
|
1222
|
+
*/
|
|
1223
|
+
payload: string | Buffer;
|
|
1224
|
+
/**
|
|
1225
|
+
* Valor do header de assinatura. Pode vir como `"<hex>"` ou `"sha256=<hex>"`.
|
|
1226
|
+
*/
|
|
1227
|
+
signature: string | string[] | undefined;
|
|
1228
|
+
/** Webhook secret do seller, gerado no painel em Integrações. */
|
|
1229
|
+
secret: string;
|
|
1230
|
+
}
|
|
1231
|
+
/** Calcula a assinatura HMAC SHA-256 em hexadecimal. */
|
|
1232
|
+
declare function computeSignature(payload: string | Buffer, secret: string): string;
|
|
1233
|
+
/**
|
|
1234
|
+
* Verifica a assinatura HMAC SHA-256 de um webhook da Sinnu.
|
|
1235
|
+
*
|
|
1236
|
+
* @returns `true` se a assinatura for válida.
|
|
1237
|
+
* @throws {SinnuWebhookSignatureError} se o header estiver ausente ou vazio.
|
|
1238
|
+
*/
|
|
1239
|
+
declare function verifySignature(options: VerifyWebhookOptions): boolean;
|
|
1240
|
+
/**
|
|
1241
|
+
* Verifica a assinatura e desserializa o evento de webhook da Sinnu.
|
|
1242
|
+
*
|
|
1243
|
+
* @example
|
|
1244
|
+
* app.post("/webhooks/sinnu", express.raw({ type: "application/json" }), (req, res) => {
|
|
1245
|
+
* try {
|
|
1246
|
+
* const event = constructEvent({
|
|
1247
|
+
* payload: req.body,
|
|
1248
|
+
* signature: req.header("X-Sinnu-Signature"),
|
|
1249
|
+
* secret: process.env.SINNU_WEBHOOK_SECRET!,
|
|
1250
|
+
* });
|
|
1251
|
+
* if (event.type === "transaction.approved") liberarProduto(event.data);
|
|
1252
|
+
* res.sendStatus(200);
|
|
1253
|
+
* } catch {
|
|
1254
|
+
* res.sendStatus(400);
|
|
1255
|
+
* }
|
|
1256
|
+
* });
|
|
1257
|
+
*
|
|
1258
|
+
* @throws {SinnuWebhookSignatureError} se a assinatura for inválida ou ausente.
|
|
1259
|
+
*/
|
|
1260
|
+
declare function constructEvent<T = Record<string, unknown>>(options: VerifyWebhookOptions): SinnuWebhookEvent<T>;
|
|
1261
|
+
/** Coleção de helpers de webhook, exposta também em `sinnu.webhooks`. */
|
|
1262
|
+
declare const webhooks: {
|
|
1263
|
+
readonly signatureHeader: "x-sinnu-signature";
|
|
1264
|
+
readonly computeSignature: typeof computeSignature;
|
|
1265
|
+
readonly verifySignature: typeof verifySignature;
|
|
1266
|
+
readonly constructEvent: typeof constructEvent;
|
|
1267
|
+
};
|
|
1268
|
+
type Webhooks = typeof webhooks;
|
|
1269
|
+
|
|
1270
|
+
/** Client principal do SDK sinnu. */
|
|
1271
|
+
declare class Sinnu {
|
|
1272
|
+
/** Client tipado de baixo nível (openapi-fetch): uso avançado. */
|
|
1273
|
+
readonly http: TypedClient;
|
|
1274
|
+
/** Links de pagamento. */
|
|
1275
|
+
readonly links: Links;
|
|
1276
|
+
/** Transações. */
|
|
1277
|
+
readonly transactions: Transactions;
|
|
1278
|
+
/** Checkout hosted (construtor de URL pública por slug). */
|
|
1279
|
+
readonly checkout: Checkout;
|
|
1280
|
+
/** Verificação de webhooks (HMAC SHA-256): não faz requisições. */
|
|
1281
|
+
readonly webhooks: Webhooks;
|
|
1282
|
+
constructor(options: SinnuOptions);
|
|
1283
|
+
}
|
|
1284
|
+
|
|
1285
|
+
export { Checkout, type CheckoutUrlOptions, type CreatePaymentLinkBody, DEFAULT_BASE_URL, DEFAULT_CHECKOUT_BASE_URL, type ListPaymentLinksParams, type ListTransactionsParams, type Page, type PageParams, type PaymentLink, type PaymentLinkTransaction, type RawRequestOptions, type RefundTransactionBody, SINNU_SIGNATURE_HEADER, Sinnu, type SinnuApiErrorBody, SinnuAuthError, SinnuError, SinnuNotFoundError, type SinnuOptions, SinnuRateLimitError, type SinnuTransactionWebhookData, SinnuValidationError, type SinnuWebhookCustomer, type SinnuWebhookEvent, type SinnuWebhookEventType, type SinnuWebhookItem, type SinnuWebhookLink, type SinnuWebhookSalesperson, SinnuWebhookSignatureError, type Transaction, type TypedClient, type UpdatePaymentLinkBody, type VerifyWebhookOptions, type Webhooks, collectAll, type components, computeSignature, constructEvent, createTypedClient, Sinnu as default, paginate, type paths, unwrap, verifySignature, webhooks };
|