-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdonate.php
494 lines (409 loc) · 10.6 KB
/
donate.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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
<?php
// Stripe library
require 'stripe/Stripe.php';
$params = array(
"testmode" => "on",
"private_live_key" => "sk_live_UUCOI2p5f6ye9oqmIPKgohSW",
"public_live_key" => "pk_live_NM71jfG5jXk2ChKV4PnBW6Uw",
"private_test_key" => "sk_test_hpudM7C5huwzSjz8Tp9R3Xjm",
"public_test_key" => "pk_test_7vp1WEu0o1IOyLilC0WhkVXs"
);
if ($params['testmode'] == "on") {
Stripe::setApiKey($params['private_test_key']);
$pubkey = $params['public_test_key'];
} else {
Stripe::setApiKey($params['private_live_key']);
$pubkey = $params['public_live_key'];
}
if(isset($_POST['stripeToken']))
{
$name = $_POST['name'];
$donate=$_POST['donate'];
$amount_cents =($donate*100); // Chargeble amount
$invoiceid = "1498996148"; // Invoice ID
$description = "Invoice #" . $invoiceid . " - " . $invoiceid;
try {
$charge = Stripe_Charge::create(array(
"amount" => $amount_cents,
"currency" => "usd",
"source" => $_POST['stripeToken'],
"description" => $description)
);
if ($charge->card->address_zip_check == "fail") {
throw new Exception("zip_check_invalid");
} else if ($charge->card->address_line1_check == "fail") {
throw new Exception("address_check_invalid");
} else if ($charge->card->cvc_check == "fail") {
throw new Exception("cvc_check_invalid");
}
// Payment has succeeded, no exceptions were thrown or otherwise caught
$result = "success";
} catch(Stripe_CardError $e) {
$error = $e->getMessage();
$result = "declined";
} catch (Stripe_InvalidRequestError $e) {
$result = "declined";
} catch (Stripe_AuthenticationError $e) {
$result = "declined";
} catch (Stripe_ApiConnectionError $e) {
$result = "declined";
} catch (Stripe_Error $e) {
$result = "declined";
} catch (Exception $e) {
if ($e->getMessage() == "zip_check_invalid") {
$result = "declined";
} else if ($e->getMessage() == "address_check_invalid") {
$result = "declined";
} else if ($e->getMessage() == "cvc_check_invalid") {
$result = "declined";
} else {
$result = "declined";
}
}
echo "<BR>Stripe Payment Status : ".$result;
echo "<BR>Stripe Response : Payment ".$result;
echo "<br>";
echo "Transaction Id:".$charge['id'];
echo "<br>";
echo "Donator Name:".$name;
echo "<br>";
echo "Your Donation Amount:$".$charge['amount']/100;
echo "<br>";
echo "Thanks for Your donation";
exit;
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<base href="/corona/">
<meta charset="UTF-8">
<title>Corona Virus Relif Fund | Help people affested by corona</title>
</head>
<?php include "siteheader.php" ?>
<body>
<link href="css/style.css" type="text/css" rel="stylesheet" />
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="We want to help for affected people in corona. So please join me and donate for fund in corona affected people and children">
<meta name="keyword" content="Donate | Corona Virus Relif Fund | Donate for Corona virus affected people | Donate for Corona virus affected Children">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js"></script>
<!-- <h1 class="bt_title">Donate</h1> -->
<div class="container" style="margin-top: 5%;">
<form action="" method="POST" id="payment-form">
<span class="payment-errors"></span>
<div id="form-container">
<div id="card-front">
<div id="shadow"></div>
<div id="image-container">
<span id="amount">Donate:</span>
<input type="number" name="donate" placeholder="ex.$10">
<span id="card-image">
</span>
</div>
<!--- end card image container --->
<label for="card-number">
Card Number
</label>
<input type="text" id="card-number" placeholder="ex.1234 5678 9101 1112" length="16" data-stripe="number">
<div id="cardholder-container">
<label for="card-holder">Card Holder
</label>
<input type="text" id="card-holder" name="name" placeholder="e.g. John Doe" data-stripe="name" />
</div>
<!--- end card holder container --->
<div id="exp-container">
<label for="card-exp">
Expiration
</label>
<input id="card-month" type="text" placeholder="MM" length="2" data-stripe="exp_month">
<input id="card-year" type="text" placeholder="YY" length="2" data-stripe="exp_year" style="margin-top: -55px;">
</div>
<div id="cvc-container">
<label for="card-cvc"> CVV</label>
<input type="text" id="card-cvc" placeholder="XXX-X" min-length="3" max-length="4" data-stripe="cvc">
</div>
<!--- end CVC container --->
<!--- end exp container --->
</div>
<!--- end card back --->
</div>
<center>
<div class="row">
<div class="col-xs-12">
<button class="btn btn-danger" style="margin-top:50px;">Donate</button>
</div>
</div>
</center>
</form>
</div>
<style>
.cc-img {
margin: 0 auto;
}
</style>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
<script type="text/javascript" src="https://js.stripe.com/v2/"></script>
<!-- TO DO : Place below JS code in js file and include that JS file -->
<script type="text/javascript">
Stripe.setPublishableKey('<?php echo $params['public_test_key']; ?>');
$(function() {
var $form = $('#payment-form');
$form.submit(function(event) {
// Disable the submit button to prevent repeated clicks:
$form.find('.submit').prop('disabled', true);
// Request a token from Stripe:
Stripe.card.createToken($form, stripeResponseHandler);
// Prevent the form from being submitted:
return false;
});
});
function stripeResponseHandler(status, response) {
// Grab the form:
var $form = $('#payment-form');
if (response.error) { // Problem!
// Show the errors on the form:
$form.find('.payment-errors').text(response.error.message);
$form.find('.submit').prop('disabled', false); // Re-enable submission
} else { // Token was created!
// Get the token ID:
var token = response.id;
// Insert the token ID into the form so it gets submitted to the server:
$form.append($('<input type="hidden" name="stripeToken">').val(token));
// Submit the form:
$form.get(0).submit();
}
};
</script>
<?php
include "footer.php"
?>
</body>
</html>
<style type="text/css">
#amount {
font-size: 12px;
}
#amount strong {
font-size: 14px;
}
#card-back {
bottom:330px;
left:600px;
}
#card-btn {
background-color: rgba(251, 251, 251, 0.8);
color: #ffb242;
position: absolute;
bottom: -55px;
right: 0;
width: 150px;
border-radius: 8px;
height: 42px;
font-size: 12px;
font-family: lato, 'helvetica-light', 'sans-serif';
text-transform: uppercase;
letter-spacing: 1px;
font-weight: 400;
outline: none;
border: none;
cursor: pointer;
}
#card-btn:hover {
background-color: rgba(251, 251, 251, 1);
}
#card-cvc {
width: 60px;
margin-bottom: 0;
}
#card-front,
#card-back {
position: absolute;
background-color: #498ee4;
width: 450px;
height: 320px;
border-radius: 6px;
padding: 20px 30px 0;
box-sizing: border-box;
font-size: 10px;
letter-spacing: 1px;
font-weight: 300;
color: white;
}
#card-image {
float: right;
height: 100%;
}
#card-image i {
font-size: 40px;
}
#card-month {
width: 45% !important;
}
#card-number,
#card-holder {
width: 100%;
}
#card-stripe {
width: 100%;
height: 55px;
background-color: #3d5266;
position: absolute;
right: 0;
}
#card-success {
color: #00b349;
}
#card-token {
display: none;
}
#card-year {
width: 45%;
float: right;
}
#cardholder-container {
width: 60%;
display: inline-block;
}
#cvc-container {
position:relative;
width: 110px;
bottom:20px;
right:1px;
box-sizing: border-box;
}
#cvc-container label {
width: 100%;
margin-left:265px;
margin-top:20px;
}
#cvc-container input {
margin-left:300px;
margin-top:-20px;
}
#cvc-container p {
font-size: 6px;
text-transform: uppercase;
opacity: 0.6;
letter-spacing: .5px;
}
#form-container {
margin: auto;
width: 500px;
height: 290px;
position: relative;
}
#form-errors {
color: #eb0000;
}
#form-errors,
#card-success {
background-color: white;
width: 500px;
margin: 0 auto 10px;
height: 50px;
border-radius: 8px;
padding: 0 20px;
font-weight: 400;
box-sizing: border-box;
line-height: 46px;
letter-spacing: .5px;
text-transform: none;
}
#form-errors p,
#card-success p {
margin: 0 5px;
display: inline-block;
}
#exp-container {
margin-left: 10px;
width: 32%;
display: inline-block;
float: right;
}
.hidden {
display: none;
}
#image-container {
width: 100%;
position: relative;
height: 55px;
margin-bottom: 5px;
line-height: 55px;
}
#image-container img {
position: absolute;
right: 0;
top: 0;
}
input {
border: none;
outline: none;
background-color: #5a9def;
height: 30px;
line-height: 30px;
padding: 0 10px;
margin: 0 0 25px;
color: white;
font-size: 10px;
box-sizing: border-box;
border-radius: 4px;
font-family: lato, 'helvetica-light', 'sans-serif';
letter-spacing: .7px;
}
input::-webkit-input-placeholder {
color: #fff;
opacity: 0.7;
font-family: lato, 'helvetica-light', 'sans-serif' letter-spacing: 1px;
font-weight: 300;
letter-spacing: 1px;
font-size: 10px;
}
input:-moz-placeholder {
color: #fff;
opacity: 0.7;
font-family: lato, 'helvetica-light', 'sans-serif' letter-spacing: 1px;
font-weight: 300;
letter-spacing: 1px;
font-size: 10px;
}
input::-moz-placeholder {
color: #fff;
opacity: 0.7;
font-family: lato, 'helvetica-light', 'sans-serif' letter-spacing: 1px;
font-weight: 300;
letter-spacing: 1px;
font-size: 10px;
}
input:-ms-input-placeholder {
color: #fff;
opacity: 0.7;
font-family: lato, 'helvetica-light', 'sans-serif' letter-spacing: 1px;
font-weight: 300;
letter-spacing: 1px;
font-size: 10px;
}
input.invalid {
border: solid 2px #eb0000;
height: 34px;
}
label {
display: block;
margin: 0 auto 7px;
}
#shadow {
position: absolute;
right: 0;
width: 284px;
height: 214px;
top: 36px;
background-color: #000;
z-index: -1;
border-radius: 8px;
box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
-moz-box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
-webkit-box-shadow: 3px 3px 0 rgba(0, 0, 0, 0.1);
}
</style>