# How to Create a Payment Method

On this page, you will find a walk-through guide on creating a payment method and the necessary information to accomplish this task.

## Prerequisites

Before making any call to the LINKs API, you first need a merchant account. Contact our team at Discover@LinksMerchantServices.com to get started.

## Creating a Payment Method

To create a payment method in LINKs, you need to call the [Create a New Payment Method endpoint](/api/payment-method/post-api-paymentmethod). The following are the parameters needed to initiate the payment method creation:

<table>
  <thead>
    <tr>
      <th><strong>Field</strong></th>
      <th><strong>Description</strong></th>
      <th><strong>Required</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>merchantIdentifier</code></td>
      <td>A unique identifier for the merchant, used to associate the payment method with the correct merchant account.</td>
      <td>Yes</td>
    </tr>
    <tr>
      <td><code>customerIdentifier</code></td>
      <td>A unique identifier for the customer. This is optional and can be used to associate the payment method with a specific customer.</td>
      <td>No</td>
    </tr>
    <tr>
      <td><code>customerReference</code></td>
      <td>An optional reference provided by the merchant to identify the customer.</td>
      <td>No</td>
    </tr>
    <tr>
      <td><code>card</code></td>
      <td>Details about the credit card used for the payment method.</td>
      <td>Yes</td>
    </tr>
    <tr>
      <td><code>billingInformation</code></td>
      <td>Billing address and contact details associated with the payment method.</td>
      <td>No</td>
    </tr>
  </tbody>
</table>


Within the `card` object, the following fields are used:

<table>
  <thead>
    <tr>
      <th><strong>Field</strong></th>
      <th><strong>Description</strong></th>
      <th><strong>Required</strong></th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td><code>cardNumber</code></td>
      <td>The credit card number.</td>
      <td>Yes</td>
    </tr>
    <tr>
      <td><code>expiryMonth</code></td>
      <td>The expiry month of the credit card (1-12).</td>
      <td>Yes</td>
    </tr>
    <tr>
      <td><code>expiryYear</code></td>
      <td>The expiry year of the credit card (e.g., 2025).</td>
      <td>Yes</td>
    </tr>
    <tr>
      <td><code>cardHolderName</code></td>
      <td>The name of the cardholder as it appears on the credit card.</td>
      <td>No</td>
    </tr>
    <tr>
      <td><code>cvv</code></td>
      <td>The card verification value (CVV) for the credit card.</td>
      <td>No</td>
    </tr>
    <tr>
      <td><code>creditCardBrand</code></td>
      <td>
        The brand of the credit card, such as Visa or MasterCard.<br/>
        Accepted values: <code>MasterCard</code>, <code>Visa</code>, <code>Amex</code>, <code>Discover</code>, <code>JCB</code>.
      </td>
      <td>Yes</td>
    </tr>
  </tbody>
</table>


You can use the code snippet below to make the endpoint call with the required parameters:

```sh
curl --request POST \
--url https://testapi.linksmerchantservices.com/api/paymentmethods \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <your_base64_encoded_credentials>' \
--data '{
  "merchantIdentifier": "<your_merchant_id>",
  "customerIdentifier": "<optional_customer_id>",
  "customerReference": "<optional_customer_reference>",
  "card": {
    "cardNumber": "4111111111111111",
    "expiryMonth": 12,
    "expiryYear": 2025,
    "cardHolderName": "John Doe",
    "cvv": "123",
    "creditCardBrand": "Visa"
  }
  "billingInformation": {
    "firstLine": "540 NE 4th st",
    "secondLine": "Second Floor",
    "city": "FLL",
    "region": "FL",
    "zipCode": "33091",
    "countryAlpha3Code": "USA"
  },
}'
```

<Callout type="info" title="Authentication">
  Depending on the request, LINKs API offers two forms of authentication,
  `Basic` and `client token`. Refer to the [Authentication](/authentication)
  guide to learn more about it.
</Callout>

This will result in a JSON response exemplified below:

```json
{
  "merchantIdentifier": "af9a9d3e-3d3b-4f7d-9fde-4169f1abedd5",
  "customerIdentifier": "c8ee51a9-f6c0-4108-a7c1-c8a821ffce2c",
  "customerReference": "154564559",
  "paymentMethodIdentifier": "583c748c-beea-4dc1-808a-2f34309e62f5",
  "card": {
    "cardNumber": "4111111111111111",
    "expiryMonth": 12,
    "expiryYear": 2025,
    "cardHolderName": "John Doe",
    "cvv": "123",
    "creditCardBrand": "Visa"
  },
  "billingInformation": {
    "firstLine": "540 NE 4th st",
    "secondLine": "Second Floor",
    "city": "FLL",
    "region": "FL",
    "zipCode": "33091",
    "countryAlpha3Code": "USA",
    "countryId": 1
  },
  "result": {
    "resultType": "Accepted",
    "merchantMessage": "",
    "logIdentifier": "60554180-07ed-4cd0-92ca-3b5ac79c1fb3",
    "logAsError": false
  }
}
```

With the `paymentMethodIdentifier` found in the response, you can either [retrieve](/how-to-retrieve-a-payment-method), [update](/how-to-update-a-payment-method) or [delete](/how-to-delete-a-payment-method) the newly created payment method.