Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $amount = (float)$this->ipnVariables->get('mc_gross');
- $minimum = (float)Flux::config('MinDonationAmount');
- if ($amount >= $minimum) {
- $trustTable = Flux::config('FluxTables.DonationTrustTable');
- $holdHours = +(int)Flux::config('HoldUntrustedAccount');
- if ($holdHours) {
- $sql = "SELECT account_id, email FROM {$servGroup->loginDatabase}.$trustTable WHERE account_id = ? AND email = ? LIMIT 1";
- $sth = $servGroup->connection->getStatement($sql);
- $res = $sth->execute(array($accountID, $payerEmail));
- if ($res && $sth->fetch()->account_id) {
- $this->logPayPal('Account ID and e-mail are trusted.');
- $trusted = true;
- }
- else {
- $trusted = false;
- }
- }
- $rate = Flux::config('CreditExchangeRate');
- $credits = floor($amount / $rate);
- if ($trusted) {
- $sql = "SELECT * FROM {$servGroup->loginDatabase}.{$this->creditsTable} WHERE account_id = ?";
- $sth = $servGroup->connection->getStatement($sql);
- $sth->execute(array($accountID));
- $acc = $sth->fetch();
- $this->logPayPal('Updating account credit balance from %s to %s', (int)$acc->balance, $acc->balance + $credits);
- $res = $servGroup->loginServer->depositCredits($accountID, $credits, $amount);
- if ($res) {
- $this->logPayPal('Deposited credits.');
- }
- else {
- $this->logPayPal('Failed to deposit credits.');
- }
- }
- else {
- $this->logPayPal('Account/e-mail is not trusted, holding donation credits for %d hours.', $holdHours);
- }
- }
- else {
- $this->logPayPal('User has donated less than the configured minimum, not exchanging credits.');
- }
Add Comment
Please, Sign In to add comment