Facebook
From Mungo Ostrich, 6 Years ago, written in Plain Text.
Embed
Download Paste or View Raw
Hits: 274
  1.  public function sendpay(Request $request)
  2.     {
  3.         if (!$this->connect()) {
  4.             return redirect('/404/Błąd poczas pingowania serwera!');
  5.         }
  6.         if (!isset($_POST['name'])) {
  7.             return redirect('/shop');
  8.         }
  9.         if ($_POST['name'] == "") {
  10.             return redirect('/shop');
  11.         }
  12.         $usluga = $request->route('usluga');
  13.         $a = 1;
  14.         if (isset($_POST['points'])) {
  15.             $a = $_POST['points'];
  16.         }
  17.         $nick = $_POST['name'];
  18.         $db = DB::table('shop_services')->where('id', $usluga)->get()->first();
  19.         if ($db == null) {
  20.             return redirect("/404/Błąd nie ma takiej uslugi!");
  21.         }
  22.  
  23.         $shop = shop_settings::where('id', 1)->first();
  24.  
  25.         $shopid = $shop->shopid;
  26.         $hash = $shop->signature;
  27.         $amount = $db->pay*$a;
  28.         $signature = md5($shopid .$hash . $amount)
  29.  
  30.         ?>
  31.  
  32.         <form id="pay_checkout" action="https://www.rushpay.pl/api/bankTransfer/" method="get">
  33.             <input type="hidden" name="shopid" value="<?= $shopid ?>">
  34.             <input type="hidden" name="signature" value="<?= $signature ?>">
  35.             <input type="hidden" name="amount" value="<?= $amount ?>">
  36.             <input type="hidden" name="control" value="<?= $nick ?>">
  37.             <input type="hidden" name="description" value="<?= $db->name .'x'.$a ?>">
  38.             <input type="hidden" name="return_urlc" value="<?= action('ShopController@checkpay', array($usluga, $nick, $a)) ?>">
  39.             <input type="hidden" name="return_url"
  40.                    value="<?= action('Error404Controller@index', "Dziekuje za zakup!") ?>">
  41.         </form>
  42.         <script>document.forms["pay_checkout"].submit();</script>
  43.         <?php
  44.         $this->rcon->disconnect();
  45.         $this->rcon = null;
  46.     }
  47.  
  48.     function checkpay(Request $request){
  49.         if (!isset($this->rcon)) {
  50.             $this->connect();
  51.         }
  52.         if ($_POST['status'] == null || !$_POST['status']) {
  53.             die;
  54.         }
  55.         if ($_POST['status' != 'ok']) {
  56.             die;
  57.         }
  58.         if ($_POST['userid'] == null || $_POST['userid'] != 22) {
  59.             die;
  60.         }
  61.         $id =  $request->route('usluga');
  62.         $db = DB::table('shop_services')->where('id', $id)->get()->first();
  63.         if ($db == null) {
  64.             die;
  65.         }
  66.         if ($_POST['amountPay'] == null || str_replace(",", ".", $db->pay) != $_POST['amountPay']) {
  67.             die;
  68.         }
  69.         $nick = $request->route('user');
  70.         $a = $request->route('amount');
  71.  
  72.         $this->executeCommands($db, $nick, 'przelew', $db->pay, $a);
  73.  
  74.     }