Home » Php » Selly.gg API – CURL POSTFIELDS error

Selly.gg API – CURL POSTFIELDS error

Posted by: admin June 30, 2018 Leave a comment


I am trying to integrate the Selly.gg payments API with my system.

The documentation to create a payment is here: https://developer.selly.gg/#create-a-payment

And here is my code:

$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;

However I get {"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)"]}

NOTICE: I even tried to set the array directly in the POSTFIELDS but it have the same result of the JSON-encoded array.

Any help would be appreciated.