commit
This commit is contained in:
@@ -26,7 +26,13 @@ use App\Models\LelongBid;
|
||||
use App\Models\LelongBidMarhun;
|
||||
use App\Models\LelKarat;
|
||||
use App\Models\LelKarat_temp;
|
||||
|
||||
use Session;
|
||||
use Carbon\Carbon;
|
||||
use Money\Money;
|
||||
use Billplz\Client;
|
||||
use Http\Client\Common\HttpMethodsClient;
|
||||
use Http\Adapter\Guzzle7\Client as GuzzleHttpClient;
|
||||
|
||||
class ApiController extends Controller
|
||||
{
|
||||
@@ -41,6 +47,19 @@ class ApiController extends Controller
|
||||
*
|
||||
* @return \Illuminate\Contracts\Support\Renderable
|
||||
*/
|
||||
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 = 'bwdtejv0';
|
||||
}else{
|
||||
$this->api_key = 'f3e82fe1-a422-4660-97f0-65cc59ff6c47';
|
||||
$this->XSignature_Key = 'S-alZUbzmD2_TF3vmrRqgehQ';
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public function biditem()
|
||||
{
|
||||
@@ -102,5 +121,191 @@ class ApiController extends Controller
|
||||
}
|
||||
}
|
||||
|
||||
public function PembayaranEngine(Request $request)
|
||||
{
|
||||
|
||||
$arraycollection_id = array();
|
||||
|
||||
$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();
|
||||
|
||||
$current = Carbon::now();
|
||||
$current = new Carbon();
|
||||
|
||||
$day = $current->day;
|
||||
$month = $current->month;
|
||||
$year = $current->format('y');
|
||||
|
||||
$total_bayaran = 10;
|
||||
|
||||
|
||||
$response = $bill->create(
|
||||
$collection_id,
|
||||
$request->email,
|
||||
$request->notel,
|
||||
$request->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::get(config('api.url') . '/api/online/transaction')->json();
|
||||
if($previous_siri){
|
||||
$nosiri = $previous_siri['nosiri'] + 1;
|
||||
}else{
|
||||
$nosiri = 1;
|
||||
}
|
||||
|
||||
$reference_no = 'LPKB' . $day . $month . $year . sprintf("%08d", $nosiri);
|
||||
|
||||
$new_transaction = Http::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 redirect($billcode['url'] . '?auto_submit=true');
|
||||
|
||||
// return view('pembayaran.result.berjaya',compact('arraybayaran'));
|
||||
}
|
||||
|
||||
public function callback(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();
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
Http::put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['billplz']['paid_at']
|
||||
]);
|
||||
|
||||
$transactionOnline = Http::get(config('api.url') . '/api/transaction/online/express',[
|
||||
'billplz_id' => $data['billplz']['id']
|
||||
])->json();
|
||||
|
||||
return redirect()->route('pay.success',[
|
||||
'transactionOnline' => $transactionOnline
|
||||
]);
|
||||
|
||||
}else{
|
||||
Http::put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null
|
||||
]);
|
||||
return redirect()->route('pay.failed');
|
||||
}
|
||||
}
|
||||
|
||||
public function response(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();
|
||||
|
||||
$data = $bill->webhook($request->toArray());
|
||||
if($data['billplz']['paid'] == 'true'){
|
||||
Http::put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'PAID',
|
||||
'paid_at' => $data['billplz']['paid_at']
|
||||
]);
|
||||
|
||||
$transactionOnline = Http::get(config('api.url') . '/api/transaction/online/login',[
|
||||
'billplz_id' => $data['billplz']['id']
|
||||
])->json();
|
||||
|
||||
return redirect()->route('pay.success',[
|
||||
'transactionOnline' => $transactionOnline
|
||||
]);
|
||||
|
||||
}else{
|
||||
Http::put(config('api.url') . '/api/online/transaction',[
|
||||
'billplz_id' => $data['billplz']['id'],
|
||||
'status' => 'UNSUCCESSFUL',
|
||||
'paid_at' => null
|
||||
]);
|
||||
return redirect()->route('pay.failed');
|
||||
}
|
||||
}
|
||||
|
||||
public function successPayment(Request $request){
|
||||
$transactionOnline = $request->transactionOnline;
|
||||
|
||||
// dd($transactionOnline);
|
||||
|
||||
$arraygadai = array();
|
||||
$arraycawangan = array();
|
||||
// dd($transactionOnline);
|
||||
foreach($transactionOnline as $index1=>$trans)
|
||||
{
|
||||
$cawangan_info = Http::get(config('api.url') . '/api/cawangan/'. $trans['kodcaw'])->json();
|
||||
$cawangan = Http::get(config('api.url') . '/api/cawangan/detail/'. $trans['kodcaw'])->json();
|
||||
$cawangan_detail = $cawangan[0];
|
||||
$nama_cawangan = $cawangan_info['details_caw'];
|
||||
$gadai = Http::get(config('api.url') .'/api/gadai/norujukan/'.$trans['norujukan'])->json();
|
||||
$gadai = $gadai[0][0];
|
||||
|
||||
array_push($arraygadai,$gadai);
|
||||
array_push($arraycawangan,$cawangan_detail);
|
||||
|
||||
|
||||
}
|
||||
|
||||
// dd($arraygadai,$arraycawangan);
|
||||
|
||||
// return view('pembayaran.result.berjaya',compact('transactionOnline','arraycawangan','arraygadai'));
|
||||
return view('pembayaran.result.berjayaportal',compact('transactionOnline','arraycawangan','arraygadai'));
|
||||
}
|
||||
|
||||
public function failedPayment(){
|
||||
// return view('pembayaran.result.gagal');
|
||||
return view('pembayaran.result.gagalportal');
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use App\Models\LelongBid;
|
||||
use App\Models\LelongBidMarhun;
|
||||
use App\Models\lelkarat;
|
||||
use Carbon\Carbon;
|
||||
use App\Models\Cawangan;
|
||||
|
||||
class LelongMobileController extends Controller
|
||||
{
|
||||
@@ -29,13 +30,14 @@ class LelongMobileController extends Controller
|
||||
$lelong[$index1]['lelongbid'] = $lelongbid;
|
||||
|
||||
foreach($lelongbid as $index2=>$lelbidmarhun){
|
||||
|
||||
$cawangan = Cawangan::where('id','=',$lelbidmarhun['caw_id'])->first()->toArray();
|
||||
// $id = lelongbid::first();
|
||||
|
||||
$lelongbidmarhun = LelongBidMarhun::where('lelongbid_id', $lelbidmarhun['id'])
|
||||
->get()->toArray();
|
||||
|
||||
$lelong[$index1]['lelongbid'][$index2]['lelongbidmarhun'] = $lelongbidmarhun;
|
||||
$lelong[$index1]['lelongbid'][$index2]['cawangan'] = $cawangan;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,9 +42,11 @@ class CartController extends Controller
|
||||
{
|
||||
$lelongbid = LelongBid::where('id',$cart['lelongbid_id'])->first()->toArray();
|
||||
$marhun = LelongBidMarhun::where('lelongbid_id','=',$lelongbid['id'])->get()->toArray();
|
||||
$cawangan = Cawangan::where('id','=',$lelongbid['caw_id'])->first()->toArray();
|
||||
|
||||
$carts[$index]['datalelongbid'] = $lelongbid;
|
||||
$carts[$index]['datalelongbid']['lelongbidmarhun'] = $marhun;
|
||||
$carts[$index]['datalelongbid']['cawangan'] = $cawangan;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -10,9 +10,11 @@
|
||||
"fruitcake/laravel-cors": "^2.0",
|
||||
"guzzlehttp/guzzle": "^7.0.1",
|
||||
"intervention/image": "^2.7",
|
||||
"jomweb/billplz": "4.1",
|
||||
"laravel/framework": "^8.65",
|
||||
"laravel/sanctum": "^2.13",
|
||||
"laravel/tinker": "^2.5",
|
||||
"php-http/guzzle7-adapter": "^1.0",
|
||||
"spatie/laravel-permission": "^5.3"
|
||||
},
|
||||
"require-dev": {
|
||||
|
||||
Generated
+1150
-1
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user