Answer the question
In order to leave comments, you need to log in
Why doesn't QIWI API 400 Bad Request work?
I decided to issue an invoice via QIWI API. I am using Laravel. I did everything according to the example: I connected the SDK, everything works. I entered the correct key (when I enter the wrong key, another error occurs), but when I try to invoice, I get an error 400. Here are the logs:
[2020-01-10 19:14:49] local.ERROR: HTTP/1.1 400 Bad Request {"exception" :"[object] (Qiwi\\Api\\BillPaymentsException(code: 400): HTTP/1.1 400 Bad Request at /home/riimukrg/roulette.anonask.ru/vendor/qiwi/bill-payments-php-sdk/src /BillPayments.php:592)
This is the same line 592:
if (true === $this->internalCurl->error) {
throw new BillPaymentsException( //ВОТ ОНА
clone $this->internalCurl,
$this->internalCurl->error_message,
$this->internalCurl->error_code
);
}
$billPayments = new Qiwis('xxxxxxxxx');
$billId = '89393155728';
$fields = [
'amount' => 1.00,
'currency' => 'RUB',
'comment' => 'test',
'expirationDateTime' => '2018-03-02T08:44:07+03:00',
'email' => '[email protected]',
'account' => 'client4563',
];
$billPayments->createBill($billId, $fields);
Answer the question
In order to leave comments, you need to log in
Friend, I also tried to create a link for payment here, in general, I did everything manually
$SECRET_KEY = "твой секретный код";
$ch = curl_init();
$billid = "какой-нибудь уникальный айди";
$timexpr = date(DATE_ATOM,time()+120); // 120 это сколько секунд до закрытия
$data = array(
'amount' => array(
"currency" => 'KZT',
"value" => '10'
),
"comment" => "Тестируем апи",
"expirationDateTime" => "$timexpr",
"customer" => array(
"phone" => "88003553535",
"email" => "[email protected]",
"account" => "kakoito"
)
);
$data = json_encode($data); // обязательно в джава массив перегнать надо
curl_setopt($ch,CURLOPT_URL,"https://api.qiwi.com/partner/bill/v1/bills/$billid");
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
curl_setopt($ch, CURLOPT_POSTFIELDS,$data);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_FOLLOWLOCATION,true);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,false);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,false);
curl_setopt($ch,CURLOPT_HTTPHEADER,array(
'content-type: application/json',
'accept: application/json',
"Authorization: Bearer $SECRET_KEY"
));
$result = curl_exec($ch);
if(curl_errno($ch)){
echo curl_error($ch);
}
curl_close($ch);
print_r($result);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question