rap2hpoutre/laravel-stripe-connect

This package is abandoned and no longer maintained. No replacement package was suggested.

v0.2.1 2018-01-25 09:26 UTC

This package is auto-updated.

Last update: 2024-03-29 09:10:57 UTC


README

Packagist Packagist Scrutinizer Code Quality

2024 Update 🎉

@simonhamp made a fork: https://github.com/simonhamp/laravel-stripe-connect. You should now use this one!

Previous readme

⚠️ Deprecated, then abandoned in 2019, looking for a competitor. See this reddit post.

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($token)
    ->amount(1000, 'usd')
    ->fee(50)
    ->from($customer)
    ->to($vendor)
    ->create();