# Payment Methods

## Prerequisites

* `access_token` from [headless-api-authentication](https://dev.ucommerce.net/readme/headless/headless-api-authentication "mention")
* `cultureCode`, e.g. `en-US` (string)
* `countryId` from [countries](https://dev.ucommerce.net/readme/headless/reference/countries "mention")

## Get Payment Methods

### Optional Parameters

* `maxItems`, limits the number of results returned. in [pagination](https://dev.ucommerce.net/readme/headless/pagination "mention")
* `nextPagingToken`, required to fetch the next page. Read more in [pagination](https://dev.ucommerce.net/readme/headless/pagination "mention")
* `priceGroupId`, limits the results to Payment Methods available for a Price Group. From [price-groups](https://dev.ucommerce.net/readme/headless/reference/price-groups "mention")

### Request

```bash
curl -D- -X POST <base_url>/api/v1/payment-methods?countryId=<countryId>&cultureCode=<cultureCode>&priceGroupId=<priceGroupId>&maxItems=<maxItems>&nextPagingToken=<nextPagingToken> \
    -H 'Authorization: Bearer <ACCESS_TOKEN>'
    -H 'Content-Type: application/json'
```

### Response

```json
{
    "nextPagingToken": "{nextPagingToken | null}",
    "paymentMethods": [
        {
            "description": "{description}",
            "displayName": "{displayName}",
            "feePercent": "{feePercent}",
            "fees": [
                {
                    "amount": "{amount}",
                    "priceGroupId": "{priceGroupId}"
                }
            ],
            "id": "{id}",
            "imageUrl": "{imageUrl}",
            "name": "{paymentName}"
        },
        {
            "displayName": "{displayName}",
            "feePercent": "{feePercent}",
            "fees": [
                {
                    "amount": "{amount}",
                    "priceGroupId": "{priceGroupId}"
                }
            ],
            "id": "{id}",
            "imageId": "{imageId}",
            "imageUrl": "{imageUrl}",
            "name": "{name}"
        }
    ]
}
```

## Error Handling

| Error              | Description                                             |
| ------------------ | ------------------------------------------------------- |
| BadRequest (400)   | PriceGroup does not exist; Country does not exist; etc. |
| Unauthorized (401) | The token is expired.                                   |
| Forbidden (403)    | The token does not have access to this endpoint.        |

Error Response Example

```json
{
"errors":
    [
        {
            "error-description": "Invalid cultureCode.",
            "error": "BadRequest"
        }
    ]
}
```

## Related Articles

{% content-ref url="../error-handling" %}
[error-handling](https://dev.ucommerce.net/readme/headless/error-handling)
{% endcontent-ref %}
