-
Notifications
You must be signed in to change notification settings - Fork 0
/
donation_form.php
215 lines (177 loc) · 8.88 KB
/
donation_form.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
<?php
include_once 'includes/header.php';
include "config/connection.php";
$MERCHANT_KEY = "your payumoney merchant key";
$SALT = "your payumoney salt";
// Merchant Key and Salt as provided by Payu.
$PAYU_BASE_URL = "https://sandboxsecure.payu.in"; // For Sandbox Mode
//$PAYU_BASE_URL = "https://secure.payu.in"; // For Production Mode
$action = '';
$posted = array();
if(!empty($_POST)) {
//print_r($_POST);
foreach($_POST as $key => $value) {
$posted[$key] = $value;
}
}
$strFileName = 'error_log.txt';
$formError = 0;
if(empty($posted['txnid'])) {
// Generate random transaction id
$txnid = substr(hash('sha256', mt_rand() . microtime()), 0, 20);
} else {
$txnid = $posted['txnid'];
}
$hash = '';
// Hash Sequence
$hashSequence = "key|txnid|amount|productinfo|firstname|email|udf1|udf2|udf3|udf4|udf5|udf6|udf7|udf8|udf9|udf10";
if(empty($posted['hash']) && sizeof($posted) > 0) {
if(
empty($posted['key'])
|| empty($posted['txnid'])
|| empty($posted['amount'])
|| empty($posted['firstname'])
|| empty($posted['email'])
|| empty($posted['phone'])
|| empty($posted['productinfo'])
|| empty($posted['surl'])
|| empty($posted['furl'])
|| empty($posted['service_provider'])
) {
$formError = 1;
} else {
//$posted['productinfo'] = json_encode(json_decode('[{"name":"tutionfee","description":"","value":"500","isRequired":"false"},{"name":"developmentfee","description":"monthly tution fee","value":"1500","isRequired":"false"}]'));
$hashVarsSeq = explode('|', $hashSequence);
$hash_string = '';
foreach($hashVarsSeq as $hash_var) {
$hash_string .= isset($posted[$hash_var]) ? $posted[$hash_var] : '';
$hash_string .= '|';
}
$hash_string .= $SALT;
$hash = strtolower(hash('sha512', $hash_string));
$action = $PAYU_BASE_URL . '/_payment';
}
} elseif(!empty($posted['hash'])) {
$hash = $posted['hash'];
$action = $PAYU_BASE_URL . '/_payment';
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags-->
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="Colorlib Templates">
<meta name="author" content="Colorlib">
<meta name="keywords" content="Colorlib Templates">
<!-- Title Page-->
<title>Donation form</title>
<!-- Icons font CSS-->
<link href="vendor/mdi-font/css/material-design-iconic-font.min.css" rel="stylesheet" media="all">
<link href="vendor/font-awesome-4.7/css/font-awesome.min.css" rel="stylesheet" media="all">
<!-- Font special for pages-->
<link href="https://fonts.googleapis.com/css?family=Poppins:100,100i,200,200i,300,300i,400,400i,500,500i,600,600i,700,700i,800,800i,900,900i" rel="stylesheet">
<!-- Vendor CSS-->
<link href="vendor/select2/select2.min.css" rel="stylesheet" media="all">
<link href="vendor/datepicker/daterangepicker.css" rel="stylesheet" media="all">
<!-- Main CSS-->
<link href="css/main.css" rel="stylesheet" media="all">
<script>
var hash = '<?php echo $hash ?>';
function submitPayuForm() {
if(hash == '') {
return;
}
var payuForm = document.forms.payuForm;
payuForm.submit();
}
</script>
</head>
<body onload="submitPayuForm()">
<div class="page-wrapper bg-gra-02 p-t-130 p-b-100 font-poppins">
<div class="wrapper wrapper--w680">
<div class="card card-4">
<div class="card-body">
<h2 class="title">Donation Form</h2>
<form id="payuForm" name="payuForm" class="quick-contact-form" action="<?php echo $action; ?>" method="POST">
<div class="input-group">
<label class="label">Full Name</label>
<input class="input--style-4" id="firstname" name="firstname" class="form-control" type="text" value="<?php echo (empty($posted['firstname'])) ? '' : $posted['firstname']; ?>" required="">
</div>
<div class="row row-space">
<div class="col-2">
<div class="input-group">
<label class="label">Email</label>
<input class="input--style-4" id="email" name="email" class="form-control" type="text" value="<?php echo (empty($posted['email'])) ? '' : $posted['email']; ?>" required="">
</div>
</div>
<div class="col-2">
<div class="input-group">
<label class="label">Phone Number</label>
<input class="input--style-4" id="phone" name="phone" class="form-control" type="text"value="<?php echo (empty($posted['phone'])) ? '' : $posted['phone']; ?>" required="" >
</div>
</div>
</div>
<div class="input-group">
<label class="label">Payment Mode</label>
<div class="rs-select2 js-select-simple select--no-search">
<select id="mode" name="mode" onchange='changeAction(this.value)'>
<option disabled="disabled" selected="selected">Choose option</option>
<option value="bank.php">RSA Banks</option>
<option value="<?php echo $action; ?>">PayuMoney</option>
<option value="crypto.php">cryptocurrency</option>
<option value="https://paypal.me/kairobrands?country.x=ZA&locale.x=en_US">PayPal</option>
</select>
<div class="select-dropdown"></div>
</div>
</div>
<div class="input-group">
<input id="ORDER_ID" name="ORDER_ID" value="<?php echo "OD".rand(10000,500000);?>" type="hidden"/>
<input id="TXN_AMOUNT" name="TXN_AMOUNT" value="" type="hidden" />
<input id="CHANNEL_ID" name="CHANNEL_ID" value="WEB" type="hidden"/>
<input id="INDUSTRY_TYPE_ID" name="INDUSTRY_TYPE_ID" value="Retail" type="hidden" />
<input id="CUST_ID" name="CUST_ID" value="CUST001" type="hidden"/>
<input type="hidden" name="key" value="<?php echo $MERCHANT_KEY ?>" />
<input type="hidden" name="hash" value="<?php echo $hash ?>"/>
<input type="hidden" name="txnid" value="<?php echo $txnid ?>" />
<div class="rs-select2 js-select-simple select--no-search">
<div class="input-group">
<label class="label">Amount</label>
<input class="input--style-4" type="number" name="amount" value="<?php echo (empty($posted['amount'])) ? '' : $posted['amount'] ?>">
</div>
</div>
<input name="productinfo" type="hidden" value="<?php echo $posted['productinfo']= $package_title; ?>"/>
<input name="surl" type="hidden" value="<?php echo $posted['surl']="https://dodonation.000webhostapp.com/payu/success.php";?>" size="64" />
<input name="furl" type="hidden" value="<?php echo $posted['furl']="https://dodonation.000webhostapp.com/payu/failure.php"; ?>" size="64" />
<input type="hidden" name="service_provider" value="payu_paisa" size="64" />
</div>
<div class="p-t-15">
<?php
// echo $hash;
if(!$hash) { ?>
<br>
<button class="btn btn--radius-2 btn--blue" name="submit" id="submit" type="submit">Donate</button>
<?php } ?>
</div>
<script>
function changeAction(val){
document.getElementById('payuForm').setAttribute('action', val);
}
</script>
</form>
</div>
</div>
</div>
</div>
<!-- Jquery JS-->
<script src="vendor/jquery/jquery.min.js"></script>
<!-- Vendor JS-->
<script src="vendor/select2/select2.min.js"></script>
<script src="vendor/datepicker/moment.min.js"></script>
<script src="vendor/datepicker/daterangepicker.js"></script>
<!-- Main JS-->
<script src="js/global.js"></script>
</body><!-- This templates was made by Colorlib (https://colorlib.com) -->
</html>
<!-- end document-->