$requestType = 'POST'; // REST $url = 'some url'; // $parameters = array(); // $loginPass = $id . ':' . $password; // ID ( ) $headers = array( "Accept: text/json", "Content-Type: application/x-www-form-urlencoded; charset=utf-8" ); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($ch, CURLOPT_USERPWD, $loginPass); if ($requestType != 'GET') { curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $requestType); curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($parameters)); } $httpResponse = curl_exec($ch); if (!$httpResponse) { // , echo curl_error($ch).'('.curl_errno($ch).')'; return false; } $httpResponseAr = json_decode($httpResponse); return $httpResponseAr->response;
$requestType = 'PUT'; $url = 'https://w.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}'; // {prv_id} – , ID . // {bill_id} – , . $parameters = array( 'user' => 'tel:+79999999999', 'amount' => 0.1, 'ccy' => 'RUB', 'comment' => ' QIWI', 'pay_source' => 'qw', 'lifetime' => date('c', $timePlusHour), 'prv_name' => 'QIWI', );
$requestType = 'GET'; $url = 'https://w.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}'; // $parameters = array();
$url = 'https://w.qiwi.com/order/external/main.action?shop={prv_id }&transaction={bill_id}'; $url .= '&successUrl=' . $successUrl; $url .= '&failUrl=' . $failUrl; // {prv_id} {bill_id} . // $successUrl $failUrl .
$requestType = 'PATCH'; $url = 'https://w.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}'; // $parameters = array( 'status' => 'rejected' );
$requestType = 'PUT'; $url = 'https://w.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}/refund/{refund_id}'; // , {refund_id} $parameters = array( 'amount' => $amount );
$requestType = 'GET'; $url = 'https://w.qiwi.com/api/v2/prv/{prv_id}/bills/{bill_id}/refund/{refund_id}'; // , {refund_id} $parameters = array();
Source: https://habr.com/ru/post/198668/
All Articles