Reputation: 67
I have a doubt how to pass the Variable $ info_pago of a controller to be used in the checkout view and how to work on it. Controller:
$info_pago = [
'merchantId' => "508029",
'accountId' =>'512321',
'description' => 'Online Store',
'referenceCode' => $reference_code,
'amount' => Cart::total(),
'signature'=> md5($api_key."~"."508029"."~"."XXXX01"."~". Cart::total() )
];
return view('checkout', ['info_pago' => $info_pago ]);
I do not know how to use it for a form in the view, I thought something like this...
<input name="merchantId" type="hidden" value="{{ $info_pago->merchantId }}" >
<input name="accountId" type="hidden" value="{{ $info_pago->accountId }}" >
<input name="description" type="hidden" value="{{ $info_pago->description }}" >
<input name="referenceCode" type="hidden" value="{{ $info_pago->referenceCode}}" >
<input name="amount" type="hidden" value="{{ $info_pago->amount }}" >
I appreciate your suggestions.. TY..
Upvotes: 0
Views: 63
Reputation: 836
The parameter you pass is an array... $info_pago
Should you not ask the attributes like an array instead of an object?
So {{$info_pago['merchantId']}}
Instead of {{$info_pago->merchantId}}
Upvotes: 1
Reputation: 4040
you can use compact
$info_pago = [
'merchantId' => "508029",
'accountId' =>'512321',
'description' => 'Online Store',
'referenceCode' => $reference_code,
'amount' => Cart::total(),
'signature'=> md5($api_key."~"."508029"."~"."XXXX01"."~". Cart::total() )
];
return view('checkout', compact('info_pago'));
in view page
{{$info_page}}
Upvotes: 0
Reputation: 106
you should use compact instead. so your return would be like this:
return view('checkout', compact('info_pago'));
and use it on your view the same as what you are using.
Upvotes: 0