-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconnect1.php
59 lines (36 loc) · 2.35 KB
/
connect1.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
<?php
include_once "include/config.php";
$secretkey = mysql_query("select * from stripecredentials where id ='1'");
$sresult = mysql_fetch_array($secretkey);
$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']);
$token = $_POST['token'];
$secretkey = mysql_query("select * from taskerdetails where userid ='" . $_POST['userid'] . "' && secretkey ='" . $sresult['secretkey'] . "'");
if (mysql_num_rows($secretkey) > 0) {
$details=mysql_fetch_array($secretkey);
$rp = \Stripe\Customer::retrieve($details['customerid']);
$rp->source=$token;
$rp->save();
//echo "update taskerdetails set `cardid`='" .$rp->sources->data['0']->id . "' WHERE userid='" . $_POST['userid'] . "'";
$update = mysql_query("update taskerdetails set `cardid`='" .$rp->sources->data['0']->id . "' WHERE userid='" . $_POST['userid'] . "'");
} else {
$name = mysql_query("select * from members where id ='" . $_POST['userid'] . "'");
$getdata=mysql_fetch_array($name);
$customer = \Stripe\Customer::create(array(
"description" => $getdata['email'],
"source" => $token // obtained with Stripe.js
));
$recipient= \Stripe\Recipient::create(array(
"name" => $getdata['fname'].' '. $getdata['lname'],
"type" => "individual"
));
$insert = mysql_query("insert into taskerdetails(`userid`,`recipientid`,`cardid`,`secretkey`,`customerid`) values('" . $_POST['userid'] . "','".$recipient->id."','".$customer->sources->data['0']->id."','".$sresult['secretkey']."','".$customer->id."')");
}
?>