-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathalreadycharge.php
66 lines (44 loc) · 1.64 KB
/
alreadycharge.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
<?php
include_once "config.php";
include_once "include/header.php";
$secretkey = mysql_query("select * from stripecredentials where id ='1'");
$sresult = mysql_fetch_array($secretkey);
try{
$stripeClassesDir = __DIR__ . '/Stripe/lib/';
$stripeUtilDir = $stripeClassesDir . 'Util/';
$stripeErrorDir = $stripeClassesDir . 'Error/';
set_include_path($stripeClassesDir . PATH_SEPARATOR . $stripeUtilDir . PATH_SEPARATOR . $stripeErrorDir);
function __autoload($class)
{
$parts = explode('\\', $class);
require end($parts) . '.php';
}
\Stripe\Stripe::setApiKey($sresult['secretkey']);
$data = mysql_query("select * from stripepayment where loggedinuser ='".$_SESSION['userid']."' && secretkey = '".$sresult['secretkey']."'");
$token = mysql_fetch_array($data);
$charge = \Stripe\Charge::create(array(
"amount" => $_POST['amount'],
"currency" => "usd",
"customer" => $token['customerid'], // obtained with Stripe.js
"description" => "Charge"
));
echo"<h3>Your Payment has been Completed.</h3>";
header('Refresh: 2; URL=http://'.$_SERVER['HTTP_HOST'].'/dashboard?success');
}
catch(Stripe_CardError $e){
$error = $e->getMessage();
echo $error;
}
catch(stripe_InvalidRequestError $e){
$error = $e->getMessage();
echo $error;
}
catch(stripe_AuthenticationError $e){
$error = $e->getMessage();
echo $error;
}
catch(Exception $e){
$error = $e->getMessage();
echo $error;
}
?>