· 6 years ago · Dec 20, 2019, 01:40 PM
1<?php
2$secretKey = 'SKHTAyCJnf6a94Wz';
3$path = 'https://paygatedirect.com/v2/';
4$requestType = 'webpay'; // possible values: charge, refund, pay...
5$requestUrl = $path . $requestType;
6// array for parametres
7$bodyRequestArray = array(
8 'currency' => "USD",
9 'serviceId' => "736",
10 'orderId' => "103",
11 'amount' => "3500.45",
12 'description' => "DESCRIPTION"
13);
14
15$body = http_build_query($bodyRequestArray);
16$signature = getSignature($body, $secretKey);
17
18$ch = curl_init();
19curl_setopt($ch, CURLOPT_URL, $requestUrl);
20curl_setopt($ch, CURLOPT_POST, 1);
21curl_setopt($ch, CURLOPT_POSTFIELDS, $body); //Post Fields
22curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
23$headers = array(
24 'signature:'.$signature
25);
26curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
27$server_output = curl_exec($ch);
28curl_close ($ch);
29function getSignature($body, $secretKey){
30 // create signature
31 $hash = hash_hmac('sha256', $body, $secretKey, false);
32 return base64_encode($hash);
33}
34
35?>
36<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
37<html>
38 <head>
39 <title></title>
40 <meta name="" content="">
41 </head>
42 <body>
43 <?php
44 echo $server_output;
45 ?>
46 </body>
47</html>