@GRO24

Как отправить QIWI API?

Всем привет. Никак не пойму в чем проблема.
Пытаюсь отправить с API QIWI перевод
В ответ получаю
array(1) { ["message"]=> string(107) "Json validation error List((obj.source,List(JsonValidationError(List(error.path.missing),WrappedArray()))))" }


Кто работал с QIWI? Подскажите, что не так делаю?

<?php 
class QiwiApi {
    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
        ]); 
        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/v1/persons/' . $this->_phone . '/payments/total', $params);
    }
    public function getBalance() {
        return $this->sendRequest('funding-sources/v1/accounts/current')['accounts'];
    }
    public function getTax($providerId) {
        return $this->sendRequest('sinap/providers/'. $providerId .'/form');
    }  
    public function sendMoneyToQiwi(Array $params = []) {
        return $this->sendRequest('sinap/terms/99/payments', $params, 1);
    }
    public function sendMoneyToProvider($providerId, Array $params = []) {
        return $this->sendRequest('sinap/terms/'. $providerId .'/payments', $params, 1);
    }
}

	$phone  = '';
	$token = '';

	$api = new QiwiApi($phone, $token);



$sendMoney = $api->sendMoneyToQiwi([
    "id" => (string)(1000 * time()),
    "sum" => [
        "amount" => 1,
        "currency" => "643"
    ],
    "paymentMethod" => [
        "type" => "Account",
        "accountId" => "643"
    ],
    "comment" => "Testing",
    "fields" => [
        "account" => "+79181111111"
    ]
]);


 ?>
  • Вопрос задан
  • 324 просмотра
Пригласить эксперта
Ответы на вопрос 1
@GRO24 Автор вопроса
Всем спасибо. Проблема была в sinap/terms/99/payments а нужно => sinap/api/v2/terms/99/payments
Ответ написан
Комментировать
Ваш ответ на вопрос

Войдите, чтобы написать ответ

Войти через центр авторизации
Похожие вопросы
19 апр. 2024, в 03:52
1000 руб./за проект
19 апр. 2024, в 03:01
1000 руб./за проект
18 апр. 2024, в 21:56
2000 руб./за проект