Selly.gg API - ошибка POSTFIELDS CURL - PullRequest
0 голосов
/ 24 мая 2018

Я пытаюсь интегрировать API платежей Selly.gg с моей системой.

Документация для создания платежа находится здесь: https://developer.selly.gg/#create-a-payment

А вот мой код:

$ch = curl_init();

    $data = array(
        "title" => "My Payment",
        "gateway" => "PayPal",
        "email" => $_GET["email"],
        "value" => $price * $_GET["stock"],
        "currency" => "USD",
        "return_url" => "http://example.com",
        "webhook_url" => "http://example.com/callback.php?paid=true"
    );
    $data_curl = json_encode($data);

    curl_setopt($ch, CURLOPT_URL, "https://selly.gg/api/v2/pay");
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data_curl);
    curl_setopt($ch, CURLOPT_POST, 1);

    $headers = array();
    $headers[] = "Authorization: Basic ".base64_encode('EMAIL:APIKEY');
    $headers[] = "Content-Type: application/x-www-form-urlencoded";
    curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

    $result = curl_exec($ch);
    if (curl_errno($ch)) {
        //echo 'Error:' . curl_error($ch);
    }
    curl_close ($ch);

    echo $result;

Однако я получаю {"message":["Currency is not one we support","Currency can't be blank","Value is not a number","Value can't be blank","Email can't be blank","Gateway is not included in the list","Gateway can't be blank","Return url can't be blank","Webhook url can't be blank","Title is too short (minimum is 2 characters)"]}

УВЕДОМЛЕНИЕ : я даже пытался установить массив непосредственно в POSTFIELDS, но у него тот же результатмассива в кодировке JSON.

Любая помощь приветствуется.

1 Ответ

0 голосов
/ 24 мая 2018

Я решил, это была ошибка моих глаз.

Заголовок Content-Type: application/x-www-form-urlencoded должен быть Content-Type: application/json

Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...