Skip to content

Commit

Permalink
chore: update TSDocs of account holder additions
Browse files Browse the repository at this point in the history
  • Loading branch information
shahednasser committed Feb 24, 2025
1 parent f00e6bf commit 5bb1d64
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 12 deletions.
20 changes: 18 additions & 2 deletions packages/core/types/src/payment/provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export type CreateAccountHolderInput = PaymentProviderInput & {

export type UpdateAccountHolderInput = PaymentProviderInput & {
/**
* The context of creating the account holder.
* The context of updating the account holder.
*/
context: PaymentProviderContext & {
/**
Expand Down Expand Up @@ -335,10 +335,26 @@ export type CreateAccountHolderOutput = PaymentProviderOutput & {
id: string
}

/**
* @interface
*
* The result of updating an account holder in the third-party payment provider. The `data`
* property is stored as-is in Medusa's account holder's `data` property.
*/
export type UpdateAccountHolderOutput = PaymentProviderOutput

/**
* @interface
*
* The result of deleting an account holder in the third-party payment provider.
*/
export type DeleteAccountHolderOutput = PaymentProviderOutput

/**
* @interface
*
* The result of listing payment methods for an account holder in the third-party payment provider.
*/
export type ListPaymentMethodsOutput = (PaymentProviderOutput & {
/**
* The ID of the payment method in the payment provider.
Expand Down Expand Up @@ -490,7 +506,7 @@ export interface IPaymentProvider {
* @param data - Input data including the details of the account holder to update.
* @returns The result of updating the account holder. If an error occurs, throw it.
*
* @version 2.6.0
* @version 2.5.1
*
* @example
* import { MedusaError } from "@medusajs/framework/utils"
Expand Down
71 changes: 61 additions & 10 deletions packages/core/types/src/payment/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ export interface IPaymentModuleService extends IModuleService {
* @returns {Promise<PaymentCollectionDTO>} The retrieved payment collection.
*
* @example
* A simple example that retrieves a {type name} by its ID:
* A simple example that retrieves a payment collection by its ID:
*
* ```ts
* const paymentCollection =
Expand Down Expand Up @@ -195,7 +195,7 @@ export interface IPaymentModuleService extends IModuleService {
* @returns {Promise<[PaymentCollectionDTO[], number]>} The list of payment collections along with their total count.
*
* @example
* To retrieve a list of {type name} using their IDs:
* To retrieve a list of payment collection using their IDs:
*
* ```ts
* const paymentCollections =
Expand All @@ -204,7 +204,7 @@ export interface IPaymentModuleService extends IModuleService {
* })
* ```
*
* To specify relations that should be retrieved within the {type name}:
* To specify relations that should be retrieved within the payment collection:
*
* ```ts
* const paymentCollections =
Expand All @@ -218,7 +218,7 @@ export interface IPaymentModuleService extends IModuleService {
* )
* ```
*
* By default, only the first `{default limit}` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const paymentCollections =
Expand Down Expand Up @@ -749,18 +749,69 @@ export interface IPaymentModuleService extends IModuleService {
sharedContext?: Context
): Promise<PaymentProviderDTO[]>

/**
* This method retrieves a paginated list of payment providers along with the total count of available payment providers satisfying the provided filters.
*
* @param {FilterablePaymentProviderProps} filters - The filters to apply on the retrieved payment provider.
* @param {FindConfig<PaymentProviderDTO>} config - The configurations determining how the payment provider is retrieved. Its properties, such as `select` or `relations`, accept the
* attributes or relations associated with a payment provider.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<[PaymentProviderDTO[], number]>} The list of payment providers along with their total count.
*
* @example
* To retrieve a list of payment providers using their IDs:
*
* ```ts
* const [paymentProviders, count] =
* await paymentModuleService.listAndCountPaymentProviders({
* id: ["pp_stripe_stripe"],
* })
* ```
*
* To specify relations that should be retrieved within the payment providers:
*
* ```ts
* const [paymentProviders, count] =
* await paymentModuleService.listAndCountPaymentProviders(
* {
* id: ["pp_stripe_stripe"],
* },
* {
* relations: ["payment_collections"],
* }
* )
* ```
*
* By default, only the first `15` records are retrieved. You can control pagination by specifying the `skip` and `take` properties of the `config` parameter:
*
* ```ts
* const [paymentProviders, count] =
* await paymentModuleService.listAndCountPaymentProviders(
* {
* id: ["pp_stripe_stripe"],
* },
* {
* relations: ["payment_collections"],
* take: 20,
* skip: 2,
* }
* )
* ```
*
*
*/
listAndCountPaymentProviders(
filters?: FilterablePaymentProviderProps,
config?: FindConfig<PaymentProviderDTO>,
sharedContext?: Context
): Promise<[PaymentProviderDTO[], number]>

/**
* This method creates(if supported by provider) the account holder in the payment provider.
* This method creates an account holder in the payment provider, if the provider supports account holders.
*
* @param {CreateAccountHolderDTO} data - The details of the account holder.
* @param {CreateAccountHolderDTO} input - The details of the account holder.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, unknown>>} The account holder's details in the payment provider, typically just the ID.
* @returns {Promise<AccountHolderDTO>} The created account holder's details.
*
* @example
* const accountHolder =
Expand Down Expand Up @@ -790,11 +841,11 @@ export interface IPaymentModuleService extends IModuleService {
): Promise<AccountHolderDTO>

/**
* This method updates(if supported by provider) the account holder in the payment provider.
* This method updates an account holder in the payment provider, if the provider supports account holders.
*
* @param {UpdateAccountHolderDTO} data - The details of the account holder.
* @param {UpdateAccountHolderDTO} input - The details of the account holder to update.
* @param {Context} sharedContext - A context used to share resources, such as transaction manager, between the application and the module.
* @returns {Promise<Record<string, unknown>>} The account holder's details in the payment provider, typically just the ID.
* @returns {Promise<AccountHolderDTO>} The updated account holder's details.
*
* @example
* const accountHolder =
Expand Down

0 comments on commit 5bb1d64

Please sign in to comment.