Git Product home page Git Product logo

stephenjude / paystack-lite Goto Github PK

View Code? Open in Web Editor NEW
22.0 2.0 1.0 47 KB

Fastest Way To Setup Paystack Checkout Form In Your Laravel Application

Home Page: http://stephenjude.me/articles/paystacklite-fastest-way-to-setup-paystack-checkout-form-in-your-laravel-application

License: MIT License

PHP 100.00%
paystack payment-integration checkout checkout-form laravel payment paystack-lite

paystack-lite's Introduction

Latest Version on Packagist Build Status Quality Score GitHub license Total Downloads

# Paystack Lite - Use Paystack Checkout Form on the go. Paystack Lite creates a blade directive you can include in your views. This is the easiest integration of paystack checkout form for Laravel applications.

Installation

  1. Install PaystackLite with composer
composer require stephenjude/paystack-lite
  1. if you are using Laravel less than 5.4 Add Stephenjude\PaystackLite\PaystackLiteServiceProvider::class to the providers array in your config/app.php.

  2. Open your .env file and add your public key, secret key, customer default email and payment url like so:

PAYSTACK_PUBLIC_KEY=xxxxxxxxxxxxx
PAYSTACK_SECRET_KEY=xxxxxxxxxxxxx

Usage

Paystack-lite make use of blade directive to abstract away all javascript configurations for setting up paystack checkout forms.

Paystack Popup Example

Include the Blade Directive (@paystack) somewhere in your template before your main application JavaScript is loaded.

The @paystack blade directive creates payWithPaystack(amount, email, meta, onPaymentCompleted, onPaymentCancelled) JavaScript helper which takes five parameters. the amount, customer email, meta data, callback for payment completed and callback when checkout form is closed.

    var amount = 1000;
    var email = '[email protected]';
    var meta = { /* optional  meta data array */ }; 

    document.getElementById('paymentBtn').onclick = function() {
        //display checkout form
        payWithPaystack(amount, email, meta, onPaymentCompleted, onPaymentCancelled);
    };

    function onPaymentCompleted(response) {
        alert('payment completed!');
        console.log(resposne);
    }

    function onPaymentCancelled() {
        alert('payment cancelled!');
    }

Paystack Emebeded Example

Include the paystack embeded blade directive inside of your html container

    <div>
        @paystackEmbeded(1000, 'onPaymentCompleted', '[email protected]')
    </div>

Add your javascript callback function

   
    function onPaymentCompleted(response) {
        alert('payment completed!');
        console.log(resposne);
    }

Paystack Fluent APIs

This package makes use of bosunski/lpaystack package. So you can use all paystack fluent APIs provided in the package.

Usage

    use Stephenjude\PaystackLite\Facades\PaystackLite;


    /**
     * This gets all your transactions
     */
    PaystackLite::api()->transactions()->list();
    
    /**
     * This verifies a transaction with transaction reference passed as parameter
     */
    PaystackLite::api()->transactions()->verify($ref);

    /**
     * This  gets all your paystack customers.
     */
    PaystackLite::api()->customers()->list();

    /**
     * This  gets all the plans that you have registered on Paystack
     */
    PaystackLite::api()->plans()->list();

See the supported Paystack APIs here.

Changelog

Please see CHANGELOG for more information what has changed recently.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

License

The MIT License (MIT). Please see License File for more information.

paystack-lite's People

Contributors

stephenjude avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

uwascan

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.