Files
medusa-store/www/apps/docs/content/references/js-client/classes/PaymentMethodsResource.mdx
github-actions[bot] f35fcb810f chore(docs): Generated References (#5593)
* chore(docs): Generated References (automated)

* fix sidebar and links

* removed reflection path section

---------

Co-authored-by: shahednasser <shahednasser@users.noreply.github.com>
Co-authored-by: Shahed nasser <shahednasser@gmail.com>
2023-11-09 20:23:25 +02: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`](../modules/internal.mdx#responsepromise)<[`StoreCustomersListPaymentMethodsRes`](../modules/internal.mdx#storecustomerslistpaymentmethodsres)\\>",
"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": []
}
]
}
]
}
]
}
]} />