# Payment links

Payment links can be used to take online payments. You can send the links to customers via SMS, email, in a invoice etc. - that is up to you.

<figure><img src="/files/FnVtYli7hc7FDd3Wtt5P" alt="" width="232"><figcaption><p>Payment link for the customer <br>(can be branded)</p></figcaption></figure>

In order to create a payment link through the Vibrant API, do this:

{% tabs %}
{% tab title="curl" %}

```json
curl -X 'POST' \
  'https://pos-api.sandbox.vibrant.app/pos/v1/payment_link' \
  -H 'accept: application/json' \
  -H 'apikey: vibrant_pos.YOUR_API_KEY' \
  -H 'Content-Type: application/json' \
  -d '{
  "amount": 2000,
  "continueUrl": "Continue URL to redirect to after payment",
  "metadata": {
    "correlationId": "internal_order_id"
  }
}'
```

{% endtab %}
{% endtabs %}

Body:&#x20;

In the API request, the `continueUrl` parameter specifies the URL to which the customer will be redirected after completing the payment. This allows businesses to direct users back to their website or a specific page to confirm their transaction or for further actions. The `metadata` parameter is used to pass additional information with the payment request. For example, it can include a `correlationId`, such as an internal order ID, to help track transactions and correlate them with internal records. This enhances the functionality of the payment process by integrating closely with the business's backend systems.

In return you get a response containing

* vibrantUrl - to send to the customer
* paymentIntentId - use this to track when the payment succeeds/fails.

See the full API description here: [REST-api documentation](https://pos-api.sandbox.vibrant.app/docs#/payment_link/PaymentLinkController_create).

The vibrant url will redirect the customer to a payment url, when the link is ready and has not been canceled.

### Track the payment status

The payment intent will go succeeded or failed when the customer tries to pay using the payment link.

We suggest signing up for payment intent webhooks - but it is also possible to pull the payment intent by id and check the status.

### Refund

It is possible to refund a payment after the payment link has been paid and the payment has been captured.\
Provide the paymentLinkId, paymentIntentId or chargeId - and the payment will be refunded.

Providing no amount, will result in a refund of the total amount.

#### Partial refunds

Provide the refund call with an amount less than the payments total amount will create a partial refund.

The sum of more partial refunds related to the same payment cannot exceed the total amount.

### Cancel link

If the link has not been paid (authorized) yet - it is possible to cancel the link so it cannot be used by customers.

### Terminal payments vs online payments

In our merchant dashboard and in the data served from out API it is possible to distinguish payments that are created online (via online store or payment links).

The charge will hold paymentMethodDetails that are either of type `card_present` or `card_not_present`.

`card_present` represent a terminal transaction where the customer need to have the credit card (virtual or physical) present.

`card_not_present` represents an online payment, where the card details are entered on a web page.

In this way you can compare you online sales (incl payment links) vs your in-store sales.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.vibrant.io/vibrant/vibrant-sandbox/payment-links.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
