Skip to main content

IPayoutModuleService Reference

This section of the documentation provides a reference to the IPayoutModuleService interface’s methods. This is the interface developers use to use the functionalities provided by the Payout 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 Payout Module.

Methods

PayoutAccount Methods

Onboarding Methods

Payout Methods

Payout Reversal Methods

Webhook Methods


createPayoutAccount

This section provides a reference to the createPayoutAccount method. This belongs to the Payout Module. This method creates a payout account by initializing it with the payout provider (e.g., Stripe Connect).

Example

const payoutAccount = await payoutModuleService.createPayoutAccount({
  context: {
    seller_id: "sel_123",
    country: "US",
    business_type: "company",
  },
})

Parameters

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

Returns

Promise
Promise<PayoutAccountDTO>
The created payout account.

syncStripeAccount

This section provides a reference to the syncStripeAccount method. This belongs to the Payout Module. This method syncs a payout account with the Stripe Connect account status. It fetches the latest account details from Stripe and updates the local payout account status based on whether the account is fully verified and authorized.

Example

const payoutAccount = await payoutModuleService.syncStripeAccount("pacc_123")

Parameters

account_id
string
required
The ID of the payout account to sync.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<PayoutAccountDTO>
The synced payout account with updated status.

initializeOnboarding

This section provides a reference to the initializeOnboarding method. This belongs to the Payout Module. This method initializes or updates the onboarding process for a payout account with the payout provider. If an onboarding record already exists, it updates it; otherwise, it creates a new one.

Example

const onboarding = await payoutModuleService.initializeOnboarding({
  payout_account_id: "pacc_123",
  context: {
    refresh_url: "https://example.com/onboarding",
    return_url: "https://example.com/dashboard",
  },
})

Parameters

data
CreateOnboardingDTO
required
The onboarding data.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OnboardingDTO>
The initialized or updated onboarding record.

createPayout

This section provides a reference to the createPayout method. This belongs to the Payout Module. This method creates a payout by processing a money transfer through the payout provider (e.g., Stripe Transfer).

Example

const payout = await payoutModuleService.createPayout({
  amount: 10000,
  currency_code: "usd",
  account_id: "pacc_123",
  transaction_id: "txn_123",
  source_transaction: "ch_456",
})

Parameters

input
CreatePayoutDTO
required
The payout to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<PayoutDTO>
The created payout.

createPayoutReversal

This section provides a reference to the createPayoutReversal method. This belongs to the Payout Module. This method creates a payout reversal by reversing a previous payout through the payout provider.

Example

const reversal = await payoutModuleService.createPayoutReversal({
  payout_id: "pout_123",
  amount: 5000,
  currency_code: "usd",
})

Parameters

input
CreatePayoutReversalDTO
required
The payout reversal to be created.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<PayoutReversalDTO>
The created payout reversal.

getWebhookActionAndData

This section provides a reference to the getWebhookActionAndData method. This belongs to the Payout Module. This method processes webhook events from the payout provider and returns the action type and associated data.

Example

const result = await payoutModuleService.getWebhookActionAndData({
  data: webhookEvent,
  rawData: req.rawBody,
  headers: req.headers,
})

Parameters

input
PayoutWebhookActionPayload
required
The webhook payload data.

Returns

Promise
Promise<PayoutWebhookActionAndDataResponse>
The webhook action and associated data.

updatePayoutAccounts

This section provides a reference to the updatePayoutAccounts method. This belongs to the Payout Module.

updatePayoutAccounts(id, data, sharedContext?): Promise<PayoutAccountDTO>

This method updates an existing payout account.

Example

const payoutAccount = await payoutModuleService.updatePayoutAccounts("pacc_123", {
  status: "active",
})

Parameters

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

Returns

Promise
Promise<PayoutAccountDTO>
The updated payout account.

deletePayoutAccounts

This section provides a reference to the deletePayoutAccounts method. This belongs to the Payout Module.

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

This method deletes payout accounts by their IDs.

Example

await payoutModuleService.deletePayoutAccounts(["pacc_123", "pacc_321"])

Parameters

ids
string[]
required
The IDs of the payout accounts.
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 payout accounts are deleted successfully.

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

This method deletes a payout account by its ID.

Example

await payoutModuleService.deletePayoutAccounts("pacc_123")

Parameters

id
string
required
The ID of the payout account.
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 payout account is deleted successfully.

retrievePayoutAccount

This section provides a reference to the retrievePayoutAccount method. This belongs to the Payout Module. This method retrieves a payout account by its ID.

Example

const payoutAccount = await payoutModuleService.retrievePayoutAccount("pacc_123")
To retrieve relationships:
const payoutAccount = await payoutModuleService.retrievePayoutAccount(
  "pacc_123",
  {
    relations: ["onboarding", "payouts"],
  }
)

Parameters

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

Returns

Promise
Promise<PayoutAccountDTO>
The retrieved payout account.

listPayoutAccounts

This section provides a reference to the listPayoutAccounts method. This belongs to the Payout Module. This method retrieves a paginated list of payout accounts based on optional filters and configuration.

Example

const payoutAccounts = await payoutModuleService.listPayoutAccounts({
  status: "active",
})
By default, only the first 15 records are retrieved. You can control pagination:
const payoutAccounts = await payoutModuleService.listPayoutAccounts(
  {
    status: "active",
  },
  {
    take: 20,
    skip: 2,
  }
)

Parameters

filters
FilterablePayoutAccountProps
The filters to apply on the retrieved payout accounts.
config
FindConfig<PayoutAccountDTO>
The configurations determining how the payout account is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<PayoutAccountDTO[]>
The list of payout accounts.

listAndCountPayoutAccounts

This section provides a reference to the listAndCountPayoutAccounts method. This belongs to the Payout Module. This method retrieves a paginated list of payout accounts along with the total count of available payout accounts satisfying the provided filters.

Example

const [payoutAccounts, count] = await payoutModuleService.listAndCountPayoutAccounts({
  status: "active",
})

Parameters

filters
FilterablePayoutAccountProps
The filters to apply on the retrieved payout accounts.
config
FindConfig<PayoutAccountDTO>
The configurations determining how the payout account is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[PayoutAccountDTO[], number]>
The list of payout accounts along with their total count.

softDeletePayoutAccounts

This section provides a reference to the softDeletePayoutAccounts method. This belongs to the Payout Module. This method soft deletes payout accounts by their IDs.

Example

await payoutModuleService.softDeletePayoutAccounts([
  "pacc_123",
  "pacc_321",
])

Parameters

payoutAccountIds
string[]
required
The IDs of the payout accounts.
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.

restorePayoutAccounts

This section provides a reference to the restorePayoutAccounts method. This belongs to the Payout Module. This method restores soft deleted payout accounts by their IDs.

Example

await payoutModuleService.restorePayoutAccounts(["pacc_123", "pacc_321"])

Parameters

payoutAccountIds
string[]
required
The IDs of the payout accounts.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the payout account.
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.

updateOnboardings

This section provides a reference to the updateOnboardings method. This belongs to the Payout Module.

updateOnboardings(id, data, sharedContext?): Promise<OnboardingDTO>

This method updates an existing onboarding record.

Example

const onboarding = await payoutModuleService.updateOnboardings("onb_123", {
  data: { url: "https://connect.stripe.com/setup/..." },
})

Parameters

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

Returns

Promise
Promise<OnboardingDTO>
The updated onboarding.

deleteOnboardings

This section provides a reference to the deleteOnboardings method. This belongs to the Payout Module.

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

This method deletes onboardings by their IDs.

Example

await payoutModuleService.deleteOnboardings(["onb_123", "onb_321"])

Parameters

ids
string[]
required
The IDs of the onboardings.
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 onboardings are deleted successfully.

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

This method deletes an onboarding by its ID.

Example

await payoutModuleService.deleteOnboardings("onb_123")

Parameters

id
string
required
The ID of the onboarding.
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 onboarding is deleted successfully.

retrieveOnboarding

This section provides a reference to the retrieveOnboarding method. This belongs to the Payout Module. This method retrieves an onboarding by its ID.

Example

const onboarding = await payoutModuleService.retrieveOnboarding("onb_123")

Parameters

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

Returns

Promise
Promise<OnboardingDTO>
The retrieved onboarding.

listOnboardings

This section provides a reference to the listOnboardings method. This belongs to the Payout Module. This method retrieves a paginated list of onboardings based on optional filters and configuration.

Example

const onboardings = await payoutModuleService.listOnboardings({
  payout_account_id: "pacc_123",
})

Parameters

filters
FilterableOnboardingProps
The filters to apply on the retrieved onboardings.
config
FindConfig<OnboardingDTO>
The configurations determining how the onboarding is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<OnboardingDTO[]>
The list of onboardings.

listAndCountOnboardings

This section provides a reference to the listAndCountOnboardings method. This belongs to the Payout Module. This method retrieves a paginated list of onboardings along with the total count of available onboardings satisfying the provided filters.

Example

const [onboardings, count] = await payoutModuleService.listAndCountOnboardings({
  payout_account_id: "pacc_123",
})

Parameters

filters
FilterableOnboardingProps
The filters to apply on the retrieved onboardings.
config
FindConfig<OnboardingDTO>
The configurations determining how the onboarding is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[OnboardingDTO[], number]>
The list of onboardings along with their total count.

softDeleteOnboardings

This section provides a reference to the softDeleteOnboardings method. This belongs to the Payout Module. This method soft deletes onboardings by their IDs.

Example

await payoutModuleService.softDeleteOnboardings([
  "onb_123",
  "onb_321",
])

Parameters

onboardingIds
string[]
required
The IDs of the onboardings.
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.

restoreOnboardings

This section provides a reference to the restoreOnboardings method. This belongs to the Payout Module. This method restores soft deleted onboardings by their IDs.

Example

await payoutModuleService.restoreOnboardings(["onb_123", "onb_321"])

Parameters

onboardingIds
string[]
required
The IDs of the onboardings.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the onboarding.
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.

createPayouts

This section provides a reference to the createPayouts method. This belongs to the Payout Module.

createPayouts(data, sharedContext?): Promise<PayoutDTO[]>

This method creates payouts.

Example

const payouts = await payoutModuleService.createPayouts([
  {
    amount: 10000,
    currency_code: "usd",
    payout_account_id: "pacc_123",
    data: { transfer_id: "tr_123" },
  },
])

Parameters

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

Returns

Promise
Promise<PayoutDTO[]>
The created payouts.

updatePayouts

This section provides a reference to the updatePayouts method. This belongs to the Payout Module.

updatePayouts(id, data, sharedContext?): Promise<PayoutDTO>

This method updates an existing payout.

Example

const payout = await payoutModuleService.updatePayouts("pout_123", {
  data: { status: "paid" },
})

Parameters

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

Returns

Promise
Promise<PayoutDTO>
The updated payout.

deletePayouts

This section provides a reference to the deletePayouts method. This belongs to the Payout Module.

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

This method deletes payouts by their IDs.

Example

await payoutModuleService.deletePayouts(["pout_123", "pout_321"])

Parameters

ids
string[]
required
The IDs of the payouts.
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 payouts are deleted successfully.

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

This method deletes a payout by its ID.

Example

await payoutModuleService.deletePayouts("pout_123")

Parameters

id
string
required
The ID of the payout.
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 payout is deleted successfully.

retrievePayout

This section provides a reference to the retrievePayout method. This belongs to the Payout Module. This method retrieves a payout by its ID.

Example

const payout = await payoutModuleService.retrievePayout("pout_123")
To retrieve relationships:
const payout = await payoutModuleService.retrievePayout(
  "pout_123",
  {
    relations: ["payout_account", "reversals"],
  }
)

Parameters

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

Returns

Promise
Promise<PayoutDTO>
The retrieved payout.

listPayouts

This section provides a reference to the listPayouts method. This belongs to the Payout Module. This method retrieves a paginated list of payouts based on optional filters and configuration.

Example

const payouts = await payoutModuleService.listPayouts({
  payout_account_id: "pacc_123",
})

Parameters

filters
FilterablePayoutProps
The filters to apply on the retrieved payouts.
config
FindConfig<PayoutDTO>
The configurations determining how the payout is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<PayoutDTO[]>
The list of payouts.

listAndCountPayouts

This section provides a reference to the listAndCountPayouts method. This belongs to the Payout Module. This method retrieves a paginated list of payouts along with the total count of available payouts satisfying the provided filters.

Example

const [payouts, count] = await payoutModuleService.listAndCountPayouts({
  payout_account_id: "pacc_123",
})

Parameters

filters
FilterablePayoutProps
The filters to apply on the retrieved payouts.
config
FindConfig<PayoutDTO>
The configurations determining how the payout is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[PayoutDTO[], number]>
The list of payouts along with their total count.

softDeletePayouts

This section provides a reference to the softDeletePayouts method. This belongs to the Payout Module. This method soft deletes payouts by their IDs.

Example

await payoutModuleService.softDeletePayouts([
  "pout_123",
  "pout_321",
])

Parameters

payoutIds
string[]
required
The IDs of the payouts.
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.

restorePayouts

This section provides a reference to the restorePayouts method. This belongs to the Payout Module. This method restores soft deleted payouts by their IDs.

Example

await payoutModuleService.restorePayouts(["pout_123", "pout_321"])

Parameters

payoutIds
string[]
required
The IDs of the payouts.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the payout.
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.

createPayoutReversals

This section provides a reference to the createPayoutReversals method. This belongs to the Payout Module.

createPayoutReversals(data, sharedContext?): Promise<PayoutReversalDTO[]>

This method creates payout reversals.

Example

const reversals = await payoutModuleService.createPayoutReversals([
  {
    amount: 5000,
    currency_code: "usd",
    payout_id: "pout_123",
    data: { reversal_id: "trr_123" },
  },
])

Parameters

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

Returns

Promise
Promise<PayoutReversalDTO[]>
The created payout reversals.

updatePayoutReversals

This section provides a reference to the updatePayoutReversals method. This belongs to the Payout Module.

updatePayoutReversals(id, data, sharedContext?): Promise<PayoutReversalDTO>

This method updates an existing payout reversal.

Example

const reversal = await payoutModuleService.updatePayoutReversals("prev_123", {
  data: { status: "succeeded" },
})

Parameters

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

Returns

Promise
Promise<PayoutReversalDTO>
The updated payout reversal.

deletePayoutReversals

This section provides a reference to the deletePayoutReversals method. This belongs to the Payout Module.

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

This method deletes payout reversals by their IDs.

Example

await payoutModuleService.deletePayoutReversals(["prev_123", "prev_321"])

Parameters

ids
string[]
required
The IDs of the payout reversals.
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 payout reversals are deleted successfully.

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

This method deletes a payout reversal by its ID.

Example

await payoutModuleService.deletePayoutReversals("prev_123")

Parameters

id
string
required
The ID of the payout reversal.
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 payout reversal is deleted successfully.

retrievePayoutReversal

This section provides a reference to the retrievePayoutReversal method. This belongs to the Payout Module. This method retrieves a payout reversal by its ID.

Example

const reversal = await payoutModuleService.retrievePayoutReversal("prev_123")

Parameters

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

Returns

Promise
Promise<PayoutReversalDTO>
The retrieved payout reversal.

listPayoutReversals

This section provides a reference to the listPayoutReversals method. This belongs to the Payout Module. This method retrieves a paginated list of payout reversals based on optional filters and configuration.

Example

const reversals = await payoutModuleService.listPayoutReversals({
  payout_id: "pout_123",
})

Parameters

filters
FilterablePayoutReversalProps
The filters to apply on the retrieved payout reversals.
config
FindConfig<PayoutReversalDTO>
The configurations determining how the payout reversal is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<PayoutReversalDTO[]>
The list of payout reversals.

listAndCountPayoutReversals

This section provides a reference to the listAndCountPayoutReversals method. This belongs to the Payout Module. This method retrieves a paginated list of payout reversals along with the total count of available payout reversals satisfying the provided filters.

Example

const [reversals, count] = await payoutModuleService.listAndCountPayoutReversals({
  payout_id: "pout_123",
})

Parameters

filters
FilterablePayoutReversalProps
The filters to apply on the retrieved payout reversals.
config
FindConfig<PayoutReversalDTO>
The configurations determining how the payout reversal is retrieved.
sharedContext
Context
A context used to share resources, such as transaction manager, between the application and the module.

Returns

Promise
Promise<[PayoutReversalDTO[], number]>
The list of payout reversals along with their total count.

softDeletePayoutReversals

This section provides a reference to the softDeletePayoutReversals method. This belongs to the Payout Module. This method soft deletes payout reversals by their IDs.

Example

await payoutModuleService.softDeletePayoutReversals([
  "prev_123",
  "prev_321",
])

Parameters

payoutReversalIds
string[]
required
The IDs of the payout reversals.
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.

restorePayoutReversals

This section provides a reference to the restorePayoutReversals method. This belongs to the Payout Module. This method restores soft deleted payout reversals by their IDs.

Example

await payoutModuleService.restorePayoutReversals(["prev_123", "prev_321"])

Parameters

payoutReversalIds
string[]
required
The IDs of the payout reversals.
config
RestoreReturn<TReturnableLinkableKeys>
Configurations determining which relations to restore along with each of the payout reversal.
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.