Code Monkey home page Code Monkey logo

laravel-stripe-connect's Introduction

Laravel Stripe Connect

Packagist Packagist Build Status Scrutinizer Code Quality

Marketplaces and platforms use Stripe Connect to accept money and pay out to third parties. Connect provides a complete set of building blocks to support virtually any business model, including on-demand businesses, e‑commerce, crowdfunding, fintech, and travel and events.

Create a marketplace application with this helper for Stripe Connect.

Installation

Install via composer

composer require rap2hpoutre/laravel-stripe-connect

Add your stripe credentials in .env:

STRIPE_KEY=pk_test_XxxXXxXXX
STRIPE_SECRET=sk_test_XxxXXxXXX

Run migrations:

php artisan migrate

Usage

You can make a single payment from a user to another user or save a customer card for later use. Just remember to import the base class via:

use Rap2hpoutre\LaravelStripeConnect\StripeConnect;

Example #1: direct charge

The customer gives his credentials via Stripe Checkout and is charged. It's a one shot process. $customer and $vendor must be User instances. The $token must have been created using Checkout or Elements.

StripeConnect::transaction($token)
    ->amount(1000, 'usd')
    ->from($customer)
    ->to($vendor)
    ->create(); 

Example #2: save a customer then charge later

Sometimes, you may want to register a card then charge later. First, create the customer.

StripeConnect::createCustomer($token, $customer);

Then, (later) charge the customer without token.

StripeConnect::transaction()
    ->amount(1000, 'usd')
    ->useSavedCustomer()
    ->from($customer)
    ->to($vendor)
    ->create(); 

Exemple #3: create a vendor account

You may want to create the vendor account before charging anybody. Just call createAccount with a User instance.

StripeConnect::createAccount($vendor);

Exemple #4: Charge with application fee

StripeConnect::transaction()
    ->amount(1000, 'usd')
    ->fee(50)
    ->from($customer)
    ->to($vendor)
    ->create(); 

laravel-stripe-connect's People

Contributors

rap2hpoutre avatar

Watchers

James Cloos avatar Damir Grgic avatar

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.