<?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);
?>
url = "https://pikassa.io/merchant-api/api/v2/invoices"
secret = "код"
apiKey = "ключ"
params = {
"externalId": "3c5301df-d806-4fb0-9f96-f44d5d2d3827",
"amount": 105.05,
"currency": "RUB",
"description": "Оплата заказа",
"deliveryMethod": "EMAIL",
}
params2 = json.dumps(params) + secret
sign = hashlib.md5(params2.encode("utf-8")).hexdigest()
sign2 = base64.b64encode(sign.encode())
headers = {
"Content-Type": "application/json; charset=utf-8",
"X-Api-Key": apiKey,
"X-Sign": sign2.decode('utf-8')
}
data = json.dumps(params)
key = json.dumps(headers)
test = json.loads(key)
res = requests.post(url, headers=test, data=data)
print(res.text)
Пытаюсь отправлять запросы но возникает ошибка неправильный X-Sign, не понимаю что я не так делаю.
Документация к api
https://pikassa.io/docs/#6bad239f3a