listAndCountPaymentMethods - Payment Module Reference

This documentation provides a reference to the listAndCountPaymentMethods method. This belongs to the Payment Module.

NoteYou should only use this methods when implementing complex customizations. For common cases, check out available workflows instead.

This method retrieves all payment methods along with the total count of available payment methods, based on the context and configuration.

Example#

To retrieve a list of payment methods for a customer:

Code
1const [paymentMethods, count] =2  await paymentModuleService.listAndCountPaymentMethods({3    provider_id: "pp_stripe_stripe",4    context: {5      customer: {6        id: "cus_123",7        metadata: {8          pp_stripe_stripe_customer_id: "str_1234"9        }10      },11    },12  })

Parameters#

The filters to apply on the retrieved payment methods.
The configurations determining how the payment method is retrieved. Its properties, such as select or relations, accept the attributes or relations associated with a payment method.
sharedContextContextOptional
A context used to share resources, such as transaction manager, between the application and the module.

Returns#

PromisePromise<[PaymentMethodDTO[], number]>
The list of payment methods along with their total count.
Was this page helpful?
Ask Anything
FAQ
What is Medusa?
How can I create a module?
How can I create a data model?
How do I create a workflow?
How can I extend a data model in the Product Module?
Recipes
How do I build a marketplace with Medusa?
How do I build digital products with Medusa?
How do I build subscription-based purchases with Medusa?
What other recipes are available in the Medusa documentation?
Chat is cleared on refresh
Line break