Member-only story
How to Integrate Stripe Payment Gateway in Laravel and VueJS
Are you looking to integrate Stripe Payment Gateway into your Laravel and VueJS application? You’ve come to the right place! In this story, I’ll share my experience of setting up and integrating Stripe into Laravel and VueJS application.
Prerequisites:
- Laravel and VueJS installed and set up
- Stripe account
Let’s get started!
Firstly, we need to install the Stripe PHP library via Composer. In your terminal, navigate to your project directory and run the following command.
composer require stripe/stripe-php
Next, we need to set up our Stripe API key. In your .env
file, add your Stripe API key and secret key.
STRIPE_KEY=pk_test_1234567890
STRIPE_SECRET=sk_test_1234567890
Note: Replace the keys with your own Stripe API keys.
In Laravel, we need to create a controller that will handle the Stripe charge. In your terminal, run the following command to create a controller.
php artisan make:controller ChargeController
Next, open up your ChargeController.php
file and add the following code.
<?php
namespace App\Http\Controllers;
use…