Skip to main content

ITaxCodeModuleService Reference

This section of the documentation provides a reference to the ITaxCodeModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Tax Code Module.
You should only use the methods in this reference when implementing complex customizations. For common cases, check out available workflows instead.
The main service interface for the Tax Code Module.

Methods


createTaxCodes

This section provides a reference to the createTaxCodes method. This belongs to the Tax Code Module.

createTaxCodes(data, sharedContext?): Promise<TaxCodeDTO[]>

This method creates tax codes.

Example

const taxCodes = await taxCodeModuleService.createTaxCodes([
  {
    name: "General",
    code: "txcd_00000000",
    description: "General - Tangible Goods",
  },
  {
    name: "Clothing",
    code: "txcd_20010000",
    description: "Clothing",
  },
])

Parameters

data
CreateTaxCodeDTO[]
required
The tax codes to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<TaxCodeDTO[]>
The created tax codes.

createTaxCodes(data, sharedContext?): Promise<TaxCodeDTO>

This method creates a tax code.

Example

const taxCode = await taxCodeModuleService.createTaxCodes({
  name: "General",
  code: "txcd_00000000",
  description: "General - Tangible Goods",
})

Parameters

data
CreateTaxCodeDTO
required
The tax code to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<TaxCodeDTO>
The created tax code.

updateTaxCodes

This section provides a reference to the updateTaxCodes method. This belongs to the Tax Code Module.

updateTaxCodes(id, data, sharedContext?): Promise<TaxCodeDTO>

This method updates an existing tax code.

Example

const taxCode = await taxCodeModuleService.updateTaxCodes("taxc_123", {
  name: "Updated General",
  description: "Updated description",
})

Parameters

id
string
required
The ID of the tax code.
data
UpdateTaxCodeDTO
required
The attributes to update in the tax code.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<TaxCodeDTO>
The updated tax code.

deleteTaxCodes

This section provides a reference to the deleteTaxCodes method. This belongs to the Tax Code Module.

deleteTaxCodes(ids, sharedContext?): Promise<void>

This method deletes tax codes by their IDs.

Example

await taxCodeModuleService.deleteTaxCodes(["taxc_123", "taxc_321"])

Parameters

ids
string[]
required
The IDs of the tax codes.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the tax codes are deleted successfully.

deleteTaxCodes(id, sharedContext?): Promise<void>

This method deletes a tax code by its ID.

Example

await taxCodeModuleService.deleteTaxCodes("taxc_123")

Parameters

id
string
required
The ID of the tax code.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void>
Resolves when the tax code is deleted successfully.

retrieveTaxCode

This section provides a reference to the retrieveTaxCode method. This belongs to the Tax Code Module. This method retrieves a tax code by its ID.

Example

const taxCode = await taxCodeModuleService.retrieveTaxCode("taxc_123")

Parameters

id
string
required
The ID of the tax code.
config
FindConfig<TaxCodeDTO>
The configurations determining how the tax code is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<TaxCodeDTO>
The retrieved tax code.

listTaxCodes

This section provides a reference to the listTaxCodes method. This belongs to the Tax Code Module. This method retrieves a paginated list of tax codes based on optional filters and configuration.

Example

To retrieve a list of tax codes using their IDs:
const taxCodes = await taxCodeModuleService.listTaxCodes({
  id: ["taxc_123", "taxc_321"],
})
To retrieve tax codes by code:
const taxCodes = await taxCodeModuleService.listTaxCodes({
  code: "txcd_00000000",
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const taxCodes = await taxCodeModuleService.listTaxCodes(
  {},
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableTaxCodeProps
The filters to apply on the retrieved tax codes.
config
FindConfig<TaxCodeDTO>
The configurations determining how the tax code is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<TaxCodeDTO[]>
The list of tax codes.

listAndCountTaxCodes

This section provides a reference to the listAndCountTaxCodes method. This belongs to the Tax Code Module. This method retrieves a paginated list of tax codes along with the total count of available tax codes satisfying the provided filters.

Example

To retrieve a list of tax codes with count:
const [taxCodes, count] = await taxCodeModuleService.listAndCountTaxCodes({
  id: ["taxc_123", "taxc_321"],
})
By default, only the first 15 records are retrieved. You can control pagination by specifying the skip and take properties of the config parameter:
const [taxCodes, count] = await taxCodeModuleService.listAndCountTaxCodes(
  {},
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterableTaxCodeProps
The filters to apply on the retrieved tax codes.
config
FindConfig<TaxCodeDTO>
The configurations determining how the tax code is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[TaxCodeDTO[], number]>
The list of tax codes along with their total count.

softDeleteTaxCodes

This section provides a reference to the softDeleteTaxCodes method. This belongs to the Tax Code Module. This method soft deletes tax codes by their IDs.

Example

await taxCodeModuleService.softDeleteTaxCodes([
  "taxc_123",
  "taxc_321",
])

Parameters

taxCodeIds
string[]
required
The IDs of the tax codes.
config
SoftDeleteReturn<TReturnableLinkableKeys>
An object that is used to specify an entity’s related entities that should be soft-deleted when the main entity is soft-deleted.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were also soft deleted. If there are no related records, the promise resolves to void.

restoreTaxCodes

This section provides a reference to the restoreTaxCodes method. This belongs to the Tax Code Module. This method restores soft deleted tax codes by their IDs.

Example

await taxCodeModuleService.restoreTaxCodes(["taxc_123", "taxc_321"])

Parameters

taxCodeIds
string[]
required
The IDs of the tax codes.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the tax code.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<void | Record<string, string[]>>
An object that includes the IDs of related records that were restored. If there are no related records restored, the promise resolves to void.

getTaxCodes

This section provides a reference to the getTaxCodes method. This belongs to the Tax Code Module. This method fetches all available tax codes from Stripe’s Tax Code API. It automatically handles pagination to retrieve all tax codes across multiple API calls.

Example

const stripeTaxCodes = await taxCodeModuleService.getTaxCodes()

// Example response structure:
// [
//   { id: "txcd_00000000", name: "General - Tangible Goods", description: "..." },
//   { id: "txcd_20010000", name: "Clothing", description: "..." },
//   ...
// ]

Parameters

This method takes no parameters.

Returns

Promise
Promise<Stripe.TaxCode[]>
An array of all available Stripe tax codes.
This method automatically handles Stripe API pagination, fetching up to 100 records per request and continuing until all tax codes are retrieved.