/
intiateTansection.php
62 lines (44 loc) · 1.24 KB
/
intiateTansection.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
<?php
/*
* import checksum generation utility
* You can get this utility from https://developer.paytm.com/docs/checksum/
*/
require("PaytmChecksum.php");
$mid=$_POST["mid"];
$orderId=$_POST["ORDERID"];
$amount=$_POST["amount"];
$key=$_POST["mkey"];
$custId=$_POST["custId"];
$url=$_POST["url"];
$websiteName=$_POST["web"];
// $mid="zlsjBq52825503339453";
$paytmParams = array();
$paytmParams["body"] = array(
"requestType" => "Payment",
"mid" =>$mid,
"websiteName" =>$websiteName,
"orderId" =>$orderId,
"callbackurl" =>"https://merchant.com/callback",
"txnAmount" => array(
"value"=>$amount,
"currency" => "INR"
),
"userInfo" => array(
"custId" =>$custId
)
);
$checksum = PaytmChecksum::generateSignature(json_encode($paytmParams["body"],JSON_UNESCAPED_SLASHES),$key);
$paytmParams["head"] = array(
"signature" => $checksum
);
$post_data =json_encode($paytmParams,JSON_UNESCAPED_SLASHES);
/* for Staging */
$url = "$url/theia/api/v1/initiateTransaction?mid=$mid&orderId=$orderId";
$ch =curl_init($url);
curl_setopt($ch,CURLOPT_POST,1);
curl_setopt($ch,CURLOPT_POSTFIELDS,$post_data);
curl_setopt($ch,CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json"));
$resp=curl_exec($ch);
print($resp);
?>