<?php
$secret = "тут секретный ключ";
$apiKey = "апи ключ";
$ch = curl_init("https://pikassa.io/merchant-api/api/v2/invoices");
$payload = json_encode(array(
"externalId" => uniqid(),
"amount" => 105.05,
"currency" => "RUB",
"description" => "Оплата заказа"
), 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);
if (curl_errno($ch)) {
var_dump(curl_error($ch));
}
curl_close($ch);
?>