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)) {