-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpayments.php
80 lines (69 loc) · 2.13 KB
/
payments.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
<?php
define("INCLUDED", true); //This is for returning a die message if INCLUDED is not defined on any of the template
$AJAX_PAGE = false;
//################ Required Resources ################
$REQUIRED_RESOURCES = array();
//################ Required Files ################
require_once("init.php");
//################ PAGE ACCESS ################
$cms->BannedAccess(true);
eval($cms->SetPageAccess(ACCESS_ALL));
//################ General Variables ################
$page_name[] = array("Payments");
//################ Page Functions ################
function ModifyDonationPoints($id, $amount)
{
global $DB, $ppd;
//If amount is less than 1 it means that the transaction is a reversal or a refund
if($amount < 1)
{
$times = 0;
}
else
{
$times = 1;
}
$amount = $amount * $ppd; //Amount of Dollars * Points per dollar specified by gateway
$query = new Query();
$query->Update("`account_mm_extend`")->Where("`id` = '%s'", $id)
->Columns(array("`donationpoints`"=>"`donationpoints` + '%s'", "`donated`"=>"`donated` + '%s'"), $amount, $times)->Build();
$DB->query($query, DBNAME);
return $DB->affected_rows;
}
if(empty($_POST) || count($_POST) == 0)
{
header('Location: points.php');
exit();
}
$ppd = 1;
switch($_GET['gateway'])
{
case "PayPal":
require_once(DOC_ROOT."/includes/PayPal.gateway.php");
$gateway = new PayPal();
$ppd = $cms->config['pointsperdollar_paypal'];
break;
case "AlertPay":
require_once(DOC_ROOT."/includes/AlertPay.gateway.php");
$gateway = new AlertPay();
$ppd = $cms->config['pointsperdollar_alertpay'];
break;
case "MoneyBookers":
require_once(DOC_ROOT."/includes/MoneyBookers.gateway.php");
$gateway = new MoneyBookers();
$ppd = $cms->config['pointsperdollar_moneybookers'];
break;
default:
//trigger_error("noob_gateway = ".$_GET['gateway'], E_USER_WARNING);
break;
}
$validation = $gateway->ValidateTransaction();
if($validation == "noob")
{
trigger_error("noob", E_USER_WARNING);
}
if($validation != false && is_array($validation))
{
ModifyDonationPoints($validation['id'], $validation['amount']);
}
?>