DEV Community

Robert Look
Robert Look

Posted on

[Stripe payment] How To Integrate Stripe Payment Gateway In Laravel 8?

Stripe Payment Gateway Integration In Laravel 8 With example

Step 1: Install Laravel 8 App
Step 2: Install stripe Package
Step 3: Stripe Configuration
Step 4: Make Route
Step 5: Create Controller
Step 6: Create a Blade View file
Step 7: Run Development Server
Read More: [Stripe payment] How To Integrate Stripe Payment Gateway In Laravel 8?

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request;
use Session;
use Stripe;

class StripeController extends Controller
{
    /**
     * success response method.
     *
     * @return \Illuminate\Http\Response
     */
    public function stripe()
    {
        return view('stripe');
    }

    /**
     * success response method.
     *
     * @return \Illuminate\Http\Response
     */
    public function stripePost(Request $request)
    {
        Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
        Stripe\Charge::create ([
                "amount" => 100 * 100,
                "currency" => "usd",
                "source" => $request->stripeToken,
                "description" => "This payment is tested purpose phpcodingstuff.com"
        ]);

        Session::flash('success', 'Payment successful!');

        return back();
    }
}
Enter fullscreen mode Exit fullscreen mode

Top comments (0)