fix: 🐛 fix #901

This commit is contained in:
Ferks-FK 2023-09-17 13:01:37 -04:00
parent 7ecc29487e
commit a471cb4021
2 changed files with 9 additions and 4 deletions

View file

@ -143,14 +143,19 @@ class PaymentController extends Controller
$subtotal = $shopProduct->price;
// Apply Coupon
$isCouponValid = $this->isCouponValid($couponCode, $user, $shopProduct->id);
if ($isCouponValid) {
$subtotal = $this->applyCoupon($couponCode, $subtotal);
if ($couponCode) {
if ($this->isCouponValid($couponCode, $user, $shopProduct->id)) {
$subtotal = $this->applyCoupon($couponCode, $subtotal);
}
}
// Apply Partner Discount
$subtotal = $subtotal - ($subtotal * $discount / 100);
if ($subtotal <= 0) {
if ($couponCode) {
event(new CouponUsedEvent($couponCode));
}
return $this->handleFreeProduct($shopProduct);
}

View file

@ -49,7 +49,7 @@ class UserPayment
$shopProduct = $event->shopProduct;
// only update user if payment is paid
if ($event->payment->status != PaymentStatus::PAID) {
if ($event->payment->status != PaymentStatus::PAID->value) {
return;
}