initial commit
This commit is contained in:
39
app/Http/Controllers/BankPaymentController.php
Normal file
39
app/Http/Controllers/BankPaymentController.php
Normal file
@@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Controllers;
|
||||
|
||||
use App\Models\Plan;
|
||||
use App\Models\User;
|
||||
use App\Models\Setting;
|
||||
use App\Models\PlanOrder;
|
||||
use App\Models\PaymentSetting;
|
||||
use Illuminate\Http\Request;
|
||||
|
||||
class BankPaymentController extends Controller
|
||||
{
|
||||
public function processPayment(Request $request)
|
||||
{
|
||||
$validated = validatePaymentRequest($request, [
|
||||
'amount' => 'required|numeric|min:0',
|
||||
]);
|
||||
|
||||
try {
|
||||
$plan = Plan::findOrFail($validated['plan_id']);
|
||||
|
||||
createPlanOrder([
|
||||
'user_id' => auth()->id(),
|
||||
'plan_id' => $plan->id,
|
||||
'billing_cycle' => $validated['billing_cycle'],
|
||||
'payment_method' => 'bank',
|
||||
'coupon_code' => $validated['coupon_code'] ?? null,
|
||||
'payment_id' => 'BANK_' . strtoupper(uniqid()),
|
||||
'status' => 'pending',
|
||||
]);
|
||||
|
||||
return back()->with('success', __('Payment request submitted. Your plan will be activated after payment verification.'));
|
||||
|
||||
} catch (\Exception $e) {
|
||||
return handlePaymentError($e, 'bank');
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user