<?php

$apiKey = "";
$secret = "";


$ch = curl_init("https://pikassa.io/merchant-api/api/v2/invoices");

$payload = json_encode(array(
    "externalId" => uniqid(),
    "amount" => 105.05,
    "currency" => "RUB",
    "description" => "Оплата заказа",
    "customerPhone" => "+74994550185",
    "customerEmail" => "support@pikassa.io",
    "customData" => array("key1" => "value1", "key2" => 5),
    "successUrl" => "https://mysite.com/successUrl",
    "failUrl" => "https://mysite.com/failUrl",
    "deliveryMethod" => "URL",
    "expirationDate" => "2021-03-14 11:08:24.090915+03:00",
    "ofdData" => null,
    "preAuth" => false
), JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES);
var_dump($payload);

$sign = base64_encode(md5($payload . $secret, true));

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
    "Content-Type:application/json",
    "X-Api-Key:" . $apiKey,
    "X-Sign:" . $sign
));
$res = curl_exec($ch);
var_dump($res);

if (curl_errno($ch)) {
    var_dump(curl_error($ch));
}

curl_close($ch);
?>