From 11a8e50d2e6ecce8b3a4cc1306b0cb52c741e444 Mon Sep 17 00:00:00 2001 From: IceToast <> Date: Sun, 15 Jan 2023 01:41:42 +0100 Subject: [PATCH] =?UTF-8?q?fix:=20=F0=9F=90=9B=20Only=20update=20user=20cr?= =?UTF-8?q?edits=20etc.=20when=20paid?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Listeners/UserPayment.php | 12 ++++++++---- app/Traits/Invoiceable.php | 5 ++--- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/app/Listeners/UserPayment.php b/app/Listeners/UserPayment.php index e6729d9c..be947087 100644 --- a/app/Listeners/UserPayment.php +++ b/app/Listeners/UserPayment.php @@ -22,19 +22,23 @@ class UserPayment $user = $event->user; $shopProduct = $event->shopProduct; + // only update user if payment is paid + if ($event->payment->status != "paid") { + return; + } //update server limit - if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0) { - if ($user->server_limit < config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')) { - $user->update(['server_limit' => config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE')]); - } + if (config('SETTINGS::USER:SERVER_LIMIT_AFTER_IRL_PURCHASE') !== 0 && $user->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 if ($shopProduct->type == "Credits") { $user->increment('credits', $shopProduct->quantity); } elseif ($shopProduct->type == "Server slots") { $user->increment('server_limit', $shopProduct->quantity); } + //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 ($ref_user = DB::table("user_referrals")->where('registered_user_id', '=', $user->id)->first()) { diff --git a/app/Traits/Invoiceable.php b/app/Traits/Invoiceable.php index 4618215e..c9073d36 100644 --- a/app/Traits/Invoiceable.php +++ b/app/Traits/Invoiceable.php @@ -65,8 +65,8 @@ trait Invoiceable ->delimiter("-") ->sequence($newInvoiceID) ->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}') - ->currencyCode($payment->currency_code) - ->currencySymbol(Currencies::getSymbol($payment->currency_code)) + ->currencyCode(strtoupper($payment->currency_code)) + ->currencySymbol(Currencies::getSymbol(strtoupper($payment->currency_code))) ->notes($notes); if (file_exists($logoPath)) { @@ -89,4 +89,3 @@ trait Invoiceable $user->notify(new InvoiceNotification($invoice, $user, $payment)); } } -