-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbankacc1.php
85 lines (63 loc) · 3.63 KB
/
bankacc1.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
<?php
include_once "include/config.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']);
$updates = mysql_query("select * from taskerdetails where userid ='".$_POST['userid']."' && secretkey='".$sresult['secretkey']."'") or die(mysql_error());
$rows=mysql_fetch_array($updates);
if(mysql_num_rows($updates)==0){
$token = \Stripe\Token::create(array(
"bank_account" => array('country' => 'US', 'routing_number' => $_POST["routing_number"], 'account_number' => $_POST["account_number"])
));
$name = mysql_query("select * from members where id ='" . $_POST['userid'] . "'");
$getdata=mysql_fetch_array($name);
/*sachin changes
$customer = \Stripe\Customer::create(array(
"description" => $getdata['email'],
"source" => $token->id // obtained with Stripe.js
));
*/
$recipient = \Stripe\Recipient::create(array(
"name" => $_POST['name'],
"type" => "individual",
"bank_account" => array('country' => 'US', 'routing_number' => $_POST["routing_number"], 'account_number' => $_POST["account_number"]),
));
$bank = $recipient->active_account;
$insert = mysql_query("insert into taskerdetails(`userid`,`recipientid`,`cardid`,`secretkey`,`customerid`,`bankid`) values('" . $_POST['userid'] . "','" . $recipient->id . "','" . $recipient->cards->data[0]['id'] . "','" . $sresult['secretkey'] . "','".$customer->id."','" . $bank->id . "')");
}else if(empty($rows['bankid'])){
$name = mysql_query("select * from members where id ='" . $_POST['userid'] . "'");
$getdata=mysql_fetch_array($name);
$recipient = \Stripe\Recipient::create(array(
"name" => $_POST['name'],
"type" => "individual",
"bank_account" => array('country' => 'US', 'routing_number' => $_POST["routing_number"], 'account_number' => $_POST["account_number"]),
));
$bank = $recipient ->active_account;
$insert = mysql_query("update taskerdetails set `recipientid`='".$recipient->id."' ,`bankid`='" . $bank->id . "' WHERE userid='".$_POST['userid']."'") or die(mysql_error());
}
echo 'success';
} catch (Stripe_CardError $e) {
$error = $e->getMessage();
echo '<span style="color:red;margin-top:10px;">' . $error . '</span>';
} catch (stripe_InvalidRequestError $e) {
$error = $e->getMessage();
echo '<span style="color:red;margin-top:10px;">' . $error . '</span>';
} catch (stripe_AuthenticationError $e) {
$error = $e->getMessage();
echo '<span style="color:red;margin-top:10px;">' . $error . '</span>';
} catch (Exception $e) {
$error = $e->getMessage();
echo '<span style="color:red;margin-top:10px;">' . $error . '</span>';
}
?>