A
A
alex_gamescripts2020-08-12 19:53:23
API
alex_gamescripts, 2020-08-12 19:53:23

How to issue an invoice in QIWI API?

Hello. When invoicing in the QIWI API, I encountered a problem, an error 400 pops up:

http.message.conversion.failed


The code I am using:
<?php


//АВТОРИЗАЦИЯ
$qiwi_secret = 'eyJ2ZXJzaW9uIjoiUDJQIiwiZGF0YSI6eyJwYXlpbl9tZXJjaGFudF9zaXRl********************=';

$billid = time() + 10 * 5;
$fields = [
  'amount' => 1.00,
  'currency' => 'RUB',
  'comment' => 'test',
  'expirationDateTime' => '2029-08-12T21:45:00+03:00'
];

$link='https://api.qiwi.com/partner/bill/v1/bills/'.$billid;
$curl=curl_init();

curl_setopt($curl,CURLOPT_RETURNTRANSFER,true);
curl_setopt($curl,CURLOPT_URL,$link);
curl_setopt($curl,CURLOPT_PUT,true);
curl_setopt($curl,CURLOPT_POSTFIELDS,http_build_query($fields));
curl_setopt($curl, CURLOPT_HTTPHEADER, [
            'Accept: application/json',
            'Content-Type: application/json',
            'Authorization: Bearer ' . $qiwi_secret
        ]);
        
$out=curl_exec($curl);
$code=curl_getinfo($curl,CURLINFO_HTTP_CODE); //код ответа сервера
curl_close($curl);

$response=json_decode($out,true);
$code_answer=json_decode($code,true);
print_r($code_answer);
echo '<br>';
print_r($response);
?>


Here is the response I get:
Array ( [serviceName] => invoicing-api
        [errorCode] => http.message.conversion.failed
        [description] => Bad request
        [userMessage] => Bad request
        [dateTime] => 2020-08-12T17:59:39.024+03:00
        [traceId] => 51ba0fa1e476552d )


Who knows how to help, write. thank you

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey Josephf, 2020-08-12
@DjozefonGang

The request is sent in Win1251 encoding, but should be in UTF8.
https://developer.qiwi.com/ru/qiwi-wallet-personal/ (invoice creation, invoice payment)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question