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 @@
Quantity | -Product | -Description | -Subtotal | -
---|---|---|---|
Quantity | +Product | +Description | +Subtotal | +
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) }} | +
Payment Methods:
- +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') }}
Subtotal: | -{{$product->formatToCurrency($product->price)}} | +{{ $product->formatToCurrency($product->price) }} | |
---|---|---|---|
Tax ({{$taxpercent}}%) | -{{$product->formatToCurrency($taxvalue)}} | +Tax ({{ $taxpercent }}%) | +{{ $product->formatToCurrency($taxvalue) }} |
Quantity: | @@ -123,7 +128,7 @@|||
Total: | -{{$product->formatToCurrency($total)}} | +{{ $product->formatToCurrency($total) }} |