Integration with Yandex Pay over API
You can use two methods to integrate with Yandex Pay:
- Adding a Yandex Pay button and widget to the merchant's frontend.
- Generating a payment link and redirecting the user to the Yandex Pay payment form.
Integrating by adding a button
In this integration, to install a Yandex Pay button and widget, you need to implement the Merchant API's /order/render and /order/create methods on the backend, and integrate them into the merchant's frontend. It also enables you to extend your integration to support Yandex Pay Checkout. To implement this integration, follow the instructions for adding a Yandex Pay button.
Demo:
For more examples with the button or widget, see the Web SDK documentation.
The following sequence of steps is provided for paying (and also creating a new order for Yandex Pay Checkout):
- The buyer clicks the Yandex Pay button. The merchant uses the SDK on the frontend to specify the order ID or items in the cart in case of Yandex Pay Checkout.
- Based on the order ID or items in the cart, Yandex Pay gets the information about the order and products using order/render.
- Based on the merchant's data and the user's personal data, Yandex Pay shows the payment form or checkout form.
- The buyer selects the payment method and delivery option (if needed) and initiates payment.
- Yandex Pay requests the permission to pay for the order by calling /order/create.
- The merchant checks the order details, reserves the items, and authorizes the payment.
- Yandex Pay sends the payment through the merchant's payment gateway or Split.
- Yandex Pay notifies the merchant about the payment status using the /webhook call, if the Callback URL has been set up.
Before paying, the buyer can update the form: change the delivery address, or apply a discount coupon. After each change, the Yandex Pay backend will repeat the steps 2-3.
Integrating with link generation
This integration model is simple, but it can only be used to paying for orders. Use it when you want to quickly add a payment method to your site. For this kind of integration, follow the instructions with link generation.
Demo:
The order is paid in the following sequence:
- The user selects a Yandex Pay payment method and proceeds to the payment page. The interface for selecting a payment method is implemented by the Merchant according to the branding rules.
- The merchant's backend receives a link to the payment form using the /orders request sent to the Yandex Pay API.
- The merchant's frontend redirects the user to the Yandex Pay payment form.
- The user proceeds to the Yandex Pay payment form that renders the cart and payment amount.
- The user clicks Buy.
- Yandex Pay sends the payment through the merchant's payment gateway or Split.
- Yandex Pay notifies the merchant about the payment status using the /webhook call, if the Callback URL has been set up.
Managing orders
The merchant can manage the order using the Yandex Pay API and console: confirm and cancel payments, make a refund, etc.
What's next
To set up two-step payments, read the instructions. To generate receipts for the Federal Taxation Service in Yandex Pay, you need to transmit the receipt data along with the cart.