窗体无法从Laravel中的数组获取变量

时间:2018-06-30 14:50:43

标签: laravel

我正在使用付款者API来接受付款,但集成API后发生错误。

m_shop is invalid or empty. Same thing is working on my other web 

我试图删除m_shop并更改商店ID,但都徒劳无功。我想我写错了。 代码:

public function gatewayRedirect(Request $request){

        $id = session('payment_log_id');
        $data['page_title'] = 'Deposit Processing';
        $trans = PaymentLog::find($id);
        $gateway = PaymentMethod::find($trans->payment_type);
        $basic = BasicSetting::first();
        $deposit_fund_route = route('deposit-fund');

        if ($gateway->id == 1) {

 $ipn = route('payeer-ipn');                                     
    $m_shop = '547754002';
$m_orderid = '1'; // invoice number in the merchant's invoicing system
$m_amount = number_format(100, 2, '.', ''); // invoice amount with two decimal places
$m_curr = 'USD'; // invoice currency
$m_desc = base64_encode('Test'); // invoice description encoded using a base64
$m_key = '123';
$arHash = array(
 $m_shop,
 $m_orderid,
 $m_amount,
 $m_curr,
 $m_desc,
 $m_key
 );

 $sign = strtoupper(hash('sha256', implode(':', $arHash)));

$data['send_pay_request'] = '<form action="https://payeer.com/merchant/" method="post" id="pament_form">                                     
<input type="hidden" name="m_shop" value="{{$m_shop}}">
<input type="hidden" name="m_orderid" value="{{$m_orderid}}">
<input type="hidden" name="m_amount" value="{{$m_amount}}">
<input type="hidden" name="m_curr" value="{{$m_curr}}">
<input type="hidden" name="m_desc" value="{{$m_desc}}">
<input type="hidden" name="m_sign" value="{{$sign}}">     
<input type="hidden" name="m_sign" value="{{$sign}}">

                                        </form>';

            return view('user.autoredirectgateway',$data);

1 个答案:

答案 0 :(得分:1)

在PHP中工作时,必须按如下所示连接变量

$data['send_pay_request'] = '<form action="https://payeer.com/merchant/" method="post" id="pament_form">                                     
<input type="hidden" name="m_shop" value="' . $m_shop . '">
<input type="hidden" name="m_orderid" value="' . $m_orderid . '">
<input type="hidden" name="m_amount" value="' . $m_amount . '">
<input type="hidden" name="m_curr" value="' . $m_curr . '">
<input type="hidden" name="m_desc" value="' . $m_desc . '">
<input type="hidden" name="m_sign" value="' . $sign . '">     
<input type="hidden" name="m_sign" value="' . $sign . '">

                                        </form>';