GithubHelp home page GithubHelp logo

mariojgt / gateway Goto Github PK

View Code? Open in Web Editor NEW
1.0 1.0 1.0 1.5 MB

Payments gateways for laravel made simple, the aim of this package is integrate most relevants payments gateway in a very simple way.

License: MIT License

PHP 42.38% Blade 57.62%
payment laravel stripe payment-gateway gateway cashier gocardless paypal-laravel easy-to-use php

gateway's Introduction

image info

Laravel Gateway laravel 9 compatible

#composer require mariojgt/gateway

This is a Laravel package design to make checkout easy and clean to implement, avaliable integration (Stripe), in the future we going to have some more integrations with others gateways, the paypal is almost there

How to use

In you blade file do the following

  1. <x-gateway::pay_stripe /> This component will add all the javascript methods so we can generate a session and redirect the user.

  2. On you button you need to add this method RegenerateSessionAndRedirect

     <button onclick="RegenerateSessionAndRedirect()"
    	Pay with Stripe Example
    </button>

    This method will send a request back to your server and generate a key so we can use in the javascript checkout.

  3. in the config file you have the key stripe_session_generate you need to point that to one of your laravel controler, you can use get or post for this.

  4. Use this example code to generate you session

    use Mariojgt\Gateway\Controllers\StripeContoller;
    
    public function sessionGenerate(Request $request)
        {
            // Start the stripe class
            $stipeManager = new StripeContoller();
            // Cart example, you Must folow this stucture
            $cartItem = [
                [
                    'name'        => 'kit kat',
                    'description' => 'Kit kat product',
                    'images'      => ['https://www.kitkat.com/images/main-logo-snap.png'],
                    'amount'      => 500, // Amount in pence value * 100
                    'currency'    => config('gateway.currency'),
                    'quantity'    => 2,
                ],
            ];
            // Send the cart item so stripe can create a valid session
            $session      = $stipeManager->process($cartItem);
            // Return a stripe session so we can use in the front end to redirect the user
            return response()->json([
                'session' => $session->id,
            ]);
        }

    This code will return a json session that we can use in the javascript

  5. You Can also check the session status using

use Mariojgt\Gateway\Controllers\StripeContoller;
$stipeManager = new StripeContoller();
$session      = $stipeManager->checkSession('Session_id');

This will return the session information and the payment information.

Notes:

In Production disable the website demo buy changing the key value demo_mode to false in the gateway config file.

gateway's People

Contributors

craigrileyuk avatar mariojgt avatar

Stargazers

 avatar

Watchers

 avatar

Forkers

dsmdesign

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.