fix: 🐛 Only update user credits etc. when paid
This commit is contained in:
parent
a34825a692
commit
11a8e50d2e
|
@ -22,19 +22,23 @@ class UserPayment
|
||||||
$user = $event->user;
|
$user = $event->user;
|
||||||
$shopProduct = $event->shopProduct;
|
$shopProduct = $event->shopProduct;
|
||||||
|
|
||||||
|
// only update user if payment is paid
|
||||||
|
if ($event->payment->status != "paid") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
//update server limit
|
//update server limit
|
||||||
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) {
|
if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0 && $user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
|
||||||
if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) {
|
|
||||||
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
|
$user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
//update User with bought item
|
//update User with bought item
|
||||||
if ($shopProduct->type == "Credits") {
|
if ($shopProduct->type == "Credits") {
|
||||||
$user->increment('credits', $shopProduct->quantity);
|
$user->increment('credits', $shopProduct->quantity);
|
||||||
} elseif ($shopProduct->type == "Server slots") {
|
} elseif ($shopProduct->type == "Server slots") {
|
||||||
$user->increment('server_limit', $shopProduct->quantity);
|
$user->increment('server_limit', $shopProduct->quantity);
|
||||||
}
|
}
|
||||||
|
|
||||||
//give referral commission always
|
//give referral commission always
|
||||||
if ((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type == "Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "true") {
|
if ((config("SETTINGS::REFERRAL:MODE") == "commission" || config("SETTINGS::REFERRAL:MODE") == "both") && $shopProduct->type == "Credits" && config("SETTINGS::REFERRAL::ALWAYS_GIVE_COMMISSION") == "true") {
|
||||||
if ($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()) {
|
if ($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()) {
|
||||||
|
|
|
@ -65,8 +65,8 @@ trait Invoiceable
|
||||||
->delimiter("-")
|
->delimiter("-")
|
||||||
->sequence($newInvoiceID)
|
->sequence($newInvoiceID)
|
||||||
->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
|
->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}')
|
||||||
->currencyCode($payment->currency_code)
|
->currencyCode(strtoupper($payment->currency_code))
|
||||||
->currencySymbol(Currencies::getSymbol($payment->currency_code))
|
->currencySymbol(Currencies::getSymbol(strtoupper($payment->currency_code)))
|
||||||
->notes($notes);
|
->notes($notes);
|
||||||
|
|
||||||
if (file_exists($logoPath)) {
|
if (file_exists($logoPath)) {
|
||||||
|
@ -89,4 +89,3 @@ trait Invoiceable
|
||||||
$user->notify(new InvoiceNotification($invoice, $user, $payment));
|
$user->notify(new InvoiceNotification($invoice, $user, $payment));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue