washday-sdk 1.6.59 → 1.6.61

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.
@@ -8,6 +8,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
8
  });
9
9
  };
10
10
  const GET_SET_COMPANIES = 'api/company';
11
+ const GET_SET_BILLING = 'api/billing';
11
12
  export const getCompanyById = function (companyId) {
12
13
  return __awaiter(this, void 0, void 0, function* () {
13
14
  try {
@@ -53,3 +54,18 @@ export const getGarmentAttributeCatalogs = function (companyId) {
53
54
  }
54
55
  });
55
56
  };
57
+ export const getCFDIAddonStatus = function (data) {
58
+ return __awaiter(this, void 0, void 0, function* () {
59
+ try {
60
+ const config = {
61
+ headers: { Authorization: `Bearer ${this.apiToken}` }
62
+ };
63
+ const response = yield this.axiosInstance.get(`${GET_SET_BILLING}/cfdi/status?companyId=${encodeURIComponent(data.companyId)}`, config);
64
+ return response;
65
+ }
66
+ catch (error) {
67
+ console.error('Error fetching getCFDIAddonStatus:', error);
68
+ throw error;
69
+ }
70
+ });
71
+ };
@@ -69,3 +69,33 @@ export const disableBillingOverage = function (data) {
69
69
  }
70
70
  });
71
71
  };
72
+ export const enableCFDIAddon = function (data) {
73
+ return __awaiter(this, void 0, void 0, function* () {
74
+ try {
75
+ const config = {
76
+ headers: { Authorization: `Bearer ${this.apiToken}` }
77
+ };
78
+ const response = yield this.axiosInstance.post(`${GET_SET_BILLING}/cfdi/enable`, data, config);
79
+ return response;
80
+ }
81
+ catch (error) {
82
+ console.error('Error fetching enableCFDIAddon:', error);
83
+ throw error;
84
+ }
85
+ });
86
+ };
87
+ export const disableCFDIAddon = function (data) {
88
+ return __awaiter(this, void 0, void 0, function* () {
89
+ try {
90
+ const config = {
91
+ headers: { Authorization: `Bearer ${this.apiToken}` }
92
+ };
93
+ const response = yield this.axiosInstance.post(`${GET_SET_BILLING}/cfdi/disable`, data, config);
94
+ return response;
95
+ }
96
+ catch (error) {
97
+ console.error('Error fetching disableCFDIAddon:', error);
98
+ throw error;
99
+ }
100
+ });
101
+ };
package/dist/api/index.js CHANGED
@@ -2,8 +2,8 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "./cashierbox
2
2
  import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "./cashierbox/get";
3
3
  import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
4
4
  import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
5
- import { getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
6
- import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
5
+ import { getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
6
+ import { disableBillingOverage, disableCFDIAddon, enableBillingOverage, enableCFDIAddon, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
7
7
  import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "./companies/put";
8
8
  import { getCountries } from "./countries/get";
9
9
  import * as configEndpoints from "./config";
@@ -285,6 +285,9 @@ const WashdayClient = function WashdayClient(apiToken, env = 'PROD', clientId, c
285
285
  updateCFDIOrgLogo: updateCFDIOrgLogo,
286
286
  enableBillingOverage: enableBillingOverage,
287
287
  disableBillingOverage: disableBillingOverage,
288
+ enableCFDIAddon: enableCFDIAddon,
289
+ disableCFDIAddon: disableCFDIAddon,
290
+ getCFDIAddonStatus: getCFDIAddonStatus,
288
291
  });
289
292
  this.stripe = bindMethods(this, {
290
293
  createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
@@ -39,6 +39,7 @@ export const createCustomerPortalSession = function (data) {
39
39
  }
40
40
  });
41
41
  };
42
+ /** @deprecated Legacy standalone CFDI checkout. New activations use companies.enableCFDIAddon. */
42
43
  export const createCFDISuscrptionCheckoutSession = function (data) {
43
44
  return __awaiter(this, void 0, void 0, function* () {
44
45
  try {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "washday-sdk",
3
- "version": "1.6.59",
3
+ "version": "1.6.61",
4
4
  "description": "Washday utilities functions and API",
5
5
  "main": "dist/index.js",
6
6
  "type": "module",
@@ -1,6 +1,8 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { GetCFDIAddonStatusRequest } from "../../interfaces/Company";
2
3
 
3
4
  const GET_SET_COMPANIES = 'api/company';
5
+ const GET_SET_BILLING = 'api/billing';
4
6
 
5
7
  export const getCompanyById = async function (this: WashdayClientInstance, companyId: string): Promise<any> {
6
8
  try {
@@ -40,3 +42,19 @@ export const getGarmentAttributeCatalogs = async function (this: WashdayClientIn
40
42
  throw error;
41
43
  }
42
44
  };
45
+
46
+ export const getCFDIAddonStatus = async function (
47
+ this: WashdayClientInstance,
48
+ data: GetCFDIAddonStatusRequest,
49
+ ): Promise<any> {
50
+ try {
51
+ const config = {
52
+ headers: { Authorization: `Bearer ${this.apiToken}` }
53
+ };
54
+ const response = await this.axiosInstance.get(`${GET_SET_BILLING}/cfdi/status?companyId=${encodeURIComponent(data.companyId)}`, config);
55
+ return response;
56
+ } catch (error) {
57
+ console.error('Error fetching getCFDIAddonStatus:', error);
58
+ throw error;
59
+ }
60
+ };
@@ -1,4 +1,5 @@
1
1
  import { WashdayClientInstance } from "../../interfaces/Api";
2
+ import { CFDIAddonToggleRequest } from "../../interfaces/Company";
2
3
  import axiosInstance from "../axiosInstance";
3
4
  const GET_SET_COMPANIES = 'api/company';
4
5
  const GET_SET_BILLING = 'api/billing';
@@ -57,4 +58,36 @@ export const disableBillingOverage = async function (this: WashdayClientInstance
57
58
  console.error('Error fetching disableBillingOverage:', error);
58
59
  throw error;
59
60
  }
60
- }
61
+ }
62
+
63
+ export const enableCFDIAddon = async function (
64
+ this: WashdayClientInstance,
65
+ data: CFDIAddonToggleRequest
66
+ ): Promise<any> {
67
+ try {
68
+ const config = {
69
+ headers: { Authorization: `Bearer ${this.apiToken}` }
70
+ };
71
+ const response = await this.axiosInstance.post(`${GET_SET_BILLING}/cfdi/enable`, data, config);
72
+ return response;
73
+ } catch (error) {
74
+ console.error('Error fetching enableCFDIAddon:', error);
75
+ throw error;
76
+ }
77
+ }
78
+
79
+ export const disableCFDIAddon = async function (
80
+ this: WashdayClientInstance,
81
+ data: CFDIAddonToggleRequest
82
+ ): Promise<any> {
83
+ try {
84
+ const config = {
85
+ headers: { Authorization: `Bearer ${this.apiToken}` }
86
+ };
87
+ const response = await this.axiosInstance.post(`${GET_SET_BILLING}/cfdi/disable`, data, config);
88
+ return response;
89
+ } catch (error) {
90
+ console.error('Error fetching disableCFDIAddon:', error);
91
+ throw error;
92
+ }
93
+ }
package/src/api/index.ts CHANGED
@@ -3,8 +3,8 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "./cashierbox
3
3
  import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "./cashierbox/get";
4
4
  import { addCashierBoxMovement, createCashierBox } from "./cashierbox/post";
5
5
  import { updateCashierBoxById, updateCashierBoxMovementById } from "./cashierbox/put";
6
- import { getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
7
- import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
6
+ import { getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "./companies/get";
7
+ import { disableBillingOverage, disableCFDIAddon, enableBillingOverage, enableCFDIAddon, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "./companies/post";
8
8
  import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "./companies/put";
9
9
  import { getCountries } from "./countries/get";
10
10
  import * as configEndpoints from "./config";
@@ -292,6 +292,9 @@ const WashdayClient: WashdayClientConstructor = function WashdayClient(this: Was
292
292
  updateCFDIOrgLogo: updateCFDIOrgLogo,
293
293
  enableBillingOverage: enableBillingOverage,
294
294
  disableBillingOverage: disableBillingOverage,
295
+ enableCFDIAddon: enableCFDIAddon,
296
+ disableCFDIAddon: disableCFDIAddon,
297
+ getCFDIAddonStatus: getCFDIAddonStatus,
295
298
  });
296
299
  this.stripe = bindMethods(this, {
297
300
  createCreateSuscriptionCheckoutSession: createCreateSuscriptionCheckoutSession,
@@ -48,6 +48,7 @@ export const createCustomerPortalSession = async function (
48
48
  }
49
49
  };
50
50
 
51
+ /** @deprecated Legacy standalone CFDI checkout. New activations use companies.enableCFDIAddon. */
51
52
  export const createCFDISuscrptionCheckoutSession = async function (
52
53
  this: WashdayClientInstance,
53
54
  data?: CreateCFDISubscriptionCheckoutSessionRequest
@@ -2,8 +2,8 @@ import { deleteCashierBoxById, deleteCashierBoxMovementById } from "../api/cashi
2
2
  import { getCashierBoxMovementsHistory, getCashierboxesById, getCashierboxesByStoreId } from "../api/cashierbox/get";
3
3
  import { addCashierBoxMovement, createCashierBox } from "../api/cashierbox/post";
4
4
  import { updateCashierBoxById, updateCashierBoxMovementById } from "../api/cashierbox/put";
5
- import { getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "../api/companies/get";
6
- import { disableBillingOverage, enableBillingOverage, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "../api/companies/post";
5
+ import { getCFDIAddonStatus, getCompanyById, getCompanyOrdersMetrics, getGarmentAttributeCatalogs } from "../api/companies/get";
6
+ import { disableBillingOverage, disableCFDIAddon, enableBillingOverage, enableCFDIAddon, updateCFDIOrgLogo, updateCompanyTaxInfoCertificates } from "../api/companies/post";
7
7
  import { updateCompanyById, updateCompanyLogoById, updateCompanySubscriptionBillingInfoById, updateCompanyTaxInfoById, updateGarmentAttributeCatalogsById } from "../api/companies/put";
8
8
  import { getCountries } from "../api/countries/get";
9
9
  import * as configEndpoints from "../api/config";
@@ -277,6 +277,9 @@ export interface WashdayClientInstance {
277
277
  updateCFDIOrgLogo: typeof updateCFDIOrgLogo;
278
278
  enableBillingOverage: typeof enableBillingOverage;
279
279
  disableBillingOverage: typeof disableBillingOverage;
280
+ enableCFDIAddon: typeof enableCFDIAddon;
281
+ disableCFDIAddon: typeof disableCFDIAddon;
282
+ getCFDIAddonStatus: typeof getCFDIAddonStatus;
280
283
  };
281
284
  stripe: {
282
285
  createCreateSuscriptionCheckoutSession: typeof createCreateSuscriptionCheckoutSession;
@@ -31,6 +31,41 @@ export interface UpdateCompanySubscriptionBillingInfoPayload {
31
31
  subscriptionBillingInfo: ISubscriptionBillingInfo;
32
32
  }
33
33
 
34
+ export type CFDIBillingMode = "none" | "separate_subscription" | "main_subscription_item";
35
+ export type CFDIMigrationStatus = "none" | "pending_cycle_end" | "migrated";
36
+ export type CFDIBillingStatus = "inactive" | "active" | "cancel_scheduled";
37
+
38
+ export interface CFDIAddonStatus {
39
+ enabled: boolean;
40
+ billingMode: CFDIBillingMode;
41
+ migrationStatus: CFDIMigrationStatus;
42
+ billingStatus: CFDIBillingStatus;
43
+ scheduledDisableAt: string | null;
44
+ isLegacy: boolean;
45
+ canToggleFromUI: boolean;
46
+ canCancelScheduledDisable: boolean;
47
+ }
48
+
49
+ export interface CFDIAddonToggleRequest {
50
+ companyId: string;
51
+ }
52
+
53
+ export interface GetCFDIAddonStatusRequest {
54
+ companyId: string;
55
+ }
56
+
57
+ export interface IStripeSettings {
58
+ stripeCFDISubID: string | null;
59
+ stripeCFDISubItemID: string | null;
60
+ cfdiBillingMode?: CFDIBillingMode;
61
+ cfdiMigrationStatus?: CFDIMigrationStatus;
62
+ cfdiBillingStatus?: CFDIBillingStatus;
63
+ cfdiScheduledDisableAt?: Date | string | null;
64
+ stripeCFDIDisableScheduleID?: string | null;
65
+ legacyStripeCFDISubID?: string | null;
66
+ legacyStripeCFDISubItemID?: string | null;
67
+ }
68
+
34
69
  export interface ICompanyTaxInfo {
35
70
  name?: string;
36
71
  legal_name?: string;
@@ -0,0 +1,70 @@
1
+ import {
2
+ disableCFDIAddon,
3
+ enableCFDIAddon,
4
+ } from "../src/api/companies/post";
5
+ import { getCFDIAddonStatus } from "../src/api/companies/get";
6
+ import type { CFDIAddonStatus } from "../src/interfaces/Company";
7
+
8
+ describe("CFDI billing add-on company endpoints", () => {
9
+ it("enables the CFDI add-on through the billing endpoint", async () => {
10
+ const post = jest.fn().mockResolvedValue({ data: { data: { enabled: true } } });
11
+ const client = {
12
+ apiToken: "token-1",
13
+ axiosInstance: { post },
14
+ } as any;
15
+
16
+ await enableCFDIAddon.call(client, { companyId: "company-1" });
17
+
18
+ expect(post).toHaveBeenCalledWith(
19
+ "api/billing/cfdi/enable",
20
+ { companyId: "company-1" },
21
+ { headers: { Authorization: "Bearer token-1" } },
22
+ );
23
+ });
24
+
25
+ it("disables the CFDI add-on through the billing endpoint", async () => {
26
+ const post = jest.fn().mockResolvedValue({ data: { data: { enabled: false } } });
27
+ const client = {
28
+ apiToken: "token-1",
29
+ axiosInstance: { post },
30
+ } as any;
31
+
32
+ await disableCFDIAddon.call(client, { companyId: "company-1" });
33
+
34
+ expect(post).toHaveBeenCalledWith(
35
+ "api/billing/cfdi/disable",
36
+ { companyId: "company-1" },
37
+ { headers: { Authorization: "Bearer token-1" } },
38
+ );
39
+ });
40
+
41
+ it("fetches CFDI add-on status without exposing Stripe IDs in the request", async () => {
42
+ const get = jest.fn().mockResolvedValue({ data: { data: { enabled: false } } });
43
+ const client = {
44
+ apiToken: "token-1",
45
+ axiosInstance: { get },
46
+ } as any;
47
+
48
+ await getCFDIAddonStatus.call(client, { companyId: "company-1" });
49
+
50
+ expect(get).toHaveBeenCalledWith(
51
+ "api/billing/cfdi/status?companyId=company-1",
52
+ { headers: { Authorization: "Bearer token-1" } },
53
+ );
54
+ });
55
+
56
+ it("types scheduled disable status fields", () => {
57
+ const status: CFDIAddonStatus = {
58
+ enabled: false,
59
+ billingMode: "main_subscription_item",
60
+ migrationStatus: "migrated",
61
+ billingStatus: "cancel_scheduled",
62
+ scheduledDisableAt: "2026-06-01T00:00:00.000Z",
63
+ canCancelScheduledDisable: true,
64
+ isLegacy: false,
65
+ canToggleFromUI: true,
66
+ };
67
+
68
+ expect(status.billingStatus).toBe("cancel_scheduled");
69
+ });
70
+ });