Guest User

Untitled

a guest
Jun 21st, 2018
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.86 KB | None | 0 0
  1. $amount = (float)$this->ipnVariables->get('mc_gross');
  2. $minimum = (float)Flux::config('MinDonationAmount');
  3.  
  4. if ($amount >= $minimum) {
  5. $trustTable = Flux::config('FluxTables.DonationTrustTable');
  6. $holdHours = +(int)Flux::config('HoldUntrustedAccount');
  7.  
  8. if ($holdHours) {
  9. $sql = "SELECT account_id, email FROM {$servGroup->loginDatabase}.$trustTable WHERE account_id = ? AND email = ? LIMIT 1";
  10. $sth = $servGroup->connection->getStatement($sql);
  11. $res = $sth->execute(array($accountID, $payerEmail));
  12.  
  13. if ($res && $sth->fetch()->account_id) {
  14. $this->logPayPal('Account ID and e-mail are trusted.');
  15. $trusted = true;
  16. }
  17. else {
  18. $trusted = false;
  19. }
  20. }
  21.  
  22. $rate = Flux::config('CreditExchangeRate');
  23. $credits = floor($amount / $rate);
  24.  
  25. if ($trusted) {
  26. $sql = "SELECT * FROM {$servGroup->loginDatabase}.{$this->creditsTable} WHERE account_id = ?";
  27. $sth = $servGroup->connection->getStatement($sql);
  28. $sth->execute(array($accountID));
  29. $acc = $sth->fetch();
  30.  
  31. $this->logPayPal('Updating account credit balance from %s to %s', (int)$acc->balance, $acc->balance + $credits);
  32. $res = $servGroup->loginServer->depositCredits($accountID, $credits, $amount);
  33.  
  34. if ($res) {
  35. $this->logPayPal('Deposited credits.');
  36. }
  37. else {
  38. $this->logPayPal('Failed to deposit credits.');
  39. }
  40. }
  41. else {
  42. $this->logPayPal('Account/e-mail is not trusted, holding donation credits for %d hours.', $holdHours);
  43. }
  44. }
  45. else {
  46. $this->logPayPal('User has donated less than the configured minimum, not exchanging credits.');
  47. }
Add Comment
Please, Sign In to add comment