Андрей Смирнов
Время чтения: ~5 мин.
Просмотров: 9

Приём оплаты через яндекс деньги

Receiving payments using forms

This scenario is unique in its simplicity of integration and variety of payment methods. There are several steps for using Yandex.Checkout payment forms in a mobile app:

  1. Initializing WebView with POST parameters according to the payment form.

  2. Server-side processing of HTTP requests for order verification and notification of payment (if activation is performed using HTTP notifications with either HTTP Protocol or CMS Module implementation).

  3. Processing redirects from the payment information page when clicking the «Go to the store’s site» button (WebView closes).

Note.

You can turn on automatically redirecting the user from the successful payment and error pages, a few seconds after payment. To find out how to turn on redirection, contact a Yandex.Checkout manager.

Tip. You can receive payments in a mobile app using WebView, or using a payment form on the site with the payment solution protocol for merchants. You can implement your own logic for transmitting payment information from the server application to the mobile app, if necessary. You get the successful payment ID in the notification of payment.

Страница оплаты

Чтобы принимать Яндекс Деньги на сайте, нужно создать страницу и разместить на ней форму, которая приведена
далее. Атрибуты тега <form> должны быть такие, как в примере. Все поля
являются обязательными.

+

8910111213141516
<form id="pay" action="https://money.yandex.ru/quickpay/confirm.xml" method="post">
  <input type="text" name="targets">
  <input type="text" name="sum">
  <input type="hidden" name="receiver" value="435824873316172">
  <input type="hidden" name="quickpay-form" value="shop">
  <input type="hidden" name="paymentType" value="PC">
  <input type="hidden" name="successURL" value="http://mysite.ru/success.html">
  <input type="submit" value="Оплатить">
</form>

Рассмотрим поля формы.

targets — назначение платежа, например, название товара

sum — сумма платежа

reciver — номер кошелька, на который будет приходить оплата

quikpay-form — тип формы. Значения: shop — обычная форма,
donate — благотворительная форма, small — кнопка

paymentType — способ оплаты. Значения: PC — с кошелька, AC — банковской
картой, MC — с баланса телефона

successURL — страница, на которую переходит пользователь после оплаты. Для
системы Яндекс Деньги это поле не обязательно. Но чтобы сайт функционировал нормально, страницу нужно указать

Если товар и его цена известны заранее, то поля targets и
sum можно заполнять автоматически и запретить изменние.

В форме могут быть дополнительные поля. Они описаны в

документации к форме.

Receiving payments using the API for Apps

Integration using the API for Apps lets you control the payment process within the app, get the payment status from the Yandex.Money server, and store user data for future payments. You can use this scenario to receive payments in two ways: from a Yandex.Money Wallet or from an arbitrary bank card.

The integration process depends on the payment method.

In any case, you first need to register the app in a Yandex.Money Wallet (you can create a Wallet just for registration).

Payments from the Yandex.Money wallet

To make a payment this way, the user must log in on the Yandex.Money site. The user can pay from the Wallet or using bank cards that are linked to it. To complete the payment, the app must:

  1. Complete authorization on the Yandex.Money server and get an access_token.

  2. Initialize a payment using the request-payment method.

  3. Process the payment using the process-payment method and process the checkOrder and paymentAviso notifications if the store has Yandex.Checkout activated using the HTTP method.

Payments from bank cards

For this type of payment, the user doesn’t need to register on the Yandex.Money site. The user can pay with any bank card. To complete the payment, the app must:

  1. Get the app instance ID.

  2. Initialize a payment using the request-external-payment method.

  3. Use the process-external-payment method to process the payment, and process the checkOrder and paymentAviso notifications if the store has Yandex.Checkout activated via the HTTP method.

The process of paying with a bank card looks the same as when paying through a payment form (see above).

Note.

The payment parameters in the request-payment and request-external-payment methods generally match the parameters in payment forms. Exceptions: You don’t need to pass shopId and paymentType, but you must pass scid in pattern_id. The other parameters are passed the same way as for integration with a payment form.

Note.

If you have already activated Yandex.Checkout, you don’t need to contact your manager and fill out additional paperwork. You can use the API for Apps for integration in individual cases, as described in the introduction.

SDK

You can use the libraries for programmatic implementation of the API for Apps:

All the branches have links to documentation.

Информация о платеже

Чтобы получатель узнал о платеже, система Яндекс Деньги отправляет данные о нём. Если Вы не делали настройки
кошелька, то данные приходят на почту, которая привязана к кошельку. Вот самые важные данные:

amount — сумма, которая пришла на кошелёк получателя

withdraw_amount — сумма, списанная с кошелька плательшика

datetime — время платежа

sender — кошелёк плательщика

label — значение поля label на странице
оплаты

codepro — содержит true, если использован
код протекции

unaccepted — содержит true, если перевод
не завершён из за того, что кошелёк переполнен или не введён код протекции.

Полное описание данных есть в документации в разделе

Уведомления.

Нужно будет подтвердить доступ, после чего Вы сможете указать URL, на который будут приходить данные
платежа. Нужно создать PHP скрипт, который будет принимать данные и производить какие-то действия
в соответствии с этими данными.

Для защиты от мошенников есть параметр sha1_hash. Он приходит с остальными
данными. О его использовании рассказано в документации в разделе «Уведомления». Это достаточно сложно, но
гарантирует, что платёж действительно произведён.

Рейтинг автора
5
Материал подготовил
Максим Иванов
Наш эксперт
Написано статей
129
Ссылка на основную публикацию
Похожие публикации