Skip to main content

How to Create a Payment

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

Prerequisites

Before making any call to LINKs API, you first need a merchant account. Contact our team at [email protected] to get started.

Creating a Payment

To create a payment, you will need to follow the steps below:

  1. Create a New Payment
  2. Authorize the Created Payment
  3. Check Payment Status (Optional)
  4. Capture the Payment
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.

1. Create a New Payment

To create a payment in LINKs, you need to call the Create a New Payment endpoint. The following are the parameters needed to start the payment creation:

FieldDescriptionRequired
merchantIdentifierUnique identifier for the merchant account.Yes
currencyCode

Currency code for the transaction in ISO 4217 format.

Yes
amountThe transaction amount; must be a positive number (minimum 0.01).Yes
customerIdentifierIdentifier for the customer. Used to link transactions to customer profiles.No
customerReferenceReference identifier for the customer.No
merchantOrderIdA unique identifier for the order, assigned by the merchant.Yes

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

curl --request POST \
--url https://testapi.linksmerchantservices.com/api/payments \
--header 'Content-Type: application/json' \
--header 'Authorization: Basic <your_base64_encoded_credentials>' \
--data '{
"merchantIdentifier": "<your_merchant_id>",
"currencyCode": "USD",
"amount": 10.50,
"merchantOrderId": "order_789"
}'

The response JSON will contain a paymentIdentifier, and a token, needed in Step 2

2. Authorize the Created Payment

With a payment created, you'll need the paymentIdentifier and token. The payment identifier will be used as path parameter in the Authorize a Payment endpoint. While the token is required to authorize this request.

Add the token to the Authorization header with the X-Api-Key prefix as exemplified below:

curl --request POST \
--url 'https://testapi.linksmerchantservices.com/api/payments/<PAYMENT_IDENTIFIER>/authorize' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'Authorization: X-Api-Key <TOKEN_FROM_STEP_1>' \
--data '{
"paymentMethodIdentifier": "string",
"paymentMethodType": "Unknown",
"autoCapture": false
}'
Authorize payment details

Refer to the Authorize Payment guide to find details about the Authorize method.

3. Check Payment Status (Optional)

Normally, at any point after creating a payment, you can use the Retrieve Payment endpoint to validate the payment's current status.

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

This call will return a JSON with details of the payment. You can check the status with the paymentStatus parameter.

4. Capture the Payment

In this guide example, you still need to capture the payment, as in the authorize endpoint call, the autoCapture flag was set to false. To perform this step, you need to call the Capture a Payment endpoint, adding the payment's ID as path parameter of this request:

curl --request POST \
--url 'https://testapi.linksmerchantservices.com/api/payments/<PAYMENT_IDENTIFIER>/capture' \
--header 'Accept: application/json' \
--header 'Authorization: Basic <your_base64_encoded_credentials>' \
Capturing payments

It's important to note that only authorized payments can be captured.

This will capture the payment that was previously authorized, finalizing the transaction by transfering funds from the customer to the merchant and completing this guide.