How to integrate Stripe payment in laravelDash

Hello laravel enthusiasts, welcome back. Here I am going to discuss on something very exciting. You will know how to integrate stripe payment gateway in laravelDash .

WHY STRIPE ?

There are so many payment gateways available, one of the most popular gateways is PayPal, but Stripe has some advantages over PayPal — simple, hassle free, easier integration, setup, maintenance and seamless checkout experience. Moreover integrating stripe with laravel is a breeze.

We just need a payment form which collects card information like card number, expiry date and a CVC code. When these details are sent to stripe it validates and returns a token which is used to process the payment.

WHAT STRIPE IS MISSING

As much as we love Stripe, nothing is ever perfect. One of the features we always yearn for would be the ability to use coupons for single charges. Whilst Stripe does support coupons, you can only apply these to a customer or a plan, but not a charge. This means that if you want to integrate a traditional e-commerce system (eg. selling individual products) then you cannot integrate Stripe’s coupon system against checkout transactions. In order to achieve this you are recommended to handle the coupons yourself, which is not ideal as it definitely isn’t simple when all things are considered. However we have actually found a creative way to apply coupons to single charges — more on that in another post!

Getting started with Stripe

  • First, we need to register with stripe, go to stripe and register yourself there.
  • Now get the public and private keys from your account which are provided in your account settings.
  • Make sure you set your stripe account as a test account so that real transactions does not occur.

Create the Laravel application

we assume that you have been able to set up your development environment. There are two ways to install Laravel project

  • Via Laravel Installer
  • Via Composer Create-Project

I will be using via composer to create new project

composer create-project --prefer-dist laravel/laravel StripeDemo

Install and Configure laravelDash

LaravelDash is super easy to install. After creating your new Laravel application you can include the laravelDash package with the following command:

composer require yal/laraveldash

LaravelDash will automatically register its service provider if you are using Laravel >=5.5. If you are using LaravelDash with Laravel 5.3 or 5.4, add LaravelDash’s service provider in your application’s config/app.php file:

/*
* Laravel dashboard Service Provider
*/
\Yasser\LaravelDashboard\DashboardServiceProvider::class,

Next, you need to publish the laravelDash configuration file , generate symbolic link and Running Migrations:

php artisan LaravelDash:install

Defining Relationships

Database tables are often related to one another. For example, a blog post may have many comments, or an order could be related to the user who placed it. Eloquent makes managing and working with these relationships easy. so go to App\User.php and add UserRelation

<?php

namespace App;

use Illuminate\Notifications\Notifiable;
use Illuminate\Foundation\Auth\User as Authenticatable;
use Yasser\LaravelDashboard\Traits\UserRelation;

class User extends Authenticatable
{
use Notifiable,UserRelation;

}

To see it, you need to start a web server on your development machine. You can do this by running the following command:php artisan serve and then head to http://localhost:8000/Checkout

Thanks for reading! you can support the laravelDash project directly by r giving it a star on github