@bloque/payments 0.0.7 → 0.0.9

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/client.d.ts CHANGED
@@ -3,7 +3,7 @@ import { PaymentResource } from './resources/payment';
3
3
  import { WebhookResource } from './resources/webhook';
4
4
  export type BloqueConfig = {
5
5
  mode: 'sandbox' | 'production';
6
- apiKey: string;
6
+ accessToken: string;
7
7
  timeout?: number;
8
8
  maxRetries?: number;
9
9
  webhookSecret?: string;
@@ -1,6 +1,6 @@
1
1
  export interface HttpClientConfig {
2
2
  baseURL: string;
3
- apiKey: string;
3
+ accessToken: string;
4
4
  timeout?: number;
5
5
  maxRetries?: number;
6
6
  userAgent?: string;
@@ -15,7 +15,7 @@ export interface RequestOptions {
15
15
  }
16
16
  export declare class HttpClient {
17
17
  private readonly baseURL;
18
- private readonly apiKey;
18
+ private readonly accessToken;
19
19
  private readonly timeout;
20
20
  private readonly maxRetries;
21
21
  private readonly userAgent;
package/dist/index.cjs CHANGED
@@ -26,7 +26,7 @@ __webpack_require__.r(__webpack_exports__);
26
26
  __webpack_require__.d(__webpack_exports__, {
27
27
  Bloque: ()=>Bloque
28
28
  });
29
- var package_namespaceObject = JSON.parse('{"UU":"@bloque/payments","rE":"0.0.7"}');
29
+ var package_namespaceObject = JSON.parse('{"UU":"@bloque/payments","rE":"0.0.9"}');
30
30
  class BloqueError extends Error {
31
31
  constructor(message){
32
32
  super(message);
@@ -61,13 +61,13 @@ const SDK_NAME = package_namespaceObject.UU;
61
61
  const SDK_VERSION = package_namespaceObject.rE;
62
62
  class HttpClient {
63
63
  baseURL;
64
- apiKey;
64
+ accessToken;
65
65
  timeout;
66
66
  maxRetries;
67
67
  userAgent;
68
68
  constructor(config){
69
69
  this.baseURL = config.baseURL;
70
- this.apiKey = config.apiKey;
70
+ this.accessToken = config.accessToken;
71
71
  this.timeout = config.timeout ?? 10000;
72
72
  this.maxRetries = config.maxRetries ?? 2;
73
73
  this.userAgent = `${SDK_NAME}/${SDK_VERSION}`;
@@ -110,7 +110,7 @@ class HttpClient {
110
110
  }
111
111
  buildHeaders(customHeaders, idempotencyKey) {
112
112
  return {
113
- Authorization: `Bearer ${this.apiKey}`,
113
+ Authorization: `Bearer ${this.accessToken}`,
114
114
  'Content-Type': 'application/json',
115
115
  'User-Agent': this.userAgent,
116
116
  ...idempotencyKey ? {
@@ -248,10 +248,6 @@ class PaymentResource extends BaseResource {
248
248
  switch(payment.type){
249
249
  case 'card':
250
250
  return this.buildCardPayload(payment.data);
251
- case 'pse':
252
- return this.buildPSEPayload(payment.data);
253
- case 'cash':
254
- return this.buildCashPayload(payment.data);
255
251
  }
256
252
  }
257
253
  buildCardPayload(data) {
@@ -264,23 +260,6 @@ class PaymentResource extends BaseResource {
264
260
  card_holder: data.cardholderName
265
261
  };
266
262
  }
267
- buildPSEPayload(data) {
268
- return {
269
- customer_email: data.email,
270
- person_type: data.personType,
271
- document_type: data.documentType,
272
- document_number: data.documentNumber,
273
- bank_code: data.bankCode
274
- };
275
- }
276
- buildCashPayload(data) {
277
- return {
278
- customer_email: data.email,
279
- document_type: data.documentType,
280
- document_number: data.documentNumber,
281
- full_name: data.fullName
282
- };
283
- }
284
263
  }
285
264
  const external_node_crypto_namespaceObject = require("node:crypto");
286
265
  class WebhookResource {
@@ -318,11 +297,11 @@ class Bloque {
318
297
  payments;
319
298
  webhooks;
320
299
  constructor(config){
321
- if (!config.apiKey) throw new Error('API key is required');
300
+ if (!config.accessToken) throw new Error('API key is required');
322
301
  this.#config = config;
323
302
  this.#httpClient = new HttpClient({
324
303
  baseURL: 'sandbox' === this.#config.mode ? 'https://dev.bloque.app/api/payments' : 'https://api.bloque.app/api/payments',
325
- apiKey: this.#config.apiKey,
304
+ accessToken: this.#config.accessToken,
326
305
  timeout: this.#config.timeout,
327
306
  maxRetries: this.#config.maxRetries
328
307
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { CreatePaymentParams, PaymentResponse, PaymentSubmitPayload, } from '@bloque/payments-core';
2
1
  export { Bloque, type BloqueConfig } from './client';
3
2
  export type { WebhookVerifyOptions } from './resources/webhook';
4
3
  export type { Checkout, CheckoutItem, CheckoutParams, CheckoutStatus, } from './types/checkout';
4
+ export type { CreatePaymentParams, PaymentResponse, PaymentSubmitPayload, } from './types/payment';
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { createHmac } from "node:crypto";
2
- var package_namespaceObject = JSON.parse('{"UU":"@bloque/payments","rE":"0.0.7"}');
2
+ var package_namespaceObject = JSON.parse('{"UU":"@bloque/payments","rE":"0.0.9"}');
3
3
  class BloqueError extends Error {
4
4
  constructor(message){
5
5
  super(message);
@@ -34,13 +34,13 @@ const SDK_NAME = package_namespaceObject.UU;
34
34
  const SDK_VERSION = package_namespaceObject.rE;
35
35
  class HttpClient {
36
36
  baseURL;
37
- apiKey;
37
+ accessToken;
38
38
  timeout;
39
39
  maxRetries;
40
40
  userAgent;
41
41
  constructor(config){
42
42
  this.baseURL = config.baseURL;
43
- this.apiKey = config.apiKey;
43
+ this.accessToken = config.accessToken;
44
44
  this.timeout = config.timeout ?? 10000;
45
45
  this.maxRetries = config.maxRetries ?? 2;
46
46
  this.userAgent = `${SDK_NAME}/${SDK_VERSION}`;
@@ -83,7 +83,7 @@ class HttpClient {
83
83
  }
84
84
  buildHeaders(customHeaders, idempotencyKey) {
85
85
  return {
86
- Authorization: `Bearer ${this.apiKey}`,
86
+ Authorization: `Bearer ${this.accessToken}`,
87
87
  'Content-Type': 'application/json',
88
88
  'User-Agent': this.userAgent,
89
89
  ...idempotencyKey ? {
@@ -221,10 +221,6 @@ class PaymentResource extends BaseResource {
221
221
  switch(payment.type){
222
222
  case 'card':
223
223
  return this.buildCardPayload(payment.data);
224
- case 'pse':
225
- return this.buildPSEPayload(payment.data);
226
- case 'cash':
227
- return this.buildCashPayload(payment.data);
228
224
  }
229
225
  }
230
226
  buildCardPayload(data) {
@@ -237,23 +233,6 @@ class PaymentResource extends BaseResource {
237
233
  card_holder: data.cardholderName
238
234
  };
239
235
  }
240
- buildPSEPayload(data) {
241
- return {
242
- customer_email: data.email,
243
- person_type: data.personType,
244
- document_type: data.documentType,
245
- document_number: data.documentNumber,
246
- bank_code: data.bankCode
247
- };
248
- }
249
- buildCashPayload(data) {
250
- return {
251
- customer_email: data.email,
252
- document_type: data.documentType,
253
- document_number: data.documentNumber,
254
- full_name: data.fullName
255
- };
256
- }
257
236
  }
258
237
  class WebhookResource {
259
238
  #secret;
@@ -290,11 +269,11 @@ class Bloque {
290
269
  payments;
291
270
  webhooks;
292
271
  constructor(config){
293
- if (!config.apiKey) throw new Error('API key is required');
272
+ if (!config.accessToken) throw new Error('API key is required');
294
273
  this.#config = config;
295
274
  this.#httpClient = new HttpClient({
296
275
  baseURL: 'sandbox' === this.#config.mode ? 'https://dev.bloque.app/api/payments' : 'https://api.bloque.app/api/payments',
297
- apiKey: this.#config.apiKey,
276
+ accessToken: this.#config.accessToken,
298
277
  timeout: this.#config.timeout,
299
278
  maxRetries: this.#config.maxRetries
300
279
  });
@@ -1,4 +1,4 @@
1
- import type { CreatePaymentParams, PaymentResponse } from '@bloque/payments-core';
1
+ import type { CreatePaymentParams, PaymentResponse } from '../types/payment';
2
2
  import { BaseResource } from './base';
3
3
  export declare class PaymentResource extends BaseResource {
4
4
  /**
@@ -28,6 +28,4 @@ export declare class PaymentResource extends BaseResource {
28
28
  create(params: CreatePaymentParams): Promise<PaymentResponse>;
29
29
  private buildPaymentPayload;
30
30
  private buildCardPayload;
31
- private buildPSEPayload;
32
- private buildCashPayload;
33
31
  }
@@ -0,0 +1,32 @@
1
+ export interface CardPaymentFormData {
2
+ cardNumber: string;
3
+ cardholderName: string;
4
+ expiryMonth: string;
5
+ expiryYear: string;
6
+ cvv: string;
7
+ email: string;
8
+ }
9
+ type PaymentFormDataMap = {
10
+ card: CardPaymentFormData;
11
+ };
12
+ export type PaymentSubmitPayload = {
13
+ [K in keyof PaymentFormDataMap]: {
14
+ type: K;
15
+ data: PaymentFormDataMap[K];
16
+ };
17
+ }[keyof PaymentFormDataMap];
18
+ export type PaymentMethodType = 'card' | 'pse' | 'cash';
19
+ export interface CreatePaymentParams {
20
+ checkoutId?: string;
21
+ payment: PaymentSubmitPayload;
22
+ }
23
+ export interface PaymentResponse {
24
+ id: string;
25
+ object: 'payment';
26
+ status: 'pending' | 'processing' | 'completed' | 'failed';
27
+ amount: number;
28
+ currency: string;
29
+ created_at: string;
30
+ updated_at: string;
31
+ }
32
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/payments",
3
- "version": "0.0.7",
3
+ "version": "0.0.9",
4
4
  "description": "Official Bloque SDK for creating and managing payments and checkouts.",
5
5
  "type": "module",
6
6
  "keywords": [
@@ -35,8 +35,5 @@
35
35
  ],
36
36
  "engines": {
37
37
  "node": ">=22"
38
- },
39
- "dependencies": {
40
- "@bloque/payments-core": "0.0.7"
41
38
  }
42
39
  }