Guest User

Untitled

a guest
Sep 12th, 2018
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.46 KB | None | 0 0
  1. <?php
  2. //Variables
  3. $user = stripslashes(ucwords(strtolower(trim($_POST['user']))));  //Confusing? Well, this is used to get the value of the inputbox in your paypal.html, since I won't be making one right now, I suggest you use the Gesior one since it will work just fine, thought I suggest tweaks since this includes several payment options.
  4. $payment_status = $_POST['payment_status'];
  5. $payment_amount = $_POST['mc_gross'];
  6. $mc_currency = $_POST['mc_currency'];
  7. $txn_id = $_POST['txn_id'];
  8. $receiver_email = $_POST['receiver_email'];
  9. $payer_email = $_POST['payer_email'];
  10.  
  11. //Database Connection
  12. $db_user = 'your_database_user';
  13. $db_password = 'your_password';
  14. $db = 'database_name';
  15. $database = new mysqli('localhost', $db_user, $db_password, $db);
  16. $receiver = 'Your@email.here');
  17. $currency = 'EUR';
  18. $log_file = 'paypal.log';
  19. $log_option = 0; //0 = It will write logs to the log file stated above(default is paypal.log), 1 = It'll write to the database
  20.  
  21. //Prices
  22. $points = array(10.00 => 40, 20.00 => 100)//10€ = 40 Points etc.
  23.  
  24. //The Code:
  25. if(gethostbyaddr($_SERVER['REMOTE_ADDR']) != 'notify.paypal.com'){ //Obviously so "hackers" can't try and cheat their way through the system
  26.     die('Un-authorized Access');
  27. }
  28. elseif ($database->connect_error) { //This will be displayed if it cannot connect to the database.
  29.     die('Connect Error (' . $mysqli->connect_errno . ') '. $mysqli->connect_error);
  30. }
  31.  
  32. if($payment_status == 'Completed' && $receiver_email == $receiver && isset($prices[$payment_amount]) && $mc_currency == $currency){
  33.     $account_id = $database->query('SELECT id, premium_points FROM accounts WHERE name = '.$user.'');
  34.     $database->query('UPDATE accounts SET premium_points = premium_points + '.$prices[$payment_amount].' WHERE id = '.$account_id[0];
  35.     if($log_option == 0){
  36.         $log_file_open = fopen($log_file, 'a');
  37.         fwrite($log_file_open, 'Purchase made at: '.date(DATE_RFC822).'\nUsername: '.$user.'\nAmount: '.$payment_amount.' '.$mc_currency.'\nPurchase ID: '.$txn_id.'\nBuyer Email: '.$payer_email.'\n');
  38.     }
  39.     elseif($log_option == 1){  
  40.         $database->query('INSERT INTO paypal_logs(id, account_id, amount, txn_id, time) VALUES(NULL, '.$account_id[0].', '.$payment_amount.', '.$txn_id.', CURRENT_TIMESTAMP)');
  41.     }  
  42. }
  43. elseif($payment_status == 'Reversed' && $receiver_email == $receiver){ //If some fuck tries to reverse the payment to scam you out of your money.
  44.     $database->query('DELETE FROM accounts WHERE id = '.$account_id[0]);
  45. }
  46.  
  47.  
  48.  
  49. $database->close();
  50. ?>
Add Comment
Please, Sign In to add comment