@vitrindigital/node 0.1.0 → 0.2.0
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/dist/index.cjs +51 -0
- package/dist/index.d.cts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +51 -0
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -214,6 +214,19 @@ var Charges = class {
|
|
|
214
214
|
idempotencyKey
|
|
215
215
|
});
|
|
216
216
|
}
|
|
217
|
+
/**
|
|
218
|
+
* One-click buy: cobra usando o cartão preferido salvo do cliente.
|
|
219
|
+
* O cliente precisa ter um saved card (vide `customers.savedCard.create`).
|
|
220
|
+
* Retorna 422 `no_saved_card` se não houver cartão; 422 `card_expired` se vencido.
|
|
221
|
+
*/
|
|
222
|
+
createWithSavedCard(params) {
|
|
223
|
+
const { idempotencyKey, ...body } = params;
|
|
224
|
+
return this.client.request("/charges/charge-saved/", {
|
|
225
|
+
method: "POST",
|
|
226
|
+
body,
|
|
227
|
+
idempotencyKey
|
|
228
|
+
});
|
|
229
|
+
}
|
|
217
230
|
retrieve(id) {
|
|
218
231
|
return this.client.request(`/transactions/${id}/`);
|
|
219
232
|
}
|
|
@@ -243,11 +256,42 @@ var Charges = class {
|
|
|
243
256
|
};
|
|
244
257
|
|
|
245
258
|
// src/resources/customers.ts
|
|
259
|
+
var SavedCardResource = class {
|
|
260
|
+
constructor(client) {
|
|
261
|
+
this.client = client;
|
|
262
|
+
}
|
|
263
|
+
client;
|
|
264
|
+
/** Tokeniza + persiste o cartão preferido do cliente (substitui o anterior). */
|
|
265
|
+
create(customerId, params) {
|
|
266
|
+
return this.client.request(`/customers/${customerId}/saved-card/`, {
|
|
267
|
+
method: "POST",
|
|
268
|
+
body: params
|
|
269
|
+
});
|
|
270
|
+
}
|
|
271
|
+
/** Retorna brand/last4/exp/holder — nunca o token. */
|
|
272
|
+
retrieve(customerId) {
|
|
273
|
+
return this.client.request(`/customers/${customerId}/saved-card/`);
|
|
274
|
+
}
|
|
275
|
+
delete(customerId) {
|
|
276
|
+
return this.client.request(`/customers/${customerId}/saved-card/`, {
|
|
277
|
+
method: "DELETE"
|
|
278
|
+
});
|
|
279
|
+
}
|
|
280
|
+
/** Gera URL assinada (JWT 24h) pro cliente final ver/remover o próprio cartão. */
|
|
281
|
+
createManagementLink(customerId) {
|
|
282
|
+
return this.client.request(
|
|
283
|
+
`/customers/${customerId}/saved-card/management-link/`,
|
|
284
|
+
{ method: "POST" }
|
|
285
|
+
);
|
|
286
|
+
}
|
|
287
|
+
};
|
|
246
288
|
var Customers = class {
|
|
247
289
|
constructor(client) {
|
|
248
290
|
this.client = client;
|
|
291
|
+
this.savedCard = new SavedCardResource(client);
|
|
249
292
|
}
|
|
250
293
|
client;
|
|
294
|
+
savedCard;
|
|
251
295
|
create(params) {
|
|
252
296
|
return this.client.request("/customers/", {
|
|
253
297
|
method: "POST",
|
|
@@ -271,6 +315,13 @@ var Customers = class {
|
|
|
271
315
|
delete(id) {
|
|
272
316
|
return this.client.request(`/customers/${id}/`, { method: "DELETE" });
|
|
273
317
|
}
|
|
318
|
+
/** Gera link assinado de recompra one-click (JWT 15min, uso único). */
|
|
319
|
+
oneClickLink(customerId, params) {
|
|
320
|
+
return this.client.request(
|
|
321
|
+
`/customers/${customerId}/one-click-link/`,
|
|
322
|
+
{ method: "POST", body: params }
|
|
323
|
+
);
|
|
324
|
+
}
|
|
274
325
|
};
|
|
275
326
|
|
|
276
327
|
// src/resources/plans.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -126,6 +126,27 @@ interface PaginatedList<T> {
|
|
|
126
126
|
previous: string | null;
|
|
127
127
|
results: T[];
|
|
128
128
|
}
|
|
129
|
+
/** Metadados do cartão salvo de um Customer (one-click buy). Nunca inclui o token. */
|
|
130
|
+
interface SavedCard {
|
|
131
|
+
brand: string;
|
|
132
|
+
last4: string;
|
|
133
|
+
exp_month: number | null;
|
|
134
|
+
exp_year: number | null;
|
|
135
|
+
holder_name: string;
|
|
136
|
+
consent_at: string | null;
|
|
137
|
+
}
|
|
138
|
+
/** Resposta de POST /customers/{id}/saved-card/management-link/. */
|
|
139
|
+
interface SavedCardManagementLink {
|
|
140
|
+
url: string;
|
|
141
|
+
token: string;
|
|
142
|
+
expires_at: string;
|
|
143
|
+
}
|
|
144
|
+
/** Resposta de POST /customers/{id}/one-click-link/. */
|
|
145
|
+
interface OneClickLink {
|
|
146
|
+
url: string;
|
|
147
|
+
token: string;
|
|
148
|
+
expires_at: string;
|
|
149
|
+
}
|
|
129
150
|
/** Response do GET /balance/. */
|
|
130
151
|
interface Balance {
|
|
131
152
|
available: number;
|
|
@@ -168,6 +189,15 @@ interface CreateChargeParams {
|
|
|
168
189
|
/** Idempotency-Key (header) — recomendado pra evitar duplo-débito em retry. */
|
|
169
190
|
idempotencyKey?: string;
|
|
170
191
|
}
|
|
192
|
+
interface CreateChargeWithSavedCardParams {
|
|
193
|
+
customer_id: string;
|
|
194
|
+
amount: number | string;
|
|
195
|
+
description?: string;
|
|
196
|
+
installments?: number;
|
|
197
|
+
external_reference?: string;
|
|
198
|
+
/** Idempotency-Key (header) — recomendado pra evitar duplo-débito em retry. */
|
|
199
|
+
idempotencyKey?: string;
|
|
200
|
+
}
|
|
171
201
|
interface RefundParams {
|
|
172
202
|
/** Valor parcial em reais. Omitir = reembolso total. */
|
|
173
203
|
amount?: number | string;
|
|
@@ -188,6 +218,12 @@ declare class Charges {
|
|
|
188
218
|
constructor(client: VitrinClient);
|
|
189
219
|
/** Cria uma cobrança avulsa (PIX/Boleto/Cartão). */
|
|
190
220
|
create(params: CreateChargeParams): Promise<Transaction>;
|
|
221
|
+
/**
|
|
222
|
+
* One-click buy: cobra usando o cartão preferido salvo do cliente.
|
|
223
|
+
* O cliente precisa ter um saved card (vide `customers.savedCard.create`).
|
|
224
|
+
* Retorna 422 `no_saved_card` se não houver cartão; 422 `card_expired` se vencido.
|
|
225
|
+
*/
|
|
226
|
+
createWithSavedCard(params: CreateChargeWithSavedCardParams): Promise<Transaction>;
|
|
191
227
|
retrieve(id: string): Promise<Transaction>;
|
|
192
228
|
list(params?: ListChargesParams): Promise<PaginatedList<Transaction>>;
|
|
193
229
|
refund(id: string, params: RefundParams): Promise<Transaction>;
|
|
@@ -214,8 +250,33 @@ interface CreateCustomerParams {
|
|
|
214
250
|
state?: string;
|
|
215
251
|
}
|
|
216
252
|
type UpdateCustomerParams = Partial<CreateCustomerParams>;
|
|
253
|
+
interface SaveCardParams {
|
|
254
|
+
credit_card: {
|
|
255
|
+
holder_name: string;
|
|
256
|
+
number: string;
|
|
257
|
+
expiry_month: string;
|
|
258
|
+
expiry_year: string;
|
|
259
|
+
cvv: string;
|
|
260
|
+
};
|
|
261
|
+
consent: {
|
|
262
|
+
accepted_at: string;
|
|
263
|
+
ip: string;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
declare class SavedCardResource {
|
|
267
|
+
private client;
|
|
268
|
+
constructor(client: VitrinClient);
|
|
269
|
+
/** Tokeniza + persiste o cartão preferido do cliente (substitui o anterior). */
|
|
270
|
+
create(customerId: string, params: SaveCardParams): Promise<SavedCard>;
|
|
271
|
+
/** Retorna brand/last4/exp/holder — nunca o token. */
|
|
272
|
+
retrieve(customerId: string): Promise<SavedCard>;
|
|
273
|
+
delete(customerId: string): Promise<void>;
|
|
274
|
+
/** Gera URL assinada (JWT 24h) pro cliente final ver/remover o próprio cartão. */
|
|
275
|
+
createManagementLink(customerId: string): Promise<SavedCardManagementLink>;
|
|
276
|
+
}
|
|
217
277
|
declare class Customers {
|
|
218
278
|
private client;
|
|
279
|
+
readonly savedCard: SavedCardResource;
|
|
219
280
|
constructor(client: VitrinClient);
|
|
220
281
|
create(params: CreateCustomerParams): Promise<Customer>;
|
|
221
282
|
retrieve(id: string): Promise<Customer>;
|
|
@@ -225,6 +286,16 @@ declare class Customers {
|
|
|
225
286
|
}): Promise<PaginatedList<Customer>>;
|
|
226
287
|
update(id: string, params: UpdateCustomerParams): Promise<Customer>;
|
|
227
288
|
delete(id: string): Promise<void>;
|
|
289
|
+
/** Gera link assinado de recompra one-click (JWT 15min, uso único). */
|
|
290
|
+
oneClickLink(customerId: string, params: {
|
|
291
|
+
product_id?: string;
|
|
292
|
+
plan_id?: string;
|
|
293
|
+
amount?: string;
|
|
294
|
+
installments?: number;
|
|
295
|
+
coupon_code?: string;
|
|
296
|
+
bump_ids?: string[];
|
|
297
|
+
expires_in?: number;
|
|
298
|
+
}): Promise<OneClickLink>;
|
|
228
299
|
}
|
|
229
300
|
|
|
230
301
|
interface CreatePlanParams {
|
package/dist/index.d.ts
CHANGED
|
@@ -126,6 +126,27 @@ interface PaginatedList<T> {
|
|
|
126
126
|
previous: string | null;
|
|
127
127
|
results: T[];
|
|
128
128
|
}
|
|
129
|
+
/** Metadados do cartão salvo de um Customer (one-click buy). Nunca inclui o token. */
|
|
130
|
+
interface SavedCard {
|
|
131
|
+
brand: string;
|
|
132
|
+
last4: string;
|
|
133
|
+
exp_month: number | null;
|
|
134
|
+
exp_year: number | null;
|
|
135
|
+
holder_name: string;
|
|
136
|
+
consent_at: string | null;
|
|
137
|
+
}
|
|
138
|
+
/** Resposta de POST /customers/{id}/saved-card/management-link/. */
|
|
139
|
+
interface SavedCardManagementLink {
|
|
140
|
+
url: string;
|
|
141
|
+
token: string;
|
|
142
|
+
expires_at: string;
|
|
143
|
+
}
|
|
144
|
+
/** Resposta de POST /customers/{id}/one-click-link/. */
|
|
145
|
+
interface OneClickLink {
|
|
146
|
+
url: string;
|
|
147
|
+
token: string;
|
|
148
|
+
expires_at: string;
|
|
149
|
+
}
|
|
129
150
|
/** Response do GET /balance/. */
|
|
130
151
|
interface Balance {
|
|
131
152
|
available: number;
|
|
@@ -168,6 +189,15 @@ interface CreateChargeParams {
|
|
|
168
189
|
/** Idempotency-Key (header) — recomendado pra evitar duplo-débito em retry. */
|
|
169
190
|
idempotencyKey?: string;
|
|
170
191
|
}
|
|
192
|
+
interface CreateChargeWithSavedCardParams {
|
|
193
|
+
customer_id: string;
|
|
194
|
+
amount: number | string;
|
|
195
|
+
description?: string;
|
|
196
|
+
installments?: number;
|
|
197
|
+
external_reference?: string;
|
|
198
|
+
/** Idempotency-Key (header) — recomendado pra evitar duplo-débito em retry. */
|
|
199
|
+
idempotencyKey?: string;
|
|
200
|
+
}
|
|
171
201
|
interface RefundParams {
|
|
172
202
|
/** Valor parcial em reais. Omitir = reembolso total. */
|
|
173
203
|
amount?: number | string;
|
|
@@ -188,6 +218,12 @@ declare class Charges {
|
|
|
188
218
|
constructor(client: VitrinClient);
|
|
189
219
|
/** Cria uma cobrança avulsa (PIX/Boleto/Cartão). */
|
|
190
220
|
create(params: CreateChargeParams): Promise<Transaction>;
|
|
221
|
+
/**
|
|
222
|
+
* One-click buy: cobra usando o cartão preferido salvo do cliente.
|
|
223
|
+
* O cliente precisa ter um saved card (vide `customers.savedCard.create`).
|
|
224
|
+
* Retorna 422 `no_saved_card` se não houver cartão; 422 `card_expired` se vencido.
|
|
225
|
+
*/
|
|
226
|
+
createWithSavedCard(params: CreateChargeWithSavedCardParams): Promise<Transaction>;
|
|
191
227
|
retrieve(id: string): Promise<Transaction>;
|
|
192
228
|
list(params?: ListChargesParams): Promise<PaginatedList<Transaction>>;
|
|
193
229
|
refund(id: string, params: RefundParams): Promise<Transaction>;
|
|
@@ -214,8 +250,33 @@ interface CreateCustomerParams {
|
|
|
214
250
|
state?: string;
|
|
215
251
|
}
|
|
216
252
|
type UpdateCustomerParams = Partial<CreateCustomerParams>;
|
|
253
|
+
interface SaveCardParams {
|
|
254
|
+
credit_card: {
|
|
255
|
+
holder_name: string;
|
|
256
|
+
number: string;
|
|
257
|
+
expiry_month: string;
|
|
258
|
+
expiry_year: string;
|
|
259
|
+
cvv: string;
|
|
260
|
+
};
|
|
261
|
+
consent: {
|
|
262
|
+
accepted_at: string;
|
|
263
|
+
ip: string;
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
declare class SavedCardResource {
|
|
267
|
+
private client;
|
|
268
|
+
constructor(client: VitrinClient);
|
|
269
|
+
/** Tokeniza + persiste o cartão preferido do cliente (substitui o anterior). */
|
|
270
|
+
create(customerId: string, params: SaveCardParams): Promise<SavedCard>;
|
|
271
|
+
/** Retorna brand/last4/exp/holder — nunca o token. */
|
|
272
|
+
retrieve(customerId: string): Promise<SavedCard>;
|
|
273
|
+
delete(customerId: string): Promise<void>;
|
|
274
|
+
/** Gera URL assinada (JWT 24h) pro cliente final ver/remover o próprio cartão. */
|
|
275
|
+
createManagementLink(customerId: string): Promise<SavedCardManagementLink>;
|
|
276
|
+
}
|
|
217
277
|
declare class Customers {
|
|
218
278
|
private client;
|
|
279
|
+
readonly savedCard: SavedCardResource;
|
|
219
280
|
constructor(client: VitrinClient);
|
|
220
281
|
create(params: CreateCustomerParams): Promise<Customer>;
|
|
221
282
|
retrieve(id: string): Promise<Customer>;
|
|
@@ -225,6 +286,16 @@ declare class Customers {
|
|
|
225
286
|
}): Promise<PaginatedList<Customer>>;
|
|
226
287
|
update(id: string, params: UpdateCustomerParams): Promise<Customer>;
|
|
227
288
|
delete(id: string): Promise<void>;
|
|
289
|
+
/** Gera link assinado de recompra one-click (JWT 15min, uso único). */
|
|
290
|
+
oneClickLink(customerId: string, params: {
|
|
291
|
+
product_id?: string;
|
|
292
|
+
plan_id?: string;
|
|
293
|
+
amount?: string;
|
|
294
|
+
installments?: number;
|
|
295
|
+
coupon_code?: string;
|
|
296
|
+
bump_ids?: string[];
|
|
297
|
+
expires_in?: number;
|
|
298
|
+
}): Promise<OneClickLink>;
|
|
228
299
|
}
|
|
229
300
|
|
|
230
301
|
interface CreatePlanParams {
|
package/dist/index.js
CHANGED
|
@@ -180,6 +180,19 @@ var Charges = class {
|
|
|
180
180
|
idempotencyKey
|
|
181
181
|
});
|
|
182
182
|
}
|
|
183
|
+
/**
|
|
184
|
+
* One-click buy: cobra usando o cartão preferido salvo do cliente.
|
|
185
|
+
* O cliente precisa ter um saved card (vide `customers.savedCard.create`).
|
|
186
|
+
* Retorna 422 `no_saved_card` se não houver cartão; 422 `card_expired` se vencido.
|
|
187
|
+
*/
|
|
188
|
+
createWithSavedCard(params) {
|
|
189
|
+
const { idempotencyKey, ...body } = params;
|
|
190
|
+
return this.client.request("/charges/charge-saved/", {
|
|
191
|
+
method: "POST",
|
|
192
|
+
body,
|
|
193
|
+
idempotencyKey
|
|
194
|
+
});
|
|
195
|
+
}
|
|
183
196
|
retrieve(id) {
|
|
184
197
|
return this.client.request(`/transactions/${id}/`);
|
|
185
198
|
}
|
|
@@ -209,11 +222,42 @@ var Charges = class {
|
|
|
209
222
|
};
|
|
210
223
|
|
|
211
224
|
// src/resources/customers.ts
|
|
225
|
+
var SavedCardResource = class {
|
|
226
|
+
constructor(client) {
|
|
227
|
+
this.client = client;
|
|
228
|
+
}
|
|
229
|
+
client;
|
|
230
|
+
/** Tokeniza + persiste o cartão preferido do cliente (substitui o anterior). */
|
|
231
|
+
create(customerId, params) {
|
|
232
|
+
return this.client.request(`/customers/${customerId}/saved-card/`, {
|
|
233
|
+
method: "POST",
|
|
234
|
+
body: params
|
|
235
|
+
});
|
|
236
|
+
}
|
|
237
|
+
/** Retorna brand/last4/exp/holder — nunca o token. */
|
|
238
|
+
retrieve(customerId) {
|
|
239
|
+
return this.client.request(`/customers/${customerId}/saved-card/`);
|
|
240
|
+
}
|
|
241
|
+
delete(customerId) {
|
|
242
|
+
return this.client.request(`/customers/${customerId}/saved-card/`, {
|
|
243
|
+
method: "DELETE"
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/** Gera URL assinada (JWT 24h) pro cliente final ver/remover o próprio cartão. */
|
|
247
|
+
createManagementLink(customerId) {
|
|
248
|
+
return this.client.request(
|
|
249
|
+
`/customers/${customerId}/saved-card/management-link/`,
|
|
250
|
+
{ method: "POST" }
|
|
251
|
+
);
|
|
252
|
+
}
|
|
253
|
+
};
|
|
212
254
|
var Customers = class {
|
|
213
255
|
constructor(client) {
|
|
214
256
|
this.client = client;
|
|
257
|
+
this.savedCard = new SavedCardResource(client);
|
|
215
258
|
}
|
|
216
259
|
client;
|
|
260
|
+
savedCard;
|
|
217
261
|
create(params) {
|
|
218
262
|
return this.client.request("/customers/", {
|
|
219
263
|
method: "POST",
|
|
@@ -237,6 +281,13 @@ var Customers = class {
|
|
|
237
281
|
delete(id) {
|
|
238
282
|
return this.client.request(`/customers/${id}/`, { method: "DELETE" });
|
|
239
283
|
}
|
|
284
|
+
/** Gera link assinado de recompra one-click (JWT 15min, uso único). */
|
|
285
|
+
oneClickLink(customerId, params) {
|
|
286
|
+
return this.client.request(
|
|
287
|
+
`/customers/${customerId}/one-click-link/`,
|
|
288
|
+
{ method: "POST", body: params }
|
|
289
|
+
);
|
|
290
|
+
}
|
|
240
291
|
};
|
|
241
292
|
|
|
242
293
|
// src/resources/plans.ts
|