@betterstore/sdk 0.6.9 → 0.6.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.js CHANGED
@@ -76,7 +76,7 @@ var createApiClient = (apiKey, proxy) => {
76
76
  apiError.code = "REQUEST_SETUP_ERROR";
77
77
  apiError.details = error;
78
78
  }
79
- console.error(apiError);
79
+ console.error("API ERROR: ", apiError);
80
80
  if (apiError.code === "REQUEST_SETUP_ERROR" || apiError.code === "SERVICE_UNAVAILABLE") {
81
81
  throw apiError;
82
82
  }
@@ -200,7 +200,7 @@ var Checkout = class {
200
200
  */
201
201
  async removeDiscount(checkoutId, discountId) {
202
202
  const data = await this.apiClient.delete(
203
- `/checkout/${checkoutId}/discounts/${discountId}`
203
+ `/checkout/${checkoutId}/discounts/remove/${discountId}`
204
204
  );
205
205
  if ("isError" in data && data.isError || !data || !("id" in data)) {
206
206
  console.error(`Checkout session with id ${checkoutId} not found`);
@@ -228,7 +228,9 @@ var Checkout = class {
228
228
  const data = await this.apiClient.get(
229
229
  `/checkout/${checkoutId}/shipping/rates`
230
230
  );
231
+ console.log("SHIPPING RATES DATA: ", data);
231
232
  if ("isError" in data && data.isError || !data) {
233
+ console.error("Failed to get shipping rates: ", data);
232
234
  return {};
233
235
  }
234
236
  return data;
@@ -238,7 +240,7 @@ var Checkout = class {
238
240
  */
239
241
  async generatePaymentSecret(checkoutId) {
240
242
  const data = await this.apiClient.post(`
241
- /checkout/payment/${checkoutId}`);
243
+ /checkout/${checkoutId}/payment`);
242
244
  if ("isError" in data && data.isError || !data || !("paymentSecret" in data)) {
243
245
  throw new Error("Failed to generate payment secret");
244
246
  }
@@ -306,7 +308,7 @@ var Client = class {
306
308
  async removeDiscount(clientSecret, checkoutId, discountId) {
307
309
  const apiClient = createApiClient(clientSecret, this.proxy);
308
310
  const data = await apiClient.delete(
309
- `/checkout/${checkoutId}/discounts/${discountId}`
311
+ `/checkout/${checkoutId}/discounts/remove/${discountId}`
310
312
  );
311
313
  if ("isError" in data && data.isError || !data || !("id" in data)) {
312
314
  throw new Error("Failed to remove discount code");
@@ -335,7 +337,9 @@ var Client = class {
335
337
  const data = await apiClient.get(
336
338
  `/checkout/${checkoutId}/shipping/rates`
337
339
  );
338
- if ("isError" in data && data.isError || !data || !("rates" in data)) {
340
+ console.log("SHIPPING RATES DATA: ", data);
341
+ if ("isError" in data && data.isError || !data) {
342
+ console.error("Failed to get shipping rates: ", data);
339
343
  return {};
340
344
  }
341
345
  return data;
@@ -345,7 +349,7 @@ var Client = class {
345
349
  */
346
350
  async generateCheckoutPaymentSecret(clientSecret, checkoutId) {
347
351
  const apiClient = createApiClient(clientSecret, this.proxy);
348
- const data = await apiClient.post(`/checkout/payment/${checkoutId}`);
352
+ const data = await apiClient.post(`/checkout/${checkoutId}/payment`);
349
353
  if ("isError" in data && data.isError || !data || !("paymentSecret" in data)) {
350
354
  throw new Error("Failed to generate payment secret");
351
355
  }
package/dist/index.mjs CHANGED
@@ -36,7 +36,7 @@ var createApiClient = (apiKey, proxy) => {
36
36
  apiError.code = "REQUEST_SETUP_ERROR";
37
37
  apiError.details = error;
38
38
  }
39
- console.error(apiError);
39
+ console.error("API ERROR: ", apiError);
40
40
  if (apiError.code === "REQUEST_SETUP_ERROR" || apiError.code === "SERVICE_UNAVAILABLE") {
41
41
  throw apiError;
42
42
  }
@@ -160,7 +160,7 @@ var Checkout = class {
160
160
  */
161
161
  async removeDiscount(checkoutId, discountId) {
162
162
  const data = await this.apiClient.delete(
163
- `/checkout/${checkoutId}/discounts/${discountId}`
163
+ `/checkout/${checkoutId}/discounts/remove/${discountId}`
164
164
  );
165
165
  if ("isError" in data && data.isError || !data || !("id" in data)) {
166
166
  console.error(`Checkout session with id ${checkoutId} not found`);
@@ -188,7 +188,9 @@ var Checkout = class {
188
188
  const data = await this.apiClient.get(
189
189
  `/checkout/${checkoutId}/shipping/rates`
190
190
  );
191
+ console.log("SHIPPING RATES DATA: ", data);
191
192
  if ("isError" in data && data.isError || !data) {
193
+ console.error("Failed to get shipping rates: ", data);
192
194
  return {};
193
195
  }
194
196
  return data;
@@ -198,7 +200,7 @@ var Checkout = class {
198
200
  */
199
201
  async generatePaymentSecret(checkoutId) {
200
202
  const data = await this.apiClient.post(`
201
- /checkout/payment/${checkoutId}`);
203
+ /checkout/${checkoutId}/payment`);
202
204
  if ("isError" in data && data.isError || !data || !("paymentSecret" in data)) {
203
205
  throw new Error("Failed to generate payment secret");
204
206
  }
@@ -266,7 +268,7 @@ var Client = class {
266
268
  async removeDiscount(clientSecret, checkoutId, discountId) {
267
269
  const apiClient = createApiClient(clientSecret, this.proxy);
268
270
  const data = await apiClient.delete(
269
- `/checkout/${checkoutId}/discounts/${discountId}`
271
+ `/checkout/${checkoutId}/discounts/remove/${discountId}`
270
272
  );
271
273
  if ("isError" in data && data.isError || !data || !("id" in data)) {
272
274
  throw new Error("Failed to remove discount code");
@@ -295,7 +297,9 @@ var Client = class {
295
297
  const data = await apiClient.get(
296
298
  `/checkout/${checkoutId}/shipping/rates`
297
299
  );
298
- if ("isError" in data && data.isError || !data || !("rates" in data)) {
300
+ console.log("SHIPPING RATES DATA: ", data);
301
+ if ("isError" in data && data.isError || !data) {
302
+ console.error("Failed to get shipping rates: ", data);
299
303
  return {};
300
304
  }
301
305
  return data;
@@ -305,7 +309,7 @@ var Client = class {
305
309
  */
306
310
  async generateCheckoutPaymentSecret(clientSecret, checkoutId) {
307
311
  const apiClient = createApiClient(clientSecret, this.proxy);
308
- const data = await apiClient.post(`/checkout/payment/${checkoutId}`);
312
+ const data = await apiClient.post(`/checkout/${checkoutId}/payment`);
309
313
  if ("isError" in data && data.isError || !data || !("paymentSecret" in data)) {
310
314
  throw new Error("Failed to generate payment secret");
311
315
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@betterstore/sdk",
3
- "version": "0.6.9",
3
+ "version": "0.6.10",
4
4
  "private": false,
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",