tambah function semakan billplz

This commit is contained in:
BTMS2
2025-05-06 10:12:20 +08:00
parent d95767c5f9
commit 791ca8dd84
8 changed files with 580 additions and 1 deletions
+62
View File
@@ -39,6 +39,7 @@ use Billplz\Client;
use Http\Client\Common\HttpMethodsClient;
use Http\Adapter\Guzzle7\Client as GuzzleHttpClient;
use Http\Message\MessageFactory\GuzzleMessageFactory;
use App\Models\LogUser;
class ApiController extends Controller
{
@@ -644,5 +645,66 @@ class ApiController extends Controller
return view('pembida.feePaymentResult', compact('data', 'result', 'success'));
}
}
// BillplzService.php atau ApiController.php
public function processPaidResit(array $data)
{
$currentdate = Carbon::now();
$currentdate = $currentdate->toDateTimeString();
$loguser = new LogUser;
$loguser->user_id = User::where('name','System')->first()->id;
$loguser->date = $currentdate;
$loguser->username = 'System';
$loguser->nama_user = 'System';
$loguser->norujukan = $data['billplz']['id'];
$loguser->nota = 'Callback Resit Billplz Telah Bayar : Billplz_id -'.$data['billplz']['id'];
$loguser->save();
$resit = Resit::where('billplz_id', '=', $data['billplz']['id'])->first();
if (!$resit) {
return false;
}
$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 = 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;
$index->remark = "BERJAYA BAYARAN ONLINE";
$index->update();
$updateTagBid = LelongBid::where('norujukan', $index->norujukan)->first();
if ($updateTagBid) {
$updateTagBid->status_payment = 2;
$updateTagBid->save();
$updateTagBidder = LelongBidder::where('lelongbid_id', $updateTagBid->id)
->where('user_id', $resit->user_id)->first();
if ($updateTagBidder) {
$updateTagBidder->status_payment = 2;
$updateTagBidder->payment_id = $index->id;
$updateTagBidder->save();
}
}
}
event(new PaymentNotify('PAID', $resit->user_id, $payment));
return true;
}
}