Файл: system/classes/Ya.php
Строк: 62
<?php
class Ya {
private $_token;
function __construct($token) {
$this->_token = $token;
}
function balance(){
$uri = 'https://money.yandex.ru/api/account-info';
$curl = curl_init();
$headers[] = 'Authorization: Bearer ' . $this->_token;
curl_setopt($curl, CURLOPT_URL, $uri);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_USERAGENT, 'ANDROID');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
$rbody = curl_exec($curl);
curl_close($curl);
$json = json_decode($rbody);
return $json->balance;
}
function send($to,$money,$message){
$uri = 'https://money.yandex.ru/api/request-payment';
$curl = curl_init();
$params = 'pattern_id=p2p&to='.$to.'&amount='.$money.'&message='.$message.'&comment='.$message;
$headers[] = 'Authorization: Bearer ' . $this->_token;
curl_setopt($curl, CURLOPT_URL, $uri);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_USERAGENT, 'ANDROID');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
$rbody = curl_exec($curl);
curl_close($curl);
$json = json_decode($rbody);
$uri2 = 'https://money.yandex.ru/api/process-payment';
$curl2 = curl_init();
$params2 = 'request_id='.$json->request_id;
$headers2[] = 'Authorization: Bearer ' . $this->_token;
curl_setopt($curl2, CURLOPT_URL, $uri2);
curl_setopt($curl2, CURLOPT_HTTPHEADER, $headers2);
curl_setopt($curl2, CURLOPT_USERAGENT, 'ANDROID');
curl_setopt($curl2, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl2, CURLOPT_POST, true);
curl_setopt($curl2, CURLOPT_POSTFIELDS, $params2);
$rbody2 = curl_exec($curl2);
curl_close($curl2);
$json2 = json_decode($rbody2);
if($json2->status == 'success'){
return 1;
}
else
{
return 0;
}
}
function history(){
$date = date('Y-m-d',time()-86400).'T08:53:03Z';
$uri = 'https://money.yandex.ru/api/operation-history';
$curl = curl_init();
$params = 'type=deposition&records=10&from='.$date;
$headers[] = 'Authorization: Bearer ' . $this->_token;
curl_setopt($curl, CURLOPT_URL, $uri);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
curl_setopt($curl, CURLOPT_USERAGENT, 'ANDROID');
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, $params);
$rbody = curl_exec($curl);
curl_close($curl);
return json_decode($rbody,true);
}
}