add api payment
This commit is contained in:
@@ -239,10 +239,16 @@ class ApiController extends Controller
|
||||
|
||||
event(new PaymentNotify('PAID',$resit->user_id,$payment->id));
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'resit' => $resit
|
||||
]);
|
||||
$success = true;
|
||||
|
||||
$result = $resit->toArray();
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'resit' => $resit
|
||||
// ]);
|
||||
|
||||
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
|
||||
|
||||
}else{
|
||||
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
|
||||
@@ -250,11 +256,16 @@ class ApiController extends Controller
|
||||
$resit->paid_at = null;
|
||||
$resit->save();
|
||||
|
||||
$result = $resit->toArray();
|
||||
|
||||
$success = false;
|
||||
|
||||
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id,''));
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'resit' => $resit
|
||||
]);
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'resit' => $resit
|
||||
// ]);
|
||||
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -328,7 +339,6 @@ class ApiController extends Controller
|
||||
|
||||
public function bidpayment(Request $request)
|
||||
{
|
||||
|
||||
$arraycollection_id = array();
|
||||
|
||||
$http = new HttpMethodsClient(
|
||||
@@ -353,6 +363,8 @@ class ApiController extends Controller
|
||||
$year = $current->format('y');
|
||||
|
||||
$total_bayaran = ($request->total)*100+100;
|
||||
// dump($request->total);
|
||||
// dd($total_bayaran);
|
||||
|
||||
$collection_id = $this->collection_id;
|
||||
$response = $bill->create(
|
||||
@@ -365,7 +377,7 @@ class ApiController extends Controller
|
||||
'Bayaran Bidaan',
|
||||
['redirect_url' => route('pay.bidpaymentStatus')]
|
||||
);
|
||||
// dd($response);
|
||||
// dd($response->toArray());
|
||||
$previous_siri = Resit::orderBy('id','desc')->first();
|
||||
if($previous_siri){
|
||||
$nosiri = $previous_siri->id + 1;
|
||||
@@ -380,6 +392,7 @@ class ApiController extends Controller
|
||||
$reference_no = 'LPKB' . $day . $month . $year . sprintf("%08d", $nosiri);
|
||||
// $response2 = $bill->get($billcode['id']);
|
||||
// dd($response2->toArray());
|
||||
|
||||
$resit = new Resit;
|
||||
$resit->user_id = $request->user_id;
|
||||
$resit->lelong_id = $request->lelong_id;
|
||||
@@ -387,7 +400,28 @@ class ApiController extends Controller
|
||||
$resit->billplz_id = $billcode['id'];
|
||||
$resit->resit_type = 2; //billplz resit for bid payment
|
||||
$resit->total_payment = $request->total;
|
||||
$resit->invoice_id = $request->invoice_id;
|
||||
$resit->invoice_no = $request->invoice_no;
|
||||
$resit->save();
|
||||
// dd($resit);
|
||||
|
||||
// $selectedSag = [];
|
||||
$selectedSag = $request->sag;
|
||||
// dd($selectedSag);
|
||||
foreach ($selectedSag as $index) {
|
||||
// dd($index['kodcaw']);
|
||||
$payment = new Payment;
|
||||
$payment->user_id = $request->user_id;
|
||||
$payment->lelong_id = $request->lelong_id;
|
||||
$payment->kodcaw = $index['kodcaw'];
|
||||
$payment->norujukan = $index['norujukan'];
|
||||
$payment->total_payment = $index['total_payment'];
|
||||
$payment->status_payment_opt = 2; //bayar secara online 2
|
||||
$payment->status = 0; //0-unpaid //1-fee //2-bid
|
||||
$payment->remark = '';
|
||||
$payment->resit_id = $resit->id;
|
||||
$payment->save();
|
||||
}
|
||||
|
||||
|
||||
// return redirect($billcode['url'] . '?auto_submit=true');
|
||||
@@ -397,148 +431,174 @@ class ApiController extends Controller
|
||||
], 201);
|
||||
// return view('pembayaran.result.berjaya',compact('arraybayaran'));
|
||||
}
|
||||
|
||||
public function bidcallback(Request $request){
|
||||
|
||||
public function bidcallback(Request $request)
|
||||
{
|
||||
// dd('hye callback');
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
|
||||
$bill = $billplz->bill();
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if (config('app.env') != 'production') {
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
|
||||
$bill = $billplz->bill();
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
|
||||
if ($data['billplz']['paid'] == 'true') {
|
||||
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
|
||||
$resit->status = 'PAID';
|
||||
$resit->paid_at = $data['billplz']['paid_at'];
|
||||
$resit->save();
|
||||
|
||||
$resitoriginal = Resit::where('user_id', $resit->user_id)
|
||||
->where('lelong_id', $resit->lelong_id)
|
||||
->where('resit_type', 2)
|
||||
->first();
|
||||
$payment = $resit->total_payment;
|
||||
$resitoriginal->total_payment = $resitoriginal->total_payment + $payment;
|
||||
$resitoriginal->save();
|
||||
->where('lelong_id', $resit->lelong_id)
|
||||
->where('resit_type', 2)
|
||||
->first();
|
||||
|
||||
$payment = new Payment;
|
||||
$payment->user_id = $resitoriginal->user_id;
|
||||
$payment->lelong_id = $resitoriginal->lelong_id;
|
||||
$payment->total_payment = $resit->total_payment;
|
||||
$payment->resit_id = $resitoriginal->id;
|
||||
$payment->status_payment_opt = 2; //bayar secara online 2
|
||||
$payment->status = 1; //fee rm10 - 1
|
||||
$payment->remark = 'BAYARAN ONLINE';
|
||||
$payment->save();
|
||||
// $resitoriginal->total_payment = $resitoriginal->total_payment + $resit->total_payment;
|
||||
// $resitoriginal->save();
|
||||
|
||||
event(new PaymentNotify('PAID',$resitoriginal->user_id,$payment->id));
|
||||
// $payment = new Payment;
|
||||
// $payment->user_id = $resitoriginal->user_id;
|
||||
// $payment->lelong_id = $resitoriginal->lelong_id;
|
||||
// $payment->total_payment = $resit->total_payment;
|
||||
// $payment->resit_id = $resitoriginal->id;
|
||||
// $payment->status_payment_opt = 2; //bayar secara online 2
|
||||
// $payment->status = 1; //fee rm10 - 1
|
||||
// $payment->remark = 'BAYARAN ONLINE';
|
||||
// $payment->save();
|
||||
|
||||
return response()->json([
|
||||
'success' => true,
|
||||
'resit' => $resitoriginal
|
||||
]);
|
||||
|
||||
}else{
|
||||
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
|
||||
$resit->status = 'UNSUCCESSFUL';
|
||||
$resit->paid_at = null;
|
||||
$resit->save();
|
||||
|
||||
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id,''));
|
||||
return response()->json([
|
||||
'success' => false,
|
||||
'resit' => $resit
|
||||
]);
|
||||
}
|
||||
}
|
||||
$payment = Payment::where('lelong_id', $resit->lelong_id)
|
||||
->where('user_id', $resit->user_id)
|
||||
->where('resit_id', $resit->id)
|
||||
->get();
|
||||
foreach ($payment as $index) {
|
||||
$index->status = 2; //0-unpaid //1-fee //2-bid
|
||||
$index->remark = "BERJAYA BAYARAN ONLINE";
|
||||
$index->update();
|
||||
}
|
||||
|
||||
public function bidresponse(Request $request){
|
||||
// dd('hye response');
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
|
||||
$bill = $billplz->bill();
|
||||
$req = $request->toArray();
|
||||
$response = $bill->get($req['billplz']['id']);
|
||||
$data = $response->toArray();
|
||||
// dd($data);
|
||||
if($data['paid'] == 'true'){
|
||||
$resit = Resit::where('billplz_id','=',$data['id'])->first();
|
||||
$resit->status = 'PAID';
|
||||
$resit->paid_at = $data['paid_at'];
|
||||
$resit->save();
|
||||
|
||||
$resitoriginal = Resit::where('user_id', $resit->user_id)
|
||||
->where('lelong_id', $resit->lelong_id)
|
||||
->where('resit_type', 2)
|
||||
->first();
|
||||
|
||||
$resitoriginal->total_payment = $resitoriginal->total_payment + $resit->total_payment;
|
||||
$resitoriginal->save();
|
||||
|
||||
$payment = new Payment;
|
||||
$payment->user_id = $resitoriginal->user_id;
|
||||
$payment->lelong_id = $resitoriginal->lelong_id;
|
||||
$payment->total_payment = $resit->total_payment;
|
||||
$payment->resit_id = $resitoriginal->id;
|
||||
$payment->status_payment_opt = 2; //bayar secara online 2
|
||||
$payment->status = 1; //fee rm10 - 1
|
||||
$payment->remark = 'BAYARAN ONLINE';
|
||||
$payment->save();
|
||||
|
||||
event(new PaymentNotify('PAID',$resit->user_id,$payment->id));
|
||||
event(new PaymentNotify('PAID', $resit->user_id, $payment));
|
||||
|
||||
$success = true;
|
||||
|
||||
$result = $resit->toArray();
|
||||
|
||||
// dump($success);
|
||||
// dump($data);
|
||||
// dump($result);
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'resit' => $resit
|
||||
// ]);
|
||||
|
||||
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
|
||||
|
||||
}else{
|
||||
$resit = Resit::where('billplz_id','=',$data['id'])->first();
|
||||
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
|
||||
} else {
|
||||
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
|
||||
$resit->status = 'UNSUCCESSFUL';
|
||||
$resit->paid_at = null;
|
||||
$resit->save();
|
||||
|
||||
event(new PaymentNotify('UNSUCCESSFUL',$resit->user_id,''));
|
||||
|
||||
event(new PaymentNotify('UNSUCCESSFUL', $resit->user_id, ''));
|
||||
|
||||
$result = $resit->toArray();
|
||||
|
||||
$success = false;
|
||||
|
||||
// return response()->json([
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'resit' => $resit
|
||||
// ]);
|
||||
|
||||
return view('pembida.feePaymentResult',compact('data', 'result', 'success'));
|
||||
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
public function bidresponse(Request $request)
|
||||
{
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if (config('app.env') != 'production') {
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
|
||||
$bill = $billplz->bill();
|
||||
$req = $request->toArray();
|
||||
$response = $bill->get($req['billplz']['id']);
|
||||
$data = $response->toArray();
|
||||
if ($data['paid'] == 'true') {
|
||||
$resit = Resit::where('billplz_id', '=', $data['id'])->first();
|
||||
$resit->status = 'PAID';
|
||||
$resit->paid_at = $data['paid_at'];
|
||||
$resit->save();
|
||||
|
||||
$resitoriginal = Resit::where('user_id', $resit->user_id)
|
||||
->where('lelong_id', $resit->lelong_id)
|
||||
->where('resit_type', 2)
|
||||
->first();
|
||||
|
||||
// $resitoriginal->total_payment = $resitoriginal->total_payment + $resit->total_payment;
|
||||
// $resitoriginal->save();
|
||||
|
||||
// $payment = new Payment;
|
||||
// $payment->user_id = $resitoriginal->user_id;
|
||||
// $payment->lelong_id = $resitoriginal->lelong_id;
|
||||
// $payment->total_payment = $resit->total_payment;
|
||||
// $payment->resit_id = $resitoriginal->id;
|
||||
// $payment->status_payment_opt = 2; //bayar secara online 2
|
||||
// $payment->status = 1; //fee rm10 - 1
|
||||
// $payment->remark = 'BAYARAN ONLINE';
|
||||
// $payment->save();
|
||||
|
||||
$payment = Payment::where('lelong_id', $resit->lelong_id)
|
||||
->where('user_id', $resit->user_id)
|
||||
->where('resit_id', $resit->id)
|
||||
->get();
|
||||
foreach ($payment as $index) {
|
||||
$index->status = 2; //0-unpaid //1-fee //2-bid
|
||||
$index->remark = "BERJAYA BAYARAN ONLINE";
|
||||
$index->update();
|
||||
}
|
||||
|
||||
event(new PaymentNotify('PAID', $resit->user_id, $payment));
|
||||
|
||||
$success = true;
|
||||
|
||||
$result = $resit->toArray();
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => true,
|
||||
// 'resit' => $resit
|
||||
// ]);
|
||||
|
||||
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
|
||||
} else {
|
||||
$resit = Resit::where('billplz_id', '=', $data['id'])->first();
|
||||
$resit->status = 'UNSUCCESSFUL';
|
||||
$resit->paid_at = null;
|
||||
$resit->save();
|
||||
|
||||
event(new PaymentNotify('UNSUCCESSFUL', $resit->user_id, ''));
|
||||
|
||||
$result = $resit->toArray();
|
||||
|
||||
$success = false;
|
||||
|
||||
// return response()->json([
|
||||
// 'success' => false,
|
||||
// 'resit' => $resit
|
||||
// ]);
|
||||
|
||||
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user