Add PayPal webhook handling
This commit is contained in:
@@ -5,6 +5,7 @@ namespace App\Http\Controllers;
|
||||
use App\Models\CheckoutSession;
|
||||
use App\Services\Checkout\CheckoutAssignmentService;
|
||||
use App\Services\Checkout\CheckoutSessionService;
|
||||
use App\Services\Coupons\CouponRedemptionService;
|
||||
use App\Services\PayPal\Exceptions\PayPalException;
|
||||
use App\Services\PayPal\PayPalOrderService;
|
||||
use Illuminate\Http\RedirectResponse;
|
||||
@@ -18,6 +19,7 @@ class PayPalReturnController extends Controller
|
||||
private readonly PayPalOrderService $orders,
|
||||
private readonly CheckoutSessionService $sessions,
|
||||
private readonly CheckoutAssignmentService $assignment,
|
||||
private readonly CouponRedemptionService $couponRedemptions,
|
||||
) {}
|
||||
|
||||
public function __invoke(Request $request): RedirectResponse
|
||||
@@ -57,6 +59,7 @@ class PayPalReturnController extends Controller
|
||||
]);
|
||||
|
||||
$this->sessions->markFailed($session, 'paypal_capture_failed');
|
||||
$this->couponRedemptions->recordFailure($session, 'paypal_capture_failed');
|
||||
|
||||
return redirect()->to($this->resolveSafeRedirect($cancelUrl, $fallback));
|
||||
}
|
||||
@@ -89,11 +92,13 @@ class PayPalReturnController extends Controller
|
||||
]);
|
||||
|
||||
$this->sessions->markCompleted($session, now());
|
||||
$this->couponRedemptions->recordSuccess($session, $capture);
|
||||
|
||||
return redirect()->to($this->resolveSafeRedirect($successUrl, $fallback));
|
||||
}
|
||||
|
||||
$this->sessions->markFailed($session, 'paypal_'.$status);
|
||||
$this->couponRedemptions->recordFailure($session, 'paypal_'.$status);
|
||||
|
||||
return redirect()->to($this->resolveSafeRedirect($cancelUrl, $fallback));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user