From 8a03a7b16b9a134f0f8ca4d5f27b85871cf39f1a Mon Sep 17 00:00:00 2001 From: IceToast <> Date: Sat, 14 Jan 2023 22:38:13 +0100 Subject: [PATCH] =?UTF-8?q?feat:=20=E2=9C=A8=20Create=20Invoiceable=20Trai?= =?UTF-8?q?t=20&=20Fix=20routing=20Extension?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Extensions/PaymentGateways/PayPal/index.php | 8 +++----- app/Extensions/PaymentGateways/PayPal/routes.php | 2 +- app/Traits/Invoiceable.php | 8 ++++---- 3 files changed, 8 insertions(+), 10 deletions(-) diff --git a/app/Extensions/PaymentGateways/PayPal/index.php b/app/Extensions/PaymentGateways/PayPal/index.php index 6e505b73..fe8958b3 100644 --- a/app/Extensions/PaymentGateways/PayPal/index.php +++ b/app/Extensions/PaymentGateways/PayPal/index.php @@ -1,5 +1,6 @@ $shopProduct->id, ]); event(new UserUpdateCreditsEvent($user)); - //only create invoice if SETTINGS::INVOICE:ENABLED is true - if (config('SETTINGS::INVOICE:ENABLED') == 'true') { - // use the createInvoice method that is defined in the Invoiceable trait - $payment->createInvoice($user, $payment, 'paid', $shopProduct->currency_code); - } + event(new PaymentEvent($payment)); + //redirect back to home return redirect()->route('home')->with('success', __('Your credit balance has been increased!')); } diff --git a/app/Extensions/PaymentGateways/PayPal/routes.php b/app/Extensions/PaymentGateways/PayPal/routes.php index 7ec92f81..bbafa314 100644 --- a/app/Extensions/PaymentGateways/PayPal/routes.php +++ b/app/Extensions/PaymentGateways/PayPal/routes.php @@ -3,4 +3,4 @@ use Illuminate\Support\Facades\Route; Route::get('payment/PayPalPay/{shopProduct}', [PaymentController::class, 'PaypalPay'])->name('payment.PayPalPay'); -Route::get('payment/PayPalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PaypalSuccess'); +Route::get('payment/PayPalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PayPalSuccess'); diff --git a/app/Traits/Invoiceable.php b/app/Traits/Invoiceable.php index a4c91d08..4618215e 100644 --- a/app/Traits/Invoiceable.php +++ b/app/Traits/Invoiceable.php @@ -14,7 +14,7 @@ use Symfony\Component\Intl\Currencies; trait Invoiceable { - public function createInvoice($user, $payment, $paymentStatus, $currencyCode) + public function createInvoice($user, $payment) { $shopProduct = ShopProduct::where('id', $payment->shop_item_product_id)->first(); //create invoice @@ -60,13 +60,13 @@ trait Invoiceable ->taxRate(floatval($shopProduct->getTaxPercent())) ->shipping(0) ->addItem($item) - ->status(__($paymentStatus)) + ->status(__($payment->status)) ->series(now()->format('mY')) ->delimiter("-") ->sequence($newInvoiceID) ->serialNumberFormat(config("SETTINGS::INVOICE:PREFIX") . '{DELIMITER}{SERIES}{SEQUENCE}') - ->currencyCode($currencyCode) - ->currencySymbol(Currencies::getSymbol($currencyCode)) + ->currencyCode($payment->currency_code) + ->currencySymbol(Currencies::getSymbol($payment->currency_code)) ->notes($notes); if (file_exists($logoPath)) {