Siemanko!
Mam taki problem, że nie mogę prawidłowo wygenerować podpisu dla mBanku. Mój kod:
//Generowanie podpisu
private $hmacAlgorithm = "sha256";
private $key = "23bb3bcd-34b5-4772-931f-*********";
private $apikey = "b7b82d86-7d7d-41ed-a2bc-**********";
public function calculateHmac($data = array()) {
$base = base64_encode(hash_hmac($this->hmacAlgorithm, json_encode($data), $this->key, true));
}
//Wysyłanie danych
$url = "https://api.sandbox.paynow.pl/v1/payments";
$ch = curl_init( $url );
$apikey = $this->input->post('api-key');
$signature = $this->input->post('signature');
$idempotency = $this->input->post('idempotency-key');
# Setup request to send json via POST.
$payload = '{"amount":45671,"description":"Some description","externalId":"234567898654","buyer":{"email":"aaa@bbb.pl","phone":{"prefix":"+48","number":123456789}},"orderItems":[{"name":"TV Dell","category":"RTV","quantity":2,"price":10000}]}';
curl_setopt( $ch, CURLOPT_POSTFIELDS, $payload );
$headers = array();
$headers[] = "Content-Type: application/json";
$headers[] = "Api-Key: $apikey";
$headers[] = "Signature: $signature";
$headers[] = "Idempotency-Key: $idempotency";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
# Send request.
$result = curl_exec($ch);
curl_close($ch);
Po wysłaniu danych zwracany jest komunikat:
{"statusCode":400,"errors":[{"errorType":"VERIFICATION_FAILED","message":"Requests signature verification failed"}]}