This commit is contained in:
Azfar Arsyad
2022-01-26 14:54:21 +08:00
parent 768fbcf3ce
commit 179e1794dd
2 changed files with 23 additions and 16 deletions
+21 -14
View File
@@ -27,6 +27,7 @@ use App\Models\LelongBidMarhun;
use App\Models\LelKarat;
use App\Models\LelKarat_temp;
use App\Models\Resit;
use App\Models\Payment;
use Session;
use Carbon\Carbon;
@@ -149,10 +150,9 @@ class ApiController extends Controller
$month = $current->month;
$year = $current->format('y');
$total_bayaran = 10;
$total_bayaran = 1000;
$collection_id = $this->collection_id;
// dd($request->all());
$response = $bill->create(
$collection_id,
'test@gmail.com',
@@ -160,8 +160,8 @@ class ApiController extends Controller
$request->name,
Money::MYR($total_bayaran),
route('pay.callback'),
'Bayaran Ansuran',
['redirect_url' => route('pay.paymentStatus')]
'Bayaran Borang',
['redirect_url' => 'http://192.168.0.10:8003/api/pembayaran/response']
);
$previous_siri = Resit::orderBy('id','desc')->first();
@@ -170,17 +170,21 @@ class ApiController extends Controller
}else{
$nosiri = 1;
}
$billcode = $response->toArray();
// dd($billcode);
// $billcode['redirect_url'] = 'http://192.168.0.10:8003/api/pembayaran/response';
// dd($billcode);
$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->lelongbid_id = null;
$resit->reference_no = $reference_no;
$resit->billplz_id = $billcode['id'];
$resit->resit_type = 1;
$resit->total_payment = $total_bayaran;
$resit->total_payment = 10;
$resit->save();
// foreach($array_payment as $index1=>$arraypay)
@@ -214,6 +218,7 @@ class ApiController extends Controller
}
public function callback(Request $request){
dd('hye');
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
@@ -256,6 +261,7 @@ class ApiController extends Controller
}
public function response(Request $request){
// dd($request->all());
$http = new HttpMethodsClient(
new GuzzleHttpClient(),
new GuzzleMessageFactory()
@@ -268,13 +274,14 @@ class ApiController extends Controller
$billplz->useVersion('v4');
$bill = $billplz->bill();
$data = $bill->webhook($request->toArray());
if($data['billplz']['paid'] == 'true'){
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
$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['billplz']['paid_at'];
$resit->paid_at = $data['paid_at'];
$resit->save();
// $transactionOnline = Http::get(config('api.url') . '/api/transaction/online/express',[
@@ -286,7 +293,7 @@ class ApiController extends Controller
]);
}else{
$resit = Resit::where('billplz_id','=',$data['billplz']['id'])->first();
$resit = Resit::where('billplz_id','=',$data['id'])->first();
$resit->status = 'UNSUCCESSFUL';
$resit->paid_at = null;
$resit->save();
+2 -2
View File
@@ -26,8 +26,8 @@ Route::post('/forgotpassword', [ResetPassword::class, 'forgotpassword']);
Route::post('/addToCart', [CartController::class, 'addToCart']);
Route::get('/cart/{userid}', [CartController::class, 'getCart']);
Route::post('/feepayment', [ApiController::class, 'feepayment']);
Route::get('/callback', [ApiController::class, 'feepayment']);
// Route::post('/feepayment', [ApiController::class, 'feepayment']);
// Route::get('/callback', [ApiController::class, 'feepayment']);
Route::post('/feepayment', [ApiController::class, 'feepayment'])->name('feepayment');
Route::get('/pembayaran/response', [ApiController::class, 'response'])->name('pay.paymentStatus');