IPaymentModuleService
The main service interface for the Payment Module.
Methods
createPaymentCollections
**createPaymentCollections**(data, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)[]>
This method creates payment collections.
Example
Parameters
The payment collections to create.
Returns
The created payment collections.
**createPaymentCollections**(data, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)>
This method creates a payment collection.
Example
Parameters
The payment collection to create.
Returns
The created payment collection.
retrievePaymentCollection
This method retrieves a payment collection by its ID.
Example
A simple example that retrieves a {type name} by its ID:
To specify relations that should be retrieved:
Parameters
paymentCollectionId
stringRequiredconfig
FindConfig<PaymentCollectionDTO>The configurations determining how the payment collection is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a payment collection.
config
FindConfig<PaymentCollectionDTO>select
or relations
, accept the
attributes or relations associated with a payment collection.Returns
The retrieved payment collection.
listPaymentCollections
This method retrieves a paginated list of payment collections based on optional filters and configuration.
Example
To retrieve a list of payment collections using their IDs:
To specify relations that should be retrieved within the payment collection:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
The filters to apply on the retrieved payment collection.
config
FindConfig<PaymentCollectionDTO>The configurations determining how the payment collection is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a payment collection.
config
FindConfig<PaymentCollectionDTO>select
or relations
, accept the
attributes or relations associated with a payment collection.Returns
The list of payment collections.
listAndCountPaymentCollections
This method retrieves a paginated list of payment collections along with the total count of available payment collections satisfying the provided filters.
Example
To retrieve a list of {type name} using their IDs:
To specify relations that should be retrieved within the {type name}:
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:
Parameters
The filters to apply on the retrieved payment collection.
config
FindConfig<PaymentCollectionDTO>The configurations determining how the payment collection is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a payment collection.
config
FindConfig<PaymentCollectionDTO>select
or relations
, accept the
attributes or relations associated with a payment collection.Returns
The list of payment collections along with their total count.
updatePaymentCollections
**updatePaymentCollections**(paymentCollectionId, data, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)>
This method updates an existing payment collection.
Example
Parameters
paymentCollectionId
stringRequiredThe attributes to update in the payment collection.
Returns
The updated payment collection.
**updatePaymentCollections**(selector, data, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)[]>
This method updates existing payment collections matching the specified filters.
Example
Parameters
The filters specifying which payment collections to update.
The attributes to update in the payment collections.
Returns
The updated payment collections.
upsertPaymentCollections
**upsertPaymentCollections**(data, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)[]>
This method updates or creates payment collections if they don't exist.
Example
Parameters
The attributes in the payment collections to be created or updated. If
the object includes the id
field, then the payment collection is updated. Otherise, it's created.
id
field, then the payment collection is updated. Otherise, it's created.Returns
The created or updated payment collections.
**upsertPaymentCollections**(data, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)>
This method updates or creates a payment collection if it doesn't exist.
Example
Parameters
The attributes in the payment collection to be created or updated. If the id
field is included, the payment collection is updated. Otherwise, it's created.
id
field is included, the payment collection is updated. Otherwise, it's created.Returns
The created or updated payment collection.
deletePaymentCollections
**deletePaymentCollections**(paymentCollectionId, sharedContext?): Promise<void>
This method deletes a payment collection by its ID.
Example
Parameters
paymentCollectionId
string[]RequiredReturns
Promise
Promise<void>Required**deletePaymentCollections**(paymentCollectionId, sharedContext?): Promise<void>
This method deletes a payment collection by its ID.
Example
Parameters
paymentCollectionId
stringRequiredReturns
Promise
Promise<void>RequiredcompletePaymentCollections
**completePaymentCollections**(paymentCollectionId, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)>
This method marks a payment collection as completed by settings its completed_at
field to the current date and time.
Example
Parameters
paymentCollectionId
stringRequiredReturns
The payment collection's details.
**completePaymentCollections**(paymentCollectionId, sharedContext?): Promise<[PaymentCollectionDTO](types.PaymentCollectionDTO.mdx)[]>
This method marks payment collections as completed by settings their completed_at
field to the current date and time.
Example
Parameters
paymentCollectionId
string[]RequiredReturns
The payment collections' details.
createPaymentSession
This method creates a payment session in a payment collection.
Example
Parameters
paymentCollectionId
stringRequiredThe details of the payment session.
Returns
The payment collection's details.
updatePaymentSession
This method updates a payment session.
Example
Parameters
The attributes to update in the payment session.
Returns
The payment session's details.
deletePaymentSession
This method deletes a payment session.
Example
Parameters
id
stringRequiredReturns
Promise
Promise<void>RequiredauthorizePaymentSession
This method authorizes a payment session using its associated payment provider. This creates a payment that can later be captured.
Learn more about the payment flow in this guide
Example
Parameters
id
stringRequiredcontext
Record<string, unknown>RequiredReturns
The created payment.
listPaymentSessions
This method retrieves a paginated list of payment sessions based on optional filters and configuration.
Example
To retrieve a list of payment sessions using their IDs:
To specify relations that should be retrieved within the payment session:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
The filters to apply on the retrieved payment sessions.
config
FindConfig<PaymentSessionDTO>The configurations determining how the payment session is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a payment session.
config
FindConfig<PaymentSessionDTO>select
or relations
, accept the
attributes or relations associated with a payment session.Returns
The list of payment sessions.
listPayments
This method retrieves a paginated list of payments based on optional filters and configuration.
Example
To retrieve a list of payments using their IDs:
To specify relations that should be retrieved within the payment:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterablePaymentPropsThe filters to apply on the retrieved payment.
filters
FilterablePaymentPropsconfig
FindConfig<PaymentDTO>The configurations determining how the payment is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a payment.
config
FindConfig<PaymentDTO>select
or relations
, accept the
attributes or relations associated with a payment.Returns
A list of payment.
updatePayment
This method updates an existing payment.
Example
Parameters
The attributes to update in the payment.
Returns
The updated payment.
capturePayment
This method captures a payment using its associated payment provider.
Learn more about the payment flow in this guide
Example
Parameters
The payment capture to be created.
Returns
The payment's details.
refundPayment
This method refunds a payment using its associated payment provider. An amount can only be refunded if it has been captured first.
Example
Parameters
The refund to be created.
Returns
The payment's details.
cancelPayment
This method cancels a payment.
Example
Parameters
paymentId
stringRequiredReturns
The payment's details.
listPaymentProviders
This method retrieves a paginated list of payment providers based on optional filters and configuration.
Example
To retrieve a list of payment providers using their IDs:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
The filters to apply on the retrieved payment providers.
config
FindConfig<PaymentProviderDTO>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.
config
FindConfig<PaymentProviderDTO>select
or relations
, accept the
attributes or relations associated with a payment provider.Returns
The list of payment providers.
listAndCountPaymentProviders
Parameters
config
FindConfig<PaymentProviderDTO>
config
FindConfig<PaymentProviderDTO>Returns
listCaptures
This method retrieves a paginated list of captures based on optional filters and configuration.
Example
To retrieve a list of captures using their IDs:
To specify relations that should be retrieved within the capture:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableCapturePropsThe filters to apply on the retrieved captures.
filters
FilterableCapturePropsconfig
FindConfig<CaptureDTO>The configurations determining how the capture is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a capture.
config
FindConfig<CaptureDTO>select
or relations
, accept the
attributes or relations associated with a capture.Returns
The list of captures.
listRefunds
This method retrieves a paginated list of refunds based on optional filters and configuration.
Example
To retrieve a list of refunds using their IDs:
To specify relations that should be retrieved within the refund:
By default, only the first 15
records are retrieved. You can control pagination by specifying the skip
and take
properties of the config
parameter:
Parameters
filters
FilterableRefundPropsThe filters to apply on the retrieved refunds.
filters
FilterableRefundPropsconfig
FindConfig<RefundDTO>The configurations determining how the refund is retrieved. Its properties, such as select
or relations
, accept the
attributes or relations associated with a refund.
config
FindConfig<RefundDTO>select
or relations
, accept the
attributes or relations associated with a refund.Returns
The list of refunds.
processEvent
This method handles a webhook event with the associated payment provider.
Learn more about handling webhook events in this guide
Example
In the following example, req
is an instance of MedusaRequest
:
Parameters
The webhook event's details.
Returns
Promise
Promise<void>Required