Codebase update
- update jomweb/billplz package - refactor controllers, views with means of to simplify data fetch and manipuation
This commit is contained in:
@@ -2,226 +2,147 @@
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
|
||||
use Billplz\Client;
|
||||
use Session;
|
||||
use Http\Client\Common\HttpMethodsClient;
|
||||
use Http\Adapter\Guzzle6\Client as GuzzleHttpClient;
|
||||
use Http\Message\MessageFactory\GuzzleMessageFactory;
|
||||
use Money\Money;
|
||||
|
||||
use App\Services\BillplzService;
|
||||
use Carbon\Carbon;
|
||||
use Illuminate\Log\Logger;
|
||||
use Illuminate\Http\Client\Pool;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Illuminate\Support\Facades\Http;
|
||||
use Money\Money;
|
||||
|
||||
class BayaranController extends Controller
|
||||
{
|
||||
|
||||
public function __construct(){
|
||||
parent::__construct();
|
||||
if(config('app.env') != 'production'){
|
||||
$this->api_key = 'abecfd0c-98d8-4635-abc2-2fcba8c60c11';
|
||||
$this->XSignature_Key = 'S-GWr7z03XjAhqPsFfu_H5nQ';
|
||||
$this->collection_id = '5aosv2dg';
|
||||
}else{
|
||||
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
|
||||
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function SenaraiPembayaran()
|
||||
{
|
||||
|
||||
$api_url = config('api.url');
|
||||
|
||||
$arraysag = [];
|
||||
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$belum_tebus = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/customers/'. $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json();
|
||||
|
||||
if(is_array($belum_tebus))
|
||||
{
|
||||
if(sizeof($belum_tebus) > 0)
|
||||
{
|
||||
foreach($belum_tebus as $index=>$bt)
|
||||
{
|
||||
foreach($bt as $index1=>$bet)
|
||||
{
|
||||
array_push($arraysag,$bet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$belum_tebus = $arraysag;
|
||||
|
||||
// return view('pembayaran.senaraibayaran', compact('belum_tebus'));
|
||||
return view('includes.bayaran.senaraibayaransag', compact('belum_tebus','api_url'));
|
||||
}
|
||||
|
||||
public function PembayaranAction(Request $request)
|
||||
{
|
||||
|
||||
|
||||
$validated = $request->validate([
|
||||
'chkboxsag' => 'required',
|
||||
]);
|
||||
|
||||
$arraybayar = array();
|
||||
$norujukanList = $request->chkboxsag;
|
||||
|
||||
foreach($request->chkboxsag as $index=>$sag)
|
||||
{
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/gadai/norujukan/'. $sag)->json();
|
||||
$arraybayar = array_map(fn($x) => Http::arrahn()->get('/api/gadai/norujukan/' . $x)->json()[0][0], $norujukanList);
|
||||
|
||||
$sagonline = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/portal/searchsagonline/',['norujukan' => $sag])->json();
|
||||
$norujukanRecentlyAttemptPayment = array_map(
|
||||
fn($x) => Http::arrahn()->get('/portal/searchsagonline/', ['norujukan' => $x])->json(),
|
||||
$norujukanList
|
||||
);
|
||||
|
||||
if($sagonline == true)
|
||||
return redirect()->route('home')->with('errorsagonline','Sila Tunggu Sebentar!');
|
||||
//$array_lelong = Http::withOptions(['verify' => config('app.api_verify')])->get('https://niklah.arrahn.com.my/api/portalApi',['norujukan' => $sag])->json();
|
||||
//if($array_lelong['lelong'] !== null){
|
||||
// return redirect()->route('home')->with('error','Barangan Sedang Dilelong.');
|
||||
//}
|
||||
$isNorujukanRecentlyAttemptPayment = in_array(true, $norujukanRecentlyAttemptPayment);
|
||||
|
||||
if($gadai[0][0]['tempoh'] >= 12){
|
||||
// return redirect()->route('home')->with('error','SAG Yang Dipilih melebihi tempoh 12 bulan ke atas.');
|
||||
return redirect()->route('home')->with('error','SAG Yang Dipilih Akan/Telah Tamat Kontrak 12 Bulan. Sila Hadir Ke Kaunter Cawangan Untuk Pembayaran/Penebusan.');
|
||||
}
|
||||
|
||||
$arraybayar[] = $gadai[0][0];
|
||||
if ($isNorujukanRecentlyAttemptPayment) {
|
||||
return redirect()->route('home')->with('errorsagonline', 'Sila Tunggu Sebentar!');
|
||||
}
|
||||
|
||||
$gadaiContractExceed12Month = array_filter($arraybayar, fn($x) => $x['tempoh'] >= 12);
|
||||
|
||||
// return view('pembayaran.checkout',compact('arraybayar'));
|
||||
return view('includes.bayaran.pembayaransag',compact('arraybayar'));
|
||||
$isGadaiContractExceed12Month = sizeof($gadaiContractExceed12Month) > 0;
|
||||
|
||||
if ($isGadaiContractExceed12Month) {
|
||||
return redirect()->route('home')->with('error', 'SAG Yang Dipilih Akan/Telah Tamat Kontrak 12 Bulan. Sila Hadir Ke Kaunter Cawangan Untuk Pembayaran/Penebusan.');
|
||||
}
|
||||
|
||||
return view('includes.bayaran.pembayaransag', compact('arraybayar'));
|
||||
}
|
||||
|
||||
public function PembayaranEngine(Request $request)
|
||||
public function PembayaranEngine(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
// $arraybayaran = array();
|
||||
['email' => $customerEmail, 'notel' => $customerPhoneNumber, 'name' => $customerName, 'icno' => $customerIcno] = auth()->user()->toArray();
|
||||
|
||||
// dd($request);
|
||||
// foreach($request->txtnorujukanhidden as $index1=>$norujukan)
|
||||
// {
|
||||
// // $updategadai = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url').'/api/gadai/'. $request->txtkodcawhidden[$index1] .'/norujukan/' . $norujukan,[
|
||||
// // 'bayaran' => $request->txtbayaranhidden[$index1]
|
||||
// // ])->json();
|
||||
$bayaranArrahn = array_filter($request->txtjenisbayaran, fn($x) => $x == 'arrahn');
|
||||
$bayaranOthers = array_filter($request->txtjenisbayaran, fn($x) => $x != 'arrahn');
|
||||
|
||||
$bayaranArrahnArray = array_map(function ($x) use ($customerName, $customerIcno, $request) {
|
||||
return [
|
||||
'customer_name' => $customerName,
|
||||
'nokp' => $customerIcno,
|
||||
'kodcaw' => $request->txtkodcawhidden[$x],
|
||||
'norujukan' => $request->txtnorujukanhidden[$x],
|
||||
'bayaran' => $request->txtbayaranhidden[$x],
|
||||
'txtjbghidden' => $request->txtjbghidden[$x],
|
||||
'txtupahhidden' => $request->txtupahhidden[$x],
|
||||
];
|
||||
}, array_keys($bayaranArrahn));
|
||||
|
||||
// array_push($arraybayaran,['norujukan' => $norujukan, 'kodcaw' => $request->txtkodcawhidden[$index1], 'bayaran' => $request->txtbayaranhidden[$index1]]);
|
||||
// }
|
||||
$bayaranOthersArray = array_map(function ($x) use ($customerName, $customerIcno, $request) {
|
||||
return [
|
||||
'customer_name' => $customerName,
|
||||
'nokp' => $customerIcno,
|
||||
'kodcaw' => $request->txtkodcawhidden[$x],
|
||||
'norujukan' => $request->txtnorujukanhidden[$x],
|
||||
'bayaran' => $request->txtbayaranhidden[$x],
|
||||
];
|
||||
}, array_keys($bayaranOthers));
|
||||
|
||||
// $arraycollection_id = array();
|
||||
$collection_id = '5aosv2dg';
|
||||
$paymentArray = array_merge($bayaranArrahnArray, $bayaranOthersArray);
|
||||
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
$getPaymentSum = function () use ($paymentArray) {
|
||||
$billPlzTransactionFee = Money::MYR(100);
|
||||
$sum = fn() => array_reduce($paymentArray, fn($accumulator, $currentItem) => $accumulator + round($currentItem['bayaran'], 1), 0) * 100;
|
||||
return Money::MYR($sum())->add($billPlzTransactionFee);
|
||||
};
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$bill = $billplzService->createBill([
|
||||
$customerEmail,
|
||||
$customerPhoneNumber,
|
||||
$customerName,
|
||||
$getPaymentSum(),
|
||||
]);
|
||||
|
||||
$billplz->useVersion('v4');
|
||||
$isRecordTransactionSuccess = $this->recordTransaction($paymentArray, $bill);
|
||||
|
||||
$bill = $billplz->bill();
|
||||
if ($isRecordTransactionSuccess) {
|
||||
session([
|
||||
'array_payment' => $paymentArray,
|
||||
'payment_method' => 'login',
|
||||
]);
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$day = $current->day;
|
||||
$month = $current->month;
|
||||
$year = $current->format('y');
|
||||
|
||||
$array_payment = [];
|
||||
|
||||
$total_bayaran = 0;
|
||||
|
||||
foreach($request->txtnorujukanhidden as $index1=>$norujukan)
|
||||
{
|
||||
if($request->txtjenisbayaran[$index1] == 'arrahn')
|
||||
{
|
||||
array_push($array_payment,['customer_name' => Auth::user()->name,'kodcaw'=>$request->txtkodcawhidden[$index1],'norujukan'=>$norujukan,'bayaran'=>$request->txtbayaranhidden[$index1],'jbg' => $request->txtjbghidden[$index1],'upah' => $request->txtupahhidden[$index1]]);
|
||||
Session::put('payment_jenis','arrahn');
|
||||
}
|
||||
else
|
||||
{
|
||||
array_push($array_payment,['customer_name' => Auth::user()->name,'nokp' => Auth::user()->icno,'kodcaw'=>$request->txtkodcawhidden[$index1],'norujukan'=>$norujukan,'bayaran'=>round($request->txtbayaranhidden[$index1],1)]);
|
||||
}
|
||||
|
||||
//$total_bayaran += $request->txtbayaranhidden[$index1];
|
||||
$total_bayaran += round($request->txtbayaranhidden[$index1],1);
|
||||
return redirect($bill['url'] . '?auto_submit=true');
|
||||
}
|
||||
|
||||
$total_bayaran = ($total_bayaran * 100) + 100;
|
||||
}
|
||||
|
||||
Session::put('array_payment',$array_payment);
|
||||
Session::put('payment_method','login');
|
||||
Session::save();
|
||||
public function recordTransaction($paymentArray, $bill)
|
||||
{
|
||||
|
||||
// foreach($request->txtkodcawhidden as $index2=>$kodcaw)
|
||||
// {
|
||||
// if(config('app.env') != 'production'){
|
||||
// $collection_id = $this->collection_id;
|
||||
// }else{
|
||||
// $collection_id = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url'). '/api/billplz/collectionid',[
|
||||
// 'kodcaw' => $kodcaw
|
||||
// ])->json();
|
||||
// }
|
||||
// array_push($arraycollection_id,$collection_id);
|
||||
// }
|
||||
['name' => $customerName, 'icno' => $customerIcno] = auth()->user()->toArray();
|
||||
|
||||
|
||||
$response = $bill->create(
|
||||
$collection_id,
|
||||
Auth::user()->email,
|
||||
Auth::user()->notel,
|
||||
Auth::user()->name,
|
||||
Money::MYR($total_bayaran),
|
||||
route('pay.callback'),
|
||||
'Bayaran Ansuran',
|
||||
['redirect_url' => route('pay.paymentStatus')]
|
||||
);
|
||||
|
||||
$billcode = $response->toArray();
|
||||
|
||||
foreach($array_payment as $index1=>$arraypay)
|
||||
{
|
||||
$previous_siri = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/online/transaction')->json();
|
||||
if($previous_siri){
|
||||
$nosiri = $previous_siri['nosiri'] + 1;
|
||||
}else{
|
||||
$nosiri = 1;
|
||||
$getlatestNoSiri = function () {
|
||||
$previous_siri = Http::arrahn()->get('/api/online/transaction')->json();
|
||||
if ($previous_siri) {
|
||||
return $previous_siri['nosiri'] + 1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
};
|
||||
|
||||
$reference_no = 'APKB' . $day . $month . $year . sprintf("%08d", $nosiri);
|
||||
$generateTransactionReferenceNumber = function () use ($getlatestNoSiri) {
|
||||
[$day, $month, $year] = [now()->day, now()->month, now()->format('y')];
|
||||
|
||||
$new_transaction = Http::withOptions(['verify' => config('app.api_verify')])->post(config('api.url') . '/api/online/transaction',[
|
||||
'nokp'=> Auth::user()->icno,
|
||||
'reference_no'=> $reference_no,
|
||||
'nosiri'=> $nosiri,
|
||||
'billplz_id' => $billcode['id'],
|
||||
'norujukan' => $arraypay['norujukan'],
|
||||
'kodcaw' => $arraypay['kodcaw'],
|
||||
'total_payment'=> $arraypay['bayaran'],
|
||||
'customer_name' => Auth::user()->name,
|
||||
])->json();
|
||||
return 'APKB' . $day . $month . $year . sprintf("%08d", $getlatestNoSiri());
|
||||
};
|
||||
|
||||
}
|
||||
Http::pool(fn(Pool $pool) =>
|
||||
collect($paymentArray)->map(fn($payment) =>
|
||||
$pool->arrahn()->post('/api/online/transaction', [
|
||||
'nokp' => $customerIcno,
|
||||
'reference_no' => $generateTransactionReferenceNumber(),
|
||||
'nosiri' => $getlatestNoSiri(),
|
||||
'billplz_id' => $bill['id'],
|
||||
'norujukan' => $payment['norujukan'],
|
||||
'kodcaw' => $payment['kodcaw'],
|
||||
'total_payment' => $payment['bayaran'],
|
||||
'customer_name' => $customerName,
|
||||
])
|
||||
)
|
||||
);
|
||||
|
||||
$tagportal = Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/transaction/online/tagportal',[
|
||||
'billplz_id'=> $billcode['id']
|
||||
])->json();
|
||||
Http::arrahn()->put('/api/transaction/online/tagportal', [
|
||||
'billplz_id' => $bill['id'],
|
||||
])->json();
|
||||
|
||||
return redirect($billcode['url'] . '?auto_submit=true');
|
||||
|
||||
// return view('pembayaran.result.berjaya',compact('arraybayaran'));
|
||||
return true;
|
||||
}
|
||||
|
||||
public function ResitBayaran(Request $request)
|
||||
@@ -230,160 +151,134 @@ class BayaranController extends Controller
|
||||
|
||||
$kpbaru = Auth::User()->icno;
|
||||
|
||||
$customer = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/customers/'.$kpbaru)->json();
|
||||
$customer = Http::arrahn()->get('/api/customers/' . $kpbaru)->json();
|
||||
$customer_details = $customer;
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
$date = $current->toDateTimeString();
|
||||
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $payment_details['kodcaw'])->json();
|
||||
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/detail/'. $payment_details['kodcaw'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
$cawangan_info = Http::arrahn()->get('/api/cawangan/' . $payment_details['kodcaw'])->json();
|
||||
$cawangan = Http::arrahn()->get('/api/cawangan/detail/' . $payment_details['kodcaw'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
|
||||
$gadai_details = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/gadai/norujukan/'.$payment_details['norujukan'])->json();
|
||||
$gadai = $gadai_details[0][0];
|
||||
// if($gadai_details[0][0]['hargajualan'] > 0)
|
||||
// {
|
||||
// $baki_harga_jualan_sebelum = $gadai_details[0][0]['bakihargajualan'] + $payment_details['total_payment'];
|
||||
// $baki_harga_jualan_semasa = $gadai_details[0][0]['bakihargajualan'];
|
||||
$gadai_details = Http::arrahn()->get('/api/gadai/norujukan/' . $payment_details['norujukan'])->json();
|
||||
$gadai = $gadai_details[0][0];
|
||||
|
||||
return view('pembayaran.resit.resitportal',compact('customer_details','payment_details','cawangan_detail','nama_cawangan','gadai'));
|
||||
// }else{
|
||||
|
||||
// $gadai_details = $gadai_details[0][0];
|
||||
|
||||
// $koskeuntungan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/upahbukantawarruq/' . $payment_details['kodcaw'] . '/' . $payment_details['norujukan'])->json();
|
||||
|
||||
// $jbg = $gadai_details['jbg'];
|
||||
|
||||
// return view('pembayaran.resit.resit_baru_sebelum',compact('customer_details','payment_details','date','koskeuntungan','jbg'));
|
||||
// }
|
||||
return view('pembayaran.resit.resitportal', compact('customer_details', 'payment_details', 'cawangan_detail', 'nama_cawangan', 'gadai'));
|
||||
|
||||
}
|
||||
|
||||
public function callback(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
$data = $billplzService->webhook($request->toArray());
|
||||
|
||||
public function callback(Request $request){
|
||||
logger('REQUEST');
|
||||
logger($request);
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
$isBillUnpaid = $data['paid'] !== true;
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
if ($isBillUnpaid) {
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null,
|
||||
]);
|
||||
|
||||
$bill = $billplz->bill();
|
||||
return response(200);
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
}
|
||||
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['billplz']['paid_at']
|
||||
]);
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['paid_at']->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
$transactionOnline = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/online/express',[
|
||||
'billplz_id' => $data['billplz']['id']
|
||||
])->json();
|
||||
return response(200);
|
||||
}
|
||||
|
||||
// \Mail::to(Auth::user()->email)->send(new \App\Mail\BayaranMail($array_payment));
|
||||
|
||||
// return redirect()->route('pay.success',[
|
||||
// 'transactionOnline' => $transactionOnline
|
||||
// ]);
|
||||
return response(200);
|
||||
public function response(Request $request, BillplzService $billplzService)
|
||||
{
|
||||
|
||||
}else{
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null
|
||||
]);
|
||||
$data = $billplzService->redirect($request->toArray());
|
||||
|
||||
// return redirect()->route('pay.failed');
|
||||
return response(500);
|
||||
}
|
||||
}
|
||||
$isBillUnpaid = $data['paid'] !== true;
|
||||
|
||||
public function response(Request $request){
|
||||
$http = new HttpMethodsClient(
|
||||
new GuzzleHttpClient(),
|
||||
new GuzzleMessageFactory()
|
||||
);
|
||||
if ($isBillUnpaid) {
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null,
|
||||
]);
|
||||
|
||||
$billplz = new Client($http, $this->api_key);
|
||||
if(config('app.env') != 'production'){
|
||||
$billplz->useSandbox();
|
||||
}
|
||||
$billplz->useVersion('v4');
|
||||
$transactionOnline = Http::arrahn()->get('/api/transaction/online/login', [
|
||||
'billplz_id' => $data['id'],
|
||||
])->json();
|
||||
|
||||
$bill = $billplz->bill();
|
||||
return redirect()->route('pay.failed');
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['billplz']['paid_at']
|
||||
]);
|
||||
}
|
||||
|
||||
$transactionOnline = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/transaction/online/login',[
|
||||
'billplz_id' => $data['billplz']['id']
|
||||
])->json();
|
||||
Http::arrahn()->put('/api/online/transaction', [
|
||||
'billplz_id' => $data['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['paid_at']->format('Y-m-d H:i:s'),
|
||||
]);
|
||||
|
||||
return redirect()->route('pay.success',[
|
||||
'transactionOnline' => $transactionOnline
|
||||
]);
|
||||
$transactionOnline = Http::arrahn()->get('/api/transaction/online/login', [
|
||||
'billplz_id' => $data['id'],
|
||||
])->json();
|
||||
|
||||
}else{
|
||||
Http::withOptions(['verify' => config('app.api_verify')])->put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null
|
||||
]);
|
||||
return redirect()->route('pay.failed');
|
||||
}
|
||||
}
|
||||
return redirect()->route('pay.success', [
|
||||
'transactionOnline' => $transactionOnline,
|
||||
]);
|
||||
|
||||
public function successPayment(Request $request){
|
||||
$transactionOnline = $request->transactionOnline;
|
||||
}
|
||||
|
||||
// dd($transactionOnline);
|
||||
public function successPayment(Request $request)
|
||||
{
|
||||
$transactionOnline = $request->transactionOnline;
|
||||
|
||||
$arraygadai = array_map(
|
||||
fn($x) => Http::arrahn()->get('/api/gadai/norujukan/' . $x['norujukan'])->json()[0][0],
|
||||
$transactionOnline
|
||||
);
|
||||
|
||||
$arraygadai = array();
|
||||
$arraycawangan = array();
|
||||
// dd($transactionOnline);
|
||||
foreach($transactionOnline as $index1=>$trans)
|
||||
{
|
||||
$cawangan_info = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/'. $trans['kodcaw'])->json();
|
||||
$cawangan = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') . '/api/cawangan/detail/'. $trans['kodcaw'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
$gadai = Http::withOptions(['verify' => config('app.api_verify')])->get(config('api.url') .'/api/gadai/norujukan/'.$trans['norujukan'])->json();
|
||||
$gadai = $gadai[0][0];
|
||||
$arraycawangan = array_map(
|
||||
fn($x) => Http::arrahn()->get('/api/cawangan/detail/' . $x['kodcaw'])->json()[0],
|
||||
$transactionOnline
|
||||
);
|
||||
|
||||
array_push($arraygadai,$gadai);
|
||||
array_push($arraycawangan,$cawangan_detail);
|
||||
return view('pembayaran.result.berjayaportal', compact('transactionOnline', 'arraycawangan', 'arraygadai'));
|
||||
}
|
||||
|
||||
public function failedPayment()
|
||||
{
|
||||
return view('pembayaran.result.gagalportal');
|
||||
}
|
||||
|
||||
}
|
||||
public function SenaraiPembayaran()
|
||||
{
|
||||
|
||||
// dd($arraygadai,$arraycawangan);
|
||||
$api_url = config('api.url');
|
||||
|
||||
// return view('pembayaran.result.berjaya',compact('transactionOnline','arraycawangan','arraygadai'));
|
||||
return view('pembayaran.result.berjayaportal',compact('transactionOnline','arraycawangan','arraygadai'));
|
||||
}
|
||||
$arraysag = [];
|
||||
|
||||
public function failedPayment(){
|
||||
// return view('pembayaran.result.gagal');
|
||||
return view('pembayaran.result.gagalportal');
|
||||
}
|
||||
$auth_user = Auth::user();
|
||||
|
||||
$belum_tebus = Http::arrahn()->get('/api/customers/' . $auth_user['icno'] . '/gadai/' . 'belum_tebus')->json();
|
||||
|
||||
if (is_array($belum_tebus)) {
|
||||
if (sizeof($belum_tebus) > 0) {
|
||||
foreach ($belum_tebus as $index => $bt) {
|
||||
foreach ($bt as $index1 => $bet) {
|
||||
array_push($arraysag, $bet);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$belum_tebus = $arraysag;
|
||||
|
||||
return view('includes.bayaran.senaraibayaransag', compact('belum_tebus', 'api_url'));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user