· 5 years ago · Nov 11, 2020, 09:12 AM
1<?php
2
3error_reporting(E_ALL);
4ini_set('display_errors', 1);
5
6function post_value($arg, $default = "") {
7 if (isset($_GET[$arg])) {
8 return $_GET[$arg];
9 } else {
10 return $default;
11 }
12
13}
14$cbk = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'] . 'response.php';
15$url = '';
16$generated_hash = "";
17
18if (!empty($_GET)) {
19
20 print_r($_GET);
21
22 // $datastring = $live . $order_id . $invoice . $total . $phone . $email . $vid . $curr . $p1 . $p2 . $p3 . $p4 . $cbk . $cst . $crl;
23
24 $live = post_value('live');
25 $oid = post_value('oid');
26 $inv = post_value('inv');
27 $ttl = post_value('ttl');
28 $tel = post_value('tel');
29 $eml = post_value('eml');
30 $vid = post_value('vid');
31 $curr = post_value('curr');
32 $p1 = post_value('p1');
33 $p2 = post_value('p2');
34 $p3 = post_value('p3');
35 $p4 = post_value('p4');
36 $cbk = post_value('cbk');
37 $cst = post_value('cst');
38 $crl = post_value('crl');
39
40 $datastring = $live . $oid . $inv . $ttl . $tel . $eml . $vid . $curr . $p1 . $p2 . $p3 . $p4 . $cbk . $cst . $crl;
41
42 $cbk = urlencode($cbk);
43
44 $generated_hash = hash_hmac('sha1', $datastring, post_value('hashkey'));
45 $url = 'https://payments.ipayafrica.com/v3/ke' . '?live=' . $live . '&oid=' . $oid . '&inv=' . $inv . '&ttl=' . $ttl . '&tel=' . $tel . '&eml=' . $eml . '&vid=' . $vid . '&p1=' . $p1 . '&p2=' . $p2 . '&p3=' . $p3 . '&p4=' . $p4 . '&crl=' . $crl . '&cbk=' . $cbk . '&cst=' . $cst . '&curr=' . $curr . '&hsh=' . $generated_hash . '';
46
47 header("Location: " . $url);
48 exit();
49}
50
51?>
52<!DOCTYPE html>
53<html lang="en">
54 <head>
55 <title> iPayAfrica - Web API - C2B Testing </title>
56 <meta name="description" content="ipayafrica - C2B Testing">
57 <meta name="author" content="www.rattelnetworks.com - ISP Radius, CRM solution">
58 <style></style>
59 </head>
60 <body>
61 <h2> iPayAfrica - REST API C2B Test</h2>
62 <p> See <a href="https://dev.ipayafrica.com/C2B.html"> https://dev.ipayafrica.com/C2B.html </a> for more information. </p><br>
63
64 <form role="form" name="form1" action="<?php echo $url ?>" method="get" >
65
66 <p> live : <input type="number" name="live" value="<?php echo post_value('live', 0) ?>" /> </p>
67
68 <p> Order ID: <input type="text" name="oid" value="<?php echo post_value('oid', 1001) ?>" /> </p>
69
70 <p> Invoice Number: <input type="text" name="inv" value="<?php echo post_value('inv', 145) ?>" /> </p>
71
72 <p> Total amount: <input type="number" name="ttl" value="<?php echo post_value('ttl', 1) ?>" /> </p>
73
74 <p> Telephone number: <input type="text" name="tel" value="<?php echo post_value('tel', "254726726993") ?>"/> </p>
75
76 <p> Email: <input type="text" name="eml" value="<?php echo post_value('eml', "demo@example.com") ?>" /> </p>
77
78 <p> Vendor ID: <input type="text" name="vid" value="<?php echo post_value('vid', "demo") ?>" /> </p>
79 <p> Hash Key: <input type="text" name="hashkey" value="<?php echo post_value('hashkey', "demoCHANGED") ?>" /> </p>
80
81 <p> Currency: <input type="text" name="curr" value="<?php echo post_value('curr', "KES") ?>" /> </p>
82
83 <p> Optional field: p1 <input type="text" name="p1" value="<?php echo post_value('p1', "1001") ?>" /> </p>
84
85 <p> Optional field: p2 <input type="text" name="p2" value="<?php echo post_value('p2', "145") ?>" /> </p>
86
87 <p> Optional field: p3 <input type="text" name="p3" value="<?php echo post_value('p3', "6") ?>" /> </p>
88
89 <p> Optional field: p4 <input type="text" name="p4" value="<?php echo post_value('p4') ?>" /> </p>
90
91 <p> Callback URL: <input type="text" name="cbk" value="<?php echo $cbk ?>" /> </p>
92
93 <p> Email notification falg: <input type="number" name="cst" value="<?php echo post_value('cst', 1) ?>" /> </p>
94
95 <p> cURL Flag: <input type="number" name="crl" value="<?php echo post_value('crl', 0) ?>"/> </p>
96
97 <?php if ($generated_hash) {
98 echo '<p style="background-color:#bfe;"> Computed iPay Hash value: <input type="text" name="hsh" value="' . $generated_hash . '" /> </p>';
99}
100?>
101
102 <button type="submit" name="submit_button" value="pay" > Submit </button>
103 <button type="reset" name="reset_button"> Reset </button>
104
105 </form>
106 <br><br><br><br>
107
108 </body>
109</html>