S
S
Sergey Nozdrin2013-10-04 22:15:38
Yandex
Sergey Nozdrin, 2013-10-04 22:15:38

Can you help with accepting payments on the site?

Hello!
There is a simple task: to embed a form for accepting payments from Yandex.Money into the site page and sending a password for those who paid by email.
I made the form, indicated the mandatory requirement email there.
Created a page that accepts an http request from Yandex after receiving a payment.
Here is the test code:

<?php

$notification_type = $_POST['notification_type']; //p2p-incoming
$operation_id = $_POST['operation_id']; //1234567
$amount = $_POST['amount']; //300.00
$currency = $_POST['currency']; //643
$datetime = $_POST['datetime']; //2011-07-01T09:00:00.000+04:00
$sender = $_POST['sender']; //41001XXXXXXXX
$codepro = $_POST['codepro']; //false
$sha1_hash = $_POST['sha1_hash']; //090a8e7ebb6982a7ad76f4c0f0fa5665d741aafa

file_put_contents("file.txt", $notification_type, FILE_APPEND);
file_put_contents("file.txt", $operation_id, FILE_APPEND);
file_put_contents("file.txt", $amount, FILE_APPEND);
file_put_contents("file.txt", $datetime, FILE_APPEND);
file_put_contents("file.txt", $sender, FILE_APPEND);
?>

The question is: how to get information about the payer's mail by operation_id (as I understand it)?
Yandex writes: To get the rest of the payment parameters, including the "Payment comment", call operation-details and specify the operation_id parameter that you received in the notification.
Can you suggest how to modify this code to get the required email address?

Answer the question

In order to leave comments, you need to log in

3 answer(s)
X
xaker1, 2013-10-05
@xaker1

Library: github.com/melnikovdv/PHP-Yandex.Money-API-SDK

<?php
require_once(dirname(__FILE__) . '/../lib/YandexMoney.php');

$token = ...; // Предварительно полученный токен, можно брать из БД, можно прописать. 
              //Актуален в течении 3-х лет с момента получения

// ваш код

$ym = new YandexMoney(CLIENT_ID, './ym.log');
$resp = $ym->operationDetail($token, $operation_id);
if ($resp->isSuccess()) {
   // Данные получены успешно, можно забирать нужное.
   var_dump($resp);
} else {
   print "Error: " . $resp->getError();
   die();
}

But first you need to get a token, look - this is in the library examples. You write the token in $token, it will be relevant for 3 years.
Whether the email of the payer will be in the response - I can’t say, I didn’t have to work with the API.

S
Sergey Nozdrin, 2013-10-06
@light204

Well, yes, I did just that, but mail does not come from the test request either. It probably needs to be requested in some other way...

C
cbeta7910, 2014-02-03
@cbeta7910

The documentation says that contact data is transmitted via HTTPS:
It is recommended to use the HTTPS protocol to receive notifications. Please
note that receiving contact information about the sender in notifications
is only possible when using this protocol. When using the
HTTP protocol, contact information will not be transmitted in the notification.
Maybe that's just the point.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question