Files
medusa-store/www/apps/docs/content/references/js-client/classes/PaymentMethodsResource.mdx
github-actions[bot] cdd42dbdcd chore(docs): Generated References (#5743)
Generated the following references:
- `entities`
- `inventory`
- `js-client`
- `pricing`
- `product`
- `services`
- `stock-location`
- `workflows`

Co-authored-by: Oli Juhl <59018053+olivermrbl@users.noreply.github.com>
Co-authored-by: Shahed Nasser <27354907+shahednasser@users.noreply.github.com>
2023-11-27 18:58:52 +00:00

99 lines
3.1 KiB
Plaintext

---
displayed_sidebar: jsClientSidebar
slug: /references/js-client/PaymentMethodsResource
---
import ParameterTypes from "@site/src/components/ParameterTypes"
# PaymentMethodsResource
This class is used to send requests to Payment Method API Routes part of the [Store Customer API Routes](https://docs.medusajs.com/api/store#customers\_postcustomers). All its method
are available in the JS Client under the `medusa.customers.paymentMethods` property.
All methods in this class require [customer authentication](AuthResource.mdx#authenticate).
## Methods
#### list
Retrieve the logged-in customer's saved payment methods. This method only works with payment providers created with the deprecated Payment Service interface.
The payment methods are saved using the Payment Service's third-party service, and not on the Medusa backend. So, they're retrieved from the third-party service.
##### Example
```ts
import Medusa from "@medusajs/medusa-js"
const medusa = new Medusa({ baseUrl: MEDUSA_BACKEND_URL, maxRetries: 3 })
// must be previously logged
medusa.customers.paymentMethods.list().then(({ payment_methods }) => {
console.log(payment_methods.length)
})
```
##### Parameters
<ParameterTypes parameters={[
{
"name": "customHeaders",
"type": "`Record<string, any>`",
"description": "Custom headers to attach to the request.",
"optional": false,
"defaultValue": "{}",
"expandable": false,
"children": []
}
]} />
##### Returns
<ParameterTypes parameters={[
{
"name": "ResponsePromise",
"type": "[ResponsePromise](../internal/types/internal.ResponsePromise.mdx)&#60;[StoreCustomersListPaymentMethodsRes](../internal/types/internal.StoreCustomersListPaymentMethodsRes.mdx)&#62;",
"optional": false,
"defaultValue": "",
"description": "Resolves to the customer's payment methods.",
"expandable": false,
"children": [
{
"name": "StoreCustomersListPaymentMethodsRes",
"type": "`object`",
"description": "The payment method's details.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "payment_methods",
"type": "``{ data: object ; provider_id: string }``[]",
"description": "The details of the saved payment methods.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": [
{
"name": "data",
"type": "`object`",
"description": "The data needed for the Payment Provider to use the saved payment method.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
},
{
"name": "provider_id",
"type": "`string`",
"description": "The ID of the Payment Provider where the payment method is saved.",
"optional": false,
"defaultValue": "",
"expandable": false,
"children": []
}
]
}
]
}
]
}
]} />