Advertisement
Guest User

Untitled

a guest
Aug 29th, 2016
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.68 KB | None | 0 0
  1. public function payment() {
  2.  
  3.         if($this->request->post['pay_balance']) {
  4.  
  5.             $server = "http://www.free-kassa.ru/merchant/cash.php";
  6.             $id = "35915";
  7.             $password1 = "0hi1kyb9";
  8.  
  9.             if($newPaymentID = Builder::table("payments")->create(['user_id' => $this->session->data['user_id'], 'payment_sum' => $this->request->post['sum'], 'payment_time' => 'NOW()'])){
  10.                 $signature = md5("$id:".$this->request->post['sum'].":$password1:$newPaymentID");
  11.                 $url = $server;
  12.                 /* Параметры: */
  13.                 $url .= "?m=$id";
  14.                 $url .= "&oa=".$this->request->post['sum'];
  15.                 $url .= "&o=$newPaymentID";
  16.                 $url .= "&s=$signature";
  17.                 $url .= "&i=125";
  18.  
  19.                 redirect($url);
  20.             }
  21.         }
  22.  
  23.         return view("payment", $data);
  24.     }
  25.  
  26.     public function handler() {
  27.  
  28.         model("User");
  29.  
  30.         if($this->request->server['REQUEST_METHOD'] == 'GET') {
  31.             $ammount = $this->request->get['AMOUNT'];
  32.             $invid = $this->request->get['MERCHANT_ORDER_ID'];
  33.             $signature = $this->request->get['SIGN'];
  34.            
  35.             $password2 = "16c7hkt9";
  36.            
  37.             if(!Builder::table("payments")->where('payment_id', $invid)->first()) {
  38.                 $errorPOST = "Invalid invoice!";
  39.             }
  40.             elseif(strtoupper($signature) != strtoupper(md5("35915:$ammount:$password2:$invid"))) {
  41.                 $errorPOST = "Invalid signature!";
  42.             }
  43.  
  44.             if(!$errorPOST) {
  45.  
  46.                 $payment = Builder::table("payments")->where("payment_id", $invid)->first();
  47.                 Builder::table("payments")->where("payment_id", $invid)->set(['payment_status' => 1])->update();
  48.  
  49.                 $this->UserModel->plusBalance($payment['payment_sum'], $payment['user_id']);
  50.  
  51.                 exit("YES");
  52.             } else {
  53.                 exit("Error: $errorPOST");
  54.             }
  55.         } else {
  56.             exit("Error: Invalid request!");
  57.         }
  58.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement