---
metadata:
  - name: generator
    content: Diplodoc Platform v5.50.6
alternate:
  - https://pay.yandex.ru/docs/en/custom/integration-guide-link.md
  - https://pay.yandex.ru/docs/ru/custom/integration-guide-link.md
---
> **Documentation Index:** Fetch the complete configuration index at https://pay.yandex.ru/docs/en/llms.txt

# Integrating by adding a Yandex Pay payment link

A payment link is the easiest method to integrate with Yandex Pay that doesn't require frontend integration. With these instructions, you can implement link generation as shown [in the demo](https://pay.yandex.ru/docs/en/custom/index.md#sequence-link). To integrate by installing a Yandex Pay button or widget, follow [other instructions](https://pay.yandex.ru/docs/en/custom/integration-guide.md).

## Requirements for connecting {#requirements}

Before getting started, [register in the merchant console](https://pay.yandex.ru/docs/en/console/index.md) and set up the test environment.

## Instructions for integrating with {#plan}

To transfer a payment:

1. [Create a link](https://pay.yandex.ru/docs/en/custom/backend/yandex-pay-api/order/merchant_v1_orders-post.md) to the Yandex Pay payment form. When generating a link, specify the available payment methods using `availablePaymentMethods`.
1. Redirect the user to the `paymentUrl` that will be contained in the response to the order creation request.
1. Wait for the order payment confirmation using [/webhook](https://pay.yandex.ru/docs/en/custom/backend/merchant-api/webhook.md) or polling the [method](https://pay.yandex.ru/docs/en/custom/backend/yandex-pay-api/order/merchant_v1_order-get.md).

## Code examples {#code-example}

{% list tabs %}

- httpie

  Example of generating a payment link using [HTTPie](https://httpie.io):

  ```bash
  http POST https://sandbox.pay.yandex.ru/api/merchant/v1/orders \
      Authorization:"API-Key a5f49c84-0baa-41e1-814f-6f99746a6987" \
      cart:='{}' \
      orderId=Order-$RANDOM \
      currencyCode=RUB \
      availablePaymentMethods:='["CARD", "SPLIT"]' \
      redirectUrls:='{"onError": "https://merchant.example/error.html", "onSuccess": "https://merchant.example/success.html"}' \
      cart:='{ "total": {"amount": "10"}, "items": [{"productId": "p1", "title": "Yandex Station Mini", "quantity": {"count": 1}, "total": "10"}]}'
  ```

- Node

  Sample merchant backend code written in [Node.js](https://nodejs.org/):

  ```javascript
  const https = require("https");

  function createOrder(orderId) {
      const ORDER_CREATE_URL =
          "https://sandbox.pay.yandex.ru/api/merchant/v1/orders";

      // In the sandbox environment, the Merchant ID is used as the authorization key.
      // In the production environment, you need to get an API key in the merchant's console.
      const API_KEY = "a5f49c84-0baa-41e1-814f-6f99746a6987";

      const orderData = {
          // Unique order ID in the merchant's system (a required parameter)
          orderId: orderId,

          // User cart details
          cart: {
              // Items in the cart
              items: [
                  {
                      productId: "3",
                      total: "15980.00",
                      title: "Yandex Station mini with a clock, pomegranate red",
                      quantity: {
                          count: "2",
                      },
                  },
              ],

              // Optional. Data about discounts applied
              discounts: [
                  {
                      amount: "500",
                      description: "Discount on the first order",
                      discountId: "first-order",
                  },
              ],

              // Total order amount
              total: {
                  amount: "15480.00",
              },
          },

          // Order currency code (ISO 4217)
          currencyCode: "RUB",

          // Get the Merchant ID in the merchant's console after registration.
          merchantId: "a5f49c84-0baa-41e1-814f-6f99746a6987",

          // URLs on merchant site to forward the user after the payment
          redirectUrls: {
              onSuccess: "https://your-site.ru/page/success",
              onError: "https://your-site.ru/page/error",
          },

          // Available payment methods.
          // Options:
          // - ["SPLIT"] — The form will only support payment via Split
          // - ["CARD"] — The form will only support payment by bank card
          // - ["SPLIT", "CARD"] — The user will be able to select between the payment methods: by bank card or Split.
          availablePaymentMethods: ["CARD", "SPLIT"],

          // Order TTL (in seconds)
          ttl: 1800,
      };

      const data = JSON.stringify(orderData);

      const requestOptions = {
          method: "POST",
          headers: {
              "Content-Type": "application/json",
              Authorization: `Api-Key ${API_KEY}`,
          },
      };

      const req = https.request(ORDER_CREATE_URL, requestOptions, (res) => {
          let response = [];

          res.on("data", (chunk) => {
              response.push(chunk);
          });

          res.on("end", () => {
              response = JSON.parse(Buffer.concat(response).toString());

              // Send paymentUrl to the frontend
              console.log(response.data.paymentUrl);
          });
      });

      req.on("error", (err) => {
          console.log("Error: ", err.message);
      });

      req.write(data);
      req.end();
  }

  createOrder("your-order-id");
  ```

{% endlist %}

## What's next {#next-step}

Read the [branding rules](https://pay.yandex.ru/docs/en/branding.md). If needed, set up transmission of [receipts for the Federal Taxation Services](https://pay.yandex.ru/docs/en/custom/fns.md), implement order management over the [Yandex Pay API](https://pay.yandex.ru/docs/en/custom/backend/merchant-api/index.md) in the merchant's backoffice, and [enable Split](https://pay.yandex.ru/docs/en/custom/split.md). To let your users pay in two steps, set up [two-step payments](https://pay.yandex.ru/docs/en/custom/payment-stages.md).
