Links API DocsLinks API Docs

How to Retreive a Payment Method

On this page, you will find a walk-through guide on retrieving 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.

Retrieving a Payment Method

There are three endpoints you can use to retrieve payment methods:

Retrieve Payment Method by Payment Method ID

To retrieve a payment method by its ID, you need to call the Retrieve a Payment Method endpoint. The following is the required parameter:

ParameterDescriptionRequired
paymentMethodIdentifierThe unique identifier of the payment method to retrieve.Yes

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

curl --request GET \
--url 'https://testapi.linksmerchantservices.com/api/paymentmethods/<PAYMENT_METHOD_IDENTIFIER>' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <your_base64_encoded_credentials>'
Authentication#

Depending on the request, LINKs API offers two forms of authentication, Basic and client token. Refer to the Authentication guide to learn more about it.

This will result in a JSON response exemplified below:

{
  "result": {
    "resultType": "Success",
    "merchantMessage": "Payment method retrieved successfully.",
    "logIdentifier": "def67890",
    "logAsError": false
  },
  "merchantIdentifier": "<your_merchant_id>",
  "customerIdentifier": "<optional_customer_id>",
  "customerReference": "<optional_customer_reference>",
  "paymentMethodIdentifier": "pm_123456789",
  "card": {
    "cardNumber": "************1111",
    "expiryMonth": 12,
    "expiryYear": 2025,
    "cardHolderName": "John Doe",
    "creditCardBrand": "Visa"
  },
  "billingInformation": {
    "firstLine": "123 Main St",
    "secondLine": "Apt 4B",
    "city": "Anytown",
    "region": "Anystate",
    "zipCode": "12345",
    "countryAlpha3Code": "USA",
    "countryId": 840
  }
}

Retrieve Payment Method by Customer ID

To retrieve all payment methods linked to a customer, you need to call the Retrieve Customer Payment Methods by ID endpoint. The following is the required parameter:

ParameterDescriptionRequired
customerIdentifierThe unique identifier of the customer whose payment methods you want to retrieve.Yes

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

curl --request GET \
--url 'https://testapi.linksmerchantservices.com/api/paymentmethod/customer/identifier/<CUSTOMER_IDENTIFIER>' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <your_base64_encoded_credentials>'

This will result in a JSON response exemplified below:

{
  "result": {
    "resultType": "Success",
    "merchantMessage": "Payment methods retrieved successfully.",
    "logIdentifier": "ghi90123",
    "logAsError": false
  },
  "merchantIdentifier": "<your_merchant_id>",
  "customerIdentifier": "<customer_id>",
  "customerReference": "<customer_reference>",
  "paymentMethods": [
    {
      "paymentMethodIdentifier": "pm_123456789",
      "card": {
        "cardNumber": "************1111",
        "expiryMonth": 12,
        "expiryYear": 2025,
        "cardHolderName": "John Doe",
        "creditCardBrand": "Visa"
      },
      "billingInformation": {
        "firstLine": "123 Main St",
        "secondLine": "Apt 4B",
        "city": "Anytown",
        "region": "Anystate",
        "zipCode": "12345",
        "countryAlpha3Code": "USA"
      }
    },
    {
      "paymentMethodIdentifier": "pm_987654321",
      "card": {
        "cardNumber": "************4242",
        "expiryMonth": 6,
        "expiryYear": 2024,
        "cardHolderName": "Jane Smith",
        "creditCardBrand": "MasterCard"
      },
      "billingInformation": {
        "firstLine": "456 Elm St",
        "secondLine": null,
        "city": "Othertown",
        "region": "Otherstate",
        "zipCode": "67890",
        "countryAlpha3Code": "USA"
      }
    }
  ]
}
Handling Multiple Payment Methods#

The paymentMethods array may contain multiple payment methods if the customer has more than one saved. Each entry provides the details of a specific payment method.

Retrieve Payment Method by Customer Reference

To retrieve all payment methods linked to a customer reference, you need to call the Retrieve Customer Payment Methods by Reference endpoint. The following is the required parameter:

ParameterDescriptionRequired
customerReferenceThe unique reference of the customer whose payment methods you want to retrieve.Yes

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

curl --request GET \
--url 'https://testapi.linksmerchantservices.com/api/paymentmethod/customer/reference/<CUSTOMER_REFERENCE>' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <your_base64_encoded_credentials>'

This will result in a JSON response exemplified below:

{
  "result": {
    "resultType": "Success",
    "merchantMessage": "Payment methods retrieved successfully.",
    "logIdentifier": "mno12345",
    "logAsError": false
  },
  "merchantIdentifier": "<your_merchant_id>",
  "customerIdentifier": "<customer_id>",
  "customerReference": "<customer_reference>",
  "paymentMethods": [
    {
      "paymentMethodIdentifier": "pm_123456789",
      "card": {
        "cardNumber": "************1111",
        "expiryMonth": 12,
        "expiryYear": 2025,
        "cardHolderName": "John Doe",
        "creditCardBrand": "Visa"
      },
      "billingInformation": {
        "firstLine": "123 Main St",
        "secondLine": "Apt 4B",
        "city": "Anytown",
        "region": "Anystate",
        "zipCode": "12345",
        "countryAlpha3Code": "USA"
      }
    },
    {
      "paymentMethodIdentifier": "pm_987654321",
      "card": {
        "cardNumber": "************4242",
        "expiryMonth": 6,
        "expiryYear": 2024,
        "cardHolderName": "Jane Smith",
        "creditCardBrand": "MasterCard"
      },
      "billingInformation": {
        "firstLine": "456 Elm St",
        "secondLine": null,
        "city": "Othertown",
        "region": "Otherstate",
        "zipCode": "67890",
        "countryAlpha3Code": "USA"
      }
    }
  ]
}
Handling Multiple Payment Methods#

The paymentMethods array may contain multiple payment methods if the customer has more than one saved. Each entry provides the details of a specific payment method.