Code Monkey home page Code Monkey logo

laravel-stripe-connect's Introduction

Laravel Stripe Connect

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(); 

laravel-stripe-connect's People

Contributors

chinleung avatar rap2hpoutre avatar vool avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  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  avatar  avatar  avatar  avatar  avatar

laravel-stripe-connect's Issues

Require Example for Better Understanding.

Hello @rap2hpoutre

I would suggest providing some examples other than just showing the code,

StripeConnect::transaction($token)
    ->amount(1000, 'usd')
    ->from($customer)
    ->to($vendor)
    ->create(); 
  1. What is the $token about? Where should I retrieve the token? From STRIPE_KEY or STRIPE_SECRET?
  2. The $customer and $vendor are emails or texts? As you mentioned, $customer and $vendor must be User instances. Assuming I do not have the knowledge of OOP, what is User instance? Is that referring to an Object or an Array or anything?

Thank you for developing this package. :D

Create a trait for users

It could be great with a trait for User.

Something like Connectable, Chargeable+Payable. Then we could do:

$client->transaction()->amount(1000, 'usd')->to($vendor)->create();

Or:

$vendor->transaction()->amount(1000, 'usd')->from($client)->create();

from customer to company

Hello,

Currently both $customer and $vendor needs to be User instances. Could it be possible to have something else than User instance?

In my project that would be Company instance

Saved card is not updated

Saved card is not updated, even if a new token (for a new card, let's say user changer her card number) is generated. It should be updated.

Need Better Documentation Please. :)

This looks very interesting. But, Iโ€™d suggest making the documentation a bit better, with more explaination especially about the arguments being passed. For example, what is $token? What is $vendor? An App/User object? Or its own object? An ID? or, what?

Thank you.

Only single payments?

I need the ability to do subscriptions. Possible with your code? Im thinking the idea is to create a product under the vendors stripe connect account and then the user subscribes to that product. Thoughts?

Migration failing in 5.8

The migration seems to be failing in Laravel 5.8,

Migrating: 2017_11_24_094130_create_stripes_table

   Illuminate\Database\QueryException  : SQLSTATE[HY000]: General error: 1215 Cannot add foreign key constraint (SQL: alter table `stripes` add constraint `stripes_user_id_foreign` foreign key (`user_id`) references `users` (`id`))

Probably related to the changes to Migrations & bigIncrements

installation problem

Hi i received this error when i run composer command for install package. please guide me on it. thanks

Your requirements could not be resolved to an installable set of packages. Problem 1 - Installation request for rap2hpoutre/laravel-stripe-connect ^0.2.1 -> satisfiable by rap2hpoutre/laravel-stripe-connect[v0.2.1]. - rap2hpoutre/laravel-stripe-connect v0.2.1 requires stripe/stripe-php ^5.0 -> satisfiable by stripe/stripe-php[v5.0.0, v5.1.0, v5.1.1, v5.1.2, v5.1.3, v5.2.0, v5.2.1, v5.2.2, v5.2.3, v5.3.0, v5.4.0, v5.5.0, v5.5.1, v5.6.0, v5.7.0, v5.8.0, v5.9.0, v5.9.1, v5.9.2] but these conflict with your requirements or minimum-stability. Installation failed, reverting ./composer.json to its original content.

How does create vendor work?

How does StripeConnect::createAccount($vendor); work? What all is included in that $vendar variable and does it send the user to the proper stripe.com connect page in order to setup their express account and link their banking info, etc? The docs are a bit sparse for your code, but I would really like to take advantage of it if I can.

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.