duanguanya3052 2019-08-11 20:25
浏览 29
已采纳

如何修复php变量中的错误? 服务器出错500

I have a code that is responsible for add money to account. There are tariff plans on the page of the site, when you click pay, the user switches to paying the bill. The code is as follows:

   public function pay(Request $request)
    {
        $ticketID = $request->get('tickID');
        if($ticketID = 1){
            $sum = 32;
        }elseif($ticketID = 2){
            $sum = 64;
        }elseif($ticketID = 3){
            $sum = 320;
        }elseif($ticketID = 4){
            $sum = 640;
        }elseif($ticketID = 5){
            $sum = 1600;
        }elseif($ticketID = 6){
            $sum = 3840;
        }elseif($ticketID = 7){
            $sum = 6400;
        }elseif($ticketID = 8){
            $sum = 9600;
        }
        $u = $this->user->steamid64;
        $merchant_id = '423';
        $secret_word1 = '432';
        $sign = md5($merchant_id.':'.$sum.':'.$secret_word1.':'.$u);
        $url = 'https://www.free-kassa.ru/merchant/cash.php?m='.$merchant_id.'&oa='.$sum.'&o='.$u.'&s='.$sign.'&lang=ru&i=&em=';
        $returnValue = [
            'redirect' => $url
        ];
        return $returnValue;
    }

    function getIP() {

        if (isset($_SERVER['HTTP_X_REAL_IP'])) return $_SERVER['HTTP_X_REAL_IP'];

        return $_SERVER['REMOTE_ADDR'];

    }

    public function payaccept(Request $request)
    {
        $merchant_id = '534';
        $secret_word2 = '423423';


        if (!in_array(getIP(), array('144.76.93.115', '144.76.93.119', '78.47.60.198'))) die('hacking attempt!');

        $sign = md5($merchant_id.':'.$_REQUEST['AMOUNT'].':'.$merchant_secret_2.':'.$_REQUEST['MERCHANT_ORDER_ID']);

        if ($sign != $_REQUEST['SIGN']) die('wrong sign');
        $summ = $_REQUEST['AMOUNT'];
        $user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID']);
        if ($summ = 32) {
            $user->money += $summ;
        }elseif ($summ = 64) {
            $user->money += $summ;
        }elseif ($summ = 320) {
            $user->money += $summ;
        }elseif ($summ = 640) {
            $user->money += round($summ*1.03);
        }elseif ($summ = 1600) {
            $user->money += round($summ*1.05);
        }elseif ($summ = 3840) {
            $user->money += round($summ*1.1);
        }elseif ($summ = 6400) {
            $user->money += round($summ*1.15);
        }elseif ($summ = 9600) {
            $user->money += round($summ*2);
        }
        $user->save();


        die('YES');
    }

Function pay forms a link, amount and digital signature. Function payaccept the function processes the payment and must enter payment information into the database.

The problem is in line $user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID']); i know it with help var_dump().

This line produces a variable steamid64, but can't fint in a DB. How i can fix it?

  • 写回答

1条回答 默认 最新

  • douju1280 2019-08-11 20:31
    关注

    Well, given that you haven't put any error message or log.. I assume the error is this line:

    $user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID']);
    

    Here you are creating the query... but not executing it. To do so add ->first() at the end.

    $user = User::Where('steamid64',$_REQUEST['MERCHANT_ORDER_ID'])->first();
    

    Then you will be able to call methods on the $user object.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料