-
Notifications
You must be signed in to change notification settings - Fork 6
/
contribute_personal_account.php
73 lines (59 loc) · 2.08 KB
/
contribute_personal_account.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
<html>
<head>
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type" />
</head>
<body>
<pre>
<?php
require_once (dirname(__FILE__) . "/lib/common.inc");
$user_id = isset($_REQUEST["user_id"]) ? $_REQUEST["user_id"] : 0;
$amount = isset($_REQUEST["amount"])? $_REQUEST["amount"] : 1000;
$tag = isset($_REQUEST["tag"])? $_REQUEST["tag"] : "DefaultTag";
$registercard = isset($_REQUEST["registercard"]) ? ($_REQUEST["registercard"] == "selected" ? true : false) : false;
$PaymentCardID = isset($_REQUEST["PaymentCardID"])? $_REQUEST["PaymentCardID"] : "0";
/*
* we fetch the user with the user_id in the URL
* else we create the user
*/
if ($user_id == 0) {
/*
* POST request to create a user
*/
$body = json_encode(array("FirstName" => "John", "LastName" => "Doe", "Email" => "[email protected]", "IP" => "127.0.0.1", "CanRegisterMeanOfPayment" => "true"));
$user = request("users", "POST", $body);
} else {
/*
* GET to fetch the user
*/
$user = request("users/" . $user_id, "GET");
}
if (!isset($user) || !isset($user -> ID)) {
print("Error");
return;
}
/*
* POST request to create a contribution on a personal account
*/
print_r ($_SERVER["REQUEST_URI"] . "\n");
print_r (str_replace( "\\", "", dirname($_SERVER["REQUEST_URI"])) . "\n");
$body = json_encode(array("UserID" => $user -> ID,
"WalletID" => $user -> ID,
"Amount" => $amount,
"ClientFeeAmount" => "0",
"RegisterMeanOfPayment" => $registercard,
"Tag" => $tag,
"PaymentCardID" => $PaymentCardID,
"ReturnURL" => "http://" . $_SERVER["SERVER_NAME"] . ":" . $_SERVER["SERVER_PORT"] . str_replace( "\\", "", dirname($_SERVER["REQUEST_URI"])) . "/return.php")
);
$contribution = request("contributions", "POST", $body);
/*
* Redirect to url of payment
*/
if ($contribution != null) {
header("Location: " . $contribution -> PaymentURL);
exit();
}
?>
</pre>
</body>
</html>