ораор - PHP Online

Form of PHP Sandbox

Enter Your PHP code here for testing/debugging in the Online PHP Sandbox. As in the usual PHP files, you can also add HTML, but do not forget to add the tag <?php in the places where the PHP script should be executed.



Your result can be seen below.

Result of php executing





Full code of ораор.php

  1. <?php
  2.  
  3. $b64url = function ($string) {
  4.     return rtrim(strtr(base64_encode($string), '+/', '-_'), '=');
  5. };
  6.  
  7. $prepare_payload = function ($path, $data, $method) {
  8.     return [
  9.         'PATH' => $path,
  10.         strtoupper($method) => array_map('strval', $data)
  11.     ];
  12. };
  13.  
  14. $apiSecret = 'hVwtyN33yoNW-oWV349QQx-kms.FqLCs';
  15. $path = '/billingapi/kinghills/sgate/callback';
  16. $data = [
  17.     "amount" => "100.0000",
  18.     "currency" => "GBP",
  19.     "custom_data" => "",
  20.     "customer_id" => "",
  21.     "fee_from_merchant" => "2.5000",
  22.     "masked_pan" => "",
  23.     "merchant_id" => "129",
  24.     "order" => "116803780218342408",
  25.     "product_id" => "306",
  26.     "requested_amount" => "100.0000",
  27.     "status" => "done",
  28.     "webhook_id" => "3443384",
  29.     "webhook_type" => "withdrawal",
  30.     "withdrawal_request_id" => "145889"
  31. ];
  32.  
  33. $method = 'POST'; // Измените на 'GET', если нужно
  34. $payload = $prepare_payload($path, $data, $method);
  35. ksort($payload[$method]);
  36.  
  37. $head = ['alg' => 'HS256'];
  38. $headJson = json_encode($head, JSON_UNESCAPED_SLASHES);
  39. $payloadJson = json_encode($payload, JSON_UNESCAPED_SLASHES);
  40.  
  41. $trueSign = $b64url(hash_hmac('sha256', $b64url($headJson) . '.' . $b64url($payloadJson), $apiSecret, true));
  42. echo $trueSign;
  43. ?>
File Description
  • ораор
  • PHP Code
  • 10 Apr-2024
  • 1.2 Kb
You can Share it: