Answer the question
In order to leave comments, you need to log in
Sending money to qiwi api?
You need to send money through qiwi api.
There is this help:
class Qiwi {
private $_phone;
private $_token;
private $_url;
function __construct($phone, $token) {
$this->_phone = $phone;
$this->_token = $token;
$this->_url = 'https://edge.qiwi.com/';
}
private function sendRequest($method, array $content = [], $post = false) {
$ch = curl_init();
if ($post) {
curl_setopt($ch, CURLOPT_URL, $this->_url . $method);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($content));
} else {
curl_setopt($ch, CURLOPT_URL, $this->_url . $method . '/?' . http_build_query($content));
}
curl_setopt($ch, CURLOPT_HTTPHEADER, [
'Accept: application/json',
'Content-Type: application/json',
'Authorization: Bearer ' . $this->_token,
'Host: edge.qiwi.com'
]);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
return json_decode($result, 1);
}
public function getAccount(Array $params = []) {
return $this->sendRequest('person-profile/v1/profile/current', $params);
}
public function getPaymentsHistory(Array $params = []) {
return $this->sendRequest('payment-history/v2/persons/' . $this->_phone . '/payments', $params);
}
public function getPaymentsStats(Array $params = []) {
return $this->sendRequest('payment-history/v2/persons/' . $this->_phone . '/payments/total', $params);
}
public function getTxn($txnId, Array $params = []) {
return $this->sendRequest('payment-history/v2/transactions/' . $txnId .'/', $params);
}
public function getCheck($txnId, Array $params = []) {
return $this->sendRequest('payment-history/v1/transactions/' . $txnId .'/cheque/file', $params);
}
public function getBalance() {
return $this->sendRequest('funding-sources/v2/persons/' . $this->_phone . '/accounts');
}
public function getTax($providerId) {
return $this->sendRequest('sinap/providers/'. $providerId .'/form');
}
public function sendMoneyToQiwi(Array $params = []) {
return $this->sendRequest('sinap/api/v2/terms/99/payments', $params, 1);
}
public function sendMoneyToProvider($providerId, Array $params = []) {
return $this->sendRequest('sinap/api/v2/terms/'. $providerId .'/payments', $params, 1);
}
public function sendMoneyToOther(Array $params = []) {
return $this->sendRequest('sinap/api/v2/terms/1717/payments', $params, 1);
}
}
if(isset($_POST['goPay'])) {
$qiwi = new Qiwi('+79649911177', 'токен нельзя палить');
$sendMoney = $qiwi->sendMoneyToProvider([
"id" => "21131343",
"sum" => [
"amount" => 8,
"currency" => "643"
],
"paymentMethod" => [
"type" => "Account",
"accountId" => "643"
],
"fields" => [
"account" => "+79114353887"
]
]);
var_dump($sendMoney);
}
Answer the question
In order to leave comments, you need to log in
Try it without help, like this:
$token = 'токен нельзя палить';
$paramGet = [
"id" => (string)(1000 * time()),
"sum" => [
"amount" => 8,
"currency" => "643"
],
"paymentMethod" => [
"type" => "Account",
"accountId" => "643"
],
"comment" => "Testing",
"fields" => [
"account" => "+79114353887"
]
];
$dataPostParam = json_encode($paramGet, JSON_UNESCAPED_UNICODE);
$ch = curl_init("https://edge.qiwi.com/sinap/api/v2/terms/__idPROVIVER__/payments");
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json',
'Accept: application/json',
'Authorization: Bearer ' . $token
)
);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, $dataPostParam);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$sResponse = curl_exec($ch);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question