@bloque/payments 0.0.9 → 0.0.10

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 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.9"}');
29
+ var package_namespaceObject = JSON.parse('{"UU":"@bloque/payments","rE":"0.0.10"}');
30
30
  class BloqueError extends Error {
31
31
  constructor(message){
32
32
  super(message);
@@ -102,11 +102,12 @@ class HttpClient {
102
102
  throw lastError ?? new BloqueError('Request failed after retries');
103
103
  }
104
104
  buildURL(path, params) {
105
- const url = new URL(path, this.baseURL);
105
+ const url = `${this.baseURL}${path.startsWith('/') ? path : `/${path}`}`;
106
+ const urlObj = new URL(url);
106
107
  if (params) {
107
- for (const [key, value] of Object.entries(params))if (null != value) url.searchParams.append(key, String(value));
108
+ for (const [key, value] of Object.entries(params))if (null != value) urlObj.searchParams.append(key, String(value));
108
109
  }
109
- return url.toString();
110
+ return urlObj.toString();
110
111
  }
111
112
  buildHeaders(customHeaders, idempotencyKey) {
112
113
  return {
@@ -200,8 +201,8 @@ class CheckoutResource extends BaseResource {
200
201
  async create(params) {
201
202
  const items = params.items.map((item)=>({
202
203
  name: item.name,
203
- price: item.amount.toString(),
204
- units: item.quantity,
204
+ amount: item.amount.toString(),
205
+ quantity: item.quantity,
205
206
  image_url: item.image_url
206
207
  }));
207
208
  const payload = {
@@ -221,14 +222,14 @@ class CheckoutResource extends BaseResource {
221
222
  object: 'checkout',
222
223
  url: response.payment.url,
223
224
  status: response.payment.summary.status,
224
- amount_total: response.payment.price,
225
- amount_subtotal: response.payment.price,
225
+ amount_total: response.payment.amount,
226
+ amount_subtotal: response.payment.amount,
226
227
  currency: 'USD',
227
228
  items: params.items,
228
229
  created_at: response.payment.created_at,
229
230
  updated_at: response.payment.updated_at,
230
231
  expires_at: response.payment.expires_at,
231
- metadata: response.payment.metadata
232
+ metadata: response.payment.metadata ?? void 0
232
233
  };
233
234
  }
234
235
  async retrieve(checkoutId) {
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.9"}');
2
+ var package_namespaceObject = JSON.parse('{"UU":"@bloque/payments","rE":"0.0.10"}');
3
3
  class BloqueError extends Error {
4
4
  constructor(message){
5
5
  super(message);
@@ -75,11 +75,12 @@ class HttpClient {
75
75
  throw lastError ?? new BloqueError('Request failed after retries');
76
76
  }
77
77
  buildURL(path, params) {
78
- const url = new URL(path, this.baseURL);
78
+ const url = `${this.baseURL}${path.startsWith('/') ? path : `/${path}`}`;
79
+ const urlObj = new URL(url);
79
80
  if (params) {
80
- for (const [key, value] of Object.entries(params))if (null != value) url.searchParams.append(key, String(value));
81
+ for (const [key, value] of Object.entries(params))if (null != value) urlObj.searchParams.append(key, String(value));
81
82
  }
82
- return url.toString();
83
+ return urlObj.toString();
83
84
  }
84
85
  buildHeaders(customHeaders, idempotencyKey) {
85
86
  return {
@@ -173,8 +174,8 @@ class CheckoutResource extends BaseResource {
173
174
  async create(params) {
174
175
  const items = params.items.map((item)=>({
175
176
  name: item.name,
176
- price: item.amount.toString(),
177
- units: item.quantity,
177
+ amount: item.amount.toString(),
178
+ quantity: item.quantity,
178
179
  image_url: item.image_url
179
180
  }));
180
181
  const payload = {
@@ -194,14 +195,14 @@ class CheckoutResource extends BaseResource {
194
195
  object: 'checkout',
195
196
  url: response.payment.url,
196
197
  status: response.payment.summary.status,
197
- amount_total: response.payment.price,
198
- amount_subtotal: response.payment.price,
198
+ amount_total: response.payment.amount,
199
+ amount_subtotal: response.payment.amount,
199
200
  currency: 'USD',
200
201
  items: params.items,
201
202
  created_at: response.payment.created_at,
202
203
  updated_at: response.payment.updated_at,
203
204
  expires_at: response.payment.expires_at,
204
- metadata: response.payment.metadata
205
+ metadata: response.payment.metadata ?? void 0
205
206
  };
206
207
  }
207
208
  async retrieve(checkoutId) {
@@ -4,12 +4,12 @@ export interface CreateCheckoutPayload {
4
4
  name: string;
5
5
  description?: string;
6
6
  image_url?: string;
7
- asset: 'dUSD/6';
7
+ asset: 'dUSD/6' | 'COPM/2';
8
8
  payment_type: 'shopping_cart';
9
9
  items: {
10
10
  name: string;
11
- price: string;
12
- units: number;
11
+ amount: string;
12
+ quantity: number;
13
13
  image_url?: string;
14
14
  }[];
15
15
  redirect_url: string;
@@ -20,16 +20,17 @@ export interface CreateCheckoutResponse {
20
20
  payment: {
21
21
  urn: string;
22
22
  url: string;
23
- price: number;
23
+ amount: number;
24
24
  image_url?: string | null;
25
- metadata?: Metadata;
25
+ metadata?: Metadata | null;
26
26
  created_at: string;
27
27
  updated_at: string;
28
- expires_at: string;
28
+ expires_at: string | null;
29
29
  summary: {
30
30
  status: CheckoutStatus;
31
31
  };
32
32
  };
33
+ url_id: string;
33
34
  }
34
35
  /**
35
36
  * Represents a single item included in a checkout.
@@ -169,5 +170,5 @@ export interface Checkout {
169
170
  /**
170
171
  * Checkout expiration timestamp in ISO 8601 format.
171
172
  */
172
- expires_at: string;
173
+ expires_at: string | null;
173
174
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bloque/payments",
3
- "version": "0.0.9",
3
+ "version": "0.0.10",
4
4
  "description": "Official Bloque SDK for creating and managing payments and checkouts.",
5
5
  "type": "module",
6
6
  "keywords": [