-
Notifications
You must be signed in to change notification settings - Fork 6
/
create_transfer.php
75 lines (58 loc) · 1.89 KB
/
create_transfer.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
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
</head>
<body>
<pre>
<?php
require_once (dirname(__FILE__) . "/lib/common.inc");
$payer_id = isset($_REQUEST["payer_id"]) ? $_REQUEST["payer_id"] : 0;
$beneficiary_id = isset($_REQUEST["beneficiary_id"]) ? $_REQUEST["beneficiary_id"] : 0;
$wallet_beneficiary_id = isset($_REQUEST["wallet_beneficiary_id"]) ? $_REQUEST["wallet_beneficiary_id"] : 0;
$wallet_payer_id = isset($_REQUEST["wallet_payer_id"]) ? $_REQUEST["wallet_payer_id"] : 0;
$amount = isset($_REQUEST["amount"]) ? $_REQUEST["amount"] : 0;
$tag = isset($_REQUEST["tag"])? $_REQUEST["tag"] : "DefaultTag";
echo " :" . $beneficiary_id . " :" . $wallet_beneficiary_id;
if ($beneficiary_id == 0 && $wallet_beneficiary_id == 0) {
print("Error : not parameter beneficiary_id nor wallet_beneficiary_id in url");
return;
}
if ($amount == 0) {
print("Error : the amount must be specified in url");
return;
}
/*
* we fetch the payer with the payer_id in the URL
*/
if ($payer_id != 0) {
/*
* GET to fetch the user
*/
$payer = request("users/$payer_id", "GET");
if (!isset($payer) || !isset($payer -> ID)) {
print("Error");
return;
}
}
/*
* we fetch the user with the beneficiary_id in the URL
*/
if ($beneficiary_id != 0) {
/*
* GET to fetch the user
*/
$beneficiary = request("users/$beneficiary_id", "GET");
if (!isset($beneficiary) || !isset($beneficiary -> ID)) {
$beneficiary = request("wallets/$beneficiary_id", "GET");
if (!isset($beneficiary) || !isset($beneficiary -> ID)) {
print("Error");
return;
}
}
}
$body = json_encode(array("Tag" => "Custom data", "Tag" => $tag, "PayerID" => $payer -> ID, "BeneficiaryID" => $beneficiary -> ID, "BeneficiaryWalletID" => $wallet_beneficiary_id , "PayerWalletID" => $wallet_payer_id, "Amount" => $amount));
$transfer = request("transfers", "POST", $body);
?>
</pre>
</body>
</html>