diff --git a/app/Http/Controllers/Admin/PaymentController.php b/app/Http/Controllers/Admin/PaymentController.php index 85425379..1ccee66c 100644 --- a/app/Http/Controllers/Admin/PaymentController.php +++ b/app/Http/Controllers/Admin/PaymentController.php @@ -24,6 +24,8 @@ use PayPalCheckoutSdk\Core\SandboxEnvironment; use PayPalCheckoutSdk\Orders\OrdersCaptureRequest; use PayPalCheckoutSdk\Orders\OrdersCreateRequest; use PayPalHttp\HttpException; +use Stripe\Stripe; + class PaymentController extends Controller { @@ -58,7 +60,7 @@ class PaymentController extends Controller * @param CreditProduct $creditProduct * @return RedirectResponse */ - public function pay(Request $request, CreditProduct $creditProduct) + public function PaypalPay(Request $request, CreditProduct $creditProduct) { $request = new OrdersCreateRequest(); $request->prefer('return=representation'); @@ -223,6 +225,76 @@ class PaymentController extends Controller return redirect()->route('store.index')->with('success', 'Payment was Canceled'); } + /** + * @param Request $request + * @param CreditProduct $creditProduct + * @return RedirectResponse + */ + public function StripePay(Request $request, CreditProduct $creditProduct) + { + \Stripe\Stripe::setApiKey('sk_test_51Js6U8J2KSABgZztx8QWiohacnzGyIlpOk48DfSoUWPW8mhqLzxcQ5B9a1Wiz8jCC4Xfp3QeBDTsuSU7hkXEUksW00JyN08hoU'); + + + + $request = \Stripe\Checkout\Session::create([ + 'line_items' => [ + [ + 'price_data' => [ + 'currency' => 'eur', + 'product_data' => [ + 'name' => $creditProduct->display, + 'description' => $creditProduct->description, + ], + 'unit_amount_decimal' => round($creditProduct->price*100, 2), + ], + 'quantity' => 1, + ], + [ + 'price_data' => [ + 'currency' => 'eur', + 'product_data' => [ + 'name' => 'Product Tax', + 'description' => $creditProduct->getTaxPercent() . "%", + ], + 'unit_amount_decimal' => round($creditProduct->getTaxValue(), 2)*100, + ], + 'quantity' => 1, + ] + ], + 'payment_method_types' => [ + 'card', + 'giropay', + 'ideal', + 'klarna', + 'sofort', + 'sepa_debit', + ], + 'mode' => 'payment', + 'success_url' => route('payment.PaypalCancel'), + 'cancel_url' => route('payment.PaypalCancel'), + ]); + + + + return redirect($request->url, 303); + } + + /** + * @return string + */ + protected function getStripeClientId() + { + return env('APP_ENV') == 'local' ? env('PAYPAL_SANDBOX_CLIENT_ID') : env('PAYPAL_CLIENT_ID'); + } + + /** + * @return string + */ + protected function getStripeClientSecret() + { + return env('STRIPE_SECRET'); + } + /** * @return JsonResponse|mixed diff --git a/resources/views/store/checkout.blade.php b/resources/views/store/checkout.blade.php index f2bce40a..19572afa 100644 --- a/resources/views/store/checkout.blade.php +++ b/resources/views/store/checkout.blade.php @@ -10,8 +10,9 @@
@@ -34,7 +35,8 @@

{{ config('app.name', 'Laravel') }} - Date: {{Carbon\Carbon::now()->isoFormat('LL')}} + Date: + {{ Carbon\Carbon::now()->isoFormat('LL') }}

@@ -44,23 +46,23 @@
To
- {{config('app.name' , 'Laravel')}}
- Email: {{env('PAYPAL_EMAIL' , env('MAIL_FROM_NAME'))}} + {{ config('app.name', 'Laravel') }}
+ Email: {{ env('PAYPAL_EMAIL', env('MAIL_FROM_NAME')) }}
From
- {{Auth::user()->name}}
- Email: {{Auth::user()->email}} + {{ Auth::user()->name }}
+ Email: {{ Auth::user()->email }}
Status
Pending
-{{-- Order ID: 4F3S8J
--}} + {{-- Order ID: 4F3S8J
--}}
@@ -71,20 +73,22 @@
- - - - - - + + + + + + - - - - - - + + + + + +
QuantityProductDescriptionSubtotal
QuantityProductDescriptionSubtotal
1{{$product->quantity}} {{strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type}}{{$product->description}}{{$product->formatToCurrency($product->price)}}
1{{ $product->quantity }} + {{ strtolower($product->type) == 'credits' ? CREDITS_DISPLAY_NAME : $product->type }} + {{ $product->description }}{{ $product->formatToCurrency($product->price) }}
@@ -97,7 +101,8 @@

Payment Methods:

- Paypal + Paypal

By purchasing this product you agree and accept our terms of service @@ -105,17 +110,17 @@

-

Amount Due {{Carbon\Carbon::now()->isoFormat('LL')}}

+

Amount Due {{ Carbon\Carbon::now()->isoFormat('LL') }}

- + - - + + @@ -123,7 +128,7 @@ - +
Subtotal:{{$product->formatToCurrency($product->price)}}{{ $product->formatToCurrency($product->price) }}
Tax ({{$taxpercent}}%){{$product->formatToCurrency($taxvalue)}}Tax ({{ $taxpercent }}%){{ $product->formatToCurrency($taxvalue) }}
Quantity:
Total:{{$product->formatToCurrency($total)}}{{ $product->formatToCurrency($total) }}
@@ -135,7 +140,14 @@
diff --git a/routes/web.php b/routes/web.php index 50f34b5a..4c323244 100644 --- a/routes/web.php +++ b/routes/web.php @@ -64,7 +64,9 @@ Route::middleware(['auth', 'checkSuspended'])->group(function () { Route::get('checkout/{creditProduct}', [PaymentController::class, 'checkOut'])->name('checkout'); Route::get('payment/PaypalSuccess', [PaymentController::class, 'PaypalSuccess'])->name('payment.PaypalSuccess'); Route::get('payment/PaypalCancel', [PaymentController::class, 'PaypalCancel'])->name('payment.PaypalCancel'); - Route::get('payment/pay/{creditProduct}', [PaymentController::class, 'pay'])->name('payment.pay'); + Route::get('payment/PaypalPay/{creditProduct}', [PaymentController::class, 'PaypalPay'])->name('payment.PaypalPay'); + Route::get('payment/StripePay/{creditProduct}', [PaymentController::class, 'StripePay'])->name('payment.StripePay'); + Route::get('users/logbackin', [UserController::class, 'logBackIn'])->name('users.logbackin');