# Create a payment method

To [create](https://docs.commercelayer.io/core/creating-resources) a new payment method, send a `POST` request to the `/api/payment_methods` endpoint, passing the resource arguments in the request body.

## Request

**POST** <https://yourdomain.commercelayer.io/api/payment\\_methods>

### Arguments

| Body Parameter                                   | Type      | Required                                           |
| ------------------------------------------------ | --------- | -------------------------------------------------- |
| **type**                                         | `string`  | Required                                           |
| attributes.**name**                              | `string`  | Optional, default to titleized payment source type |
| attributes.**payment\_source\_type**             | `string`  | Required                                           |
| attributes.**currency\_code**                    | `string`  | Required, unless inherited by market               |
| attributes.**moto**                              | `boolean` | Optional, default is 'false'                       |
| attributes.**require\_capture**                  | `boolean` | Optional, deafult is 'true'                        |
| attributes.**auto\_place**                       | `boolean` | Optional, default is 'false'                       |
| attributes.**auto\_capture**                     | `boolean` | Optional, default is 'false'                       |
| attributes.**price\_amount\_cents**              | `integer` | Required                                           |
| attributes.**auto\_capture\_max\_amount\_cents** | `integer` | Optional                                           |
| attributes.**\_disable**                         | `boolean` | Optional                                           |
| attributes.**\_enable**                          | `boolean` | Optional                                           |
| attributes.**reference**                         | `string`  | Optional                                           |
| attributes.**reference\_origin**                 | `string`  | Optional                                           |
| attributes.**metadata**                          | `object`  | Optional                                           |
| relationships.**market**                         | `object`  | Optional                                           |
| relationships.**payment\_gateway**               | `object`  | Required                                           |
| relationships.**store**                          | `object`  | Optional                                           |

### Example

{% tabs %}
{% tab title="Request" %}
The following request creates a new payment method:

```shell
curl -g -X POST \
  'https://yourdomain.commercelayer.io/api/payment_methods' \
  -H 'Accept: application/vnd.api+json' \
  -H 'Authorization: Bearer your-access-token' \
  -H 'Content-Type: application/vnd.api+json' \
  -d '{
  "data": {
    "type": "payment_methods",
    "attributes": {
      "payment_source_type": "stripe_payments",
      "currency_code": "EUR",
      "price_amount_cents": 0
    },
    "relationships": {
      "payment_gateway": {
        "data": {
          "type": "payment_gateways",
          "id": "ABCRtyUpBa"
        }
      }
    }
  }
}'
```

{% endtab %}

{% tab title="Response" %}
On success, the API responds with a `201 Created` status code, returning the created resource object:

```json
{
  "data": {
    "id": "XAyRWNUzyN",
    "type": "payment_methods",
    "links": {
      "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN"
    },
    "attributes": {
      "name": "Stripe Payment",
      "payment_source_type": "stripe_payments",
      "currency_code": "EUR",
      "moto": false,
      "require_capture": true,
      "auto_place": true,
      "auto_capture": false,
      "price_amount_cents": 0,
      "price_amount_float": 0.0,
      "formatted_price_amount": "€0,00",
      "auto_capture_max_amount_cents": 0,
      "auto_capture_max_amount_float": 0.0,
      "formatted_auto_capture_max_amount": "€0,00",
      "disabled_at": "2018-01-01T12:00:00.000Z",
      "created_at": "2018-01-01T12:00:00.000Z",
      "updated_at": "2018-01-01T12:00:00.000Z",
      "reference": "ANY-EXTERNAL-REFEFERNCE",
      "reference_origin": "ANY-EXTERNAL-REFEFERNCE-ORIGIN",
      "metadata": {
        "foo": "bar"
      }
    },
    "relationships": {
      "market": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/relationships/market",
          "related": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/market"
        }
      },
      "payment_gateway": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/relationships/payment_gateway",
          "related": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/payment_gateway"
        }
      },
      "store": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/relationships/store",
          "related": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/store"
        }
      },
      "attachments": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/relationships/attachments",
          "related": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/attachments"
        }
      },
      "versions": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/relationships/versions",
          "related": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/versions"
        }
      },
      "event_stores": {
        "links": {
          "self": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/relationships/event_stores",
          "related": "https://yourdomain.commercelayer.io/api/payment_methods/XAyRWNUzyN/event_stores"
        }
      }
    },
    "meta": {
      "mode": "test",
      "organization_id": "xRRkjDFafe",
      "trace_id": "69abaa3545913c78132e5578bd26208d44aa9043647d78698fd0021f3958cd74"
    }
  }
}
```

{% endtab %}
{% endtabs %}
