我遇到问题了。
这是我的控制器
public function finish(Request $request)
{
$result = $request->input('data');
//$data = json_decode($result, true);
return $this->InvoiceBayar($result);
}
public function InvoiceBayar($result)
{
$data = json_decode($result, true);
$transaction = $data['transaction_status'];
$type = $data['payment_type'];
$order_id = $data['order_id'];
$fraud = $data['fraud_status'];
Fee::where('invoice',$order_id)
->update([
'status' => 'Paid',
]);
echo "Transaction order_id: " . $order_id ." successfully transfered using " . $type;
}
这是我的路线
Route::POST('/notification', 'SnapController@finish');
当付款网关向我发送参数时,我无法更新数据库。 但是当我使用POSTMAN时。我成功更新数据库
答案 0 :(得分:1)
您需要使用$request->all()
,因为它将包含所有付款网关数据。
public function finish(Request $request)
{
$result = $request->all();
return $this->InvoiceBayar($result);
}
答案 1 :(得分:0)
您也可以这样做
$update = Fee::where('invoice',$order_id)->first();
$update->status = 'Paid';
$update->save();
答案 2 :(得分:0)
您应该尝试以下操作:
public function InvoiceBayar($result)
{
$data = json_decode($result, true);
$transaction = $data->transaction_status;
$type = $data->payment_type;
$order_id = $data->order_id;
$fraud = $data->fraud_status;
Fee::where('invoice',$order_id)
->update([
'status' => 'Paid',
]);
echo "Transaction order_id: " . $order_id ." successfully transfered using " . $type;
}