Build and start your own marketplace by using the Stripe Connect API with PHP to process the payments between your platform, Connected accounts and Customers!
This script has been written to be easily modified to fit your very own needs so you can integrate Stripe Connect to your website in a white-label way (your users stay on your website and won’t have to leave on Stripe’s website to register, pay, etc). The code is written in the simplest possible way for you to understand how it works quickly, it’s also fully commented with every Stripe API function use having a link to its API documentation and other useful links when needed. Even if the design of the script doesn’t really matter here, you’ll be happy to know that it’s also responsive. The Stripe Connect API version is the latest to date and the script uses PHP 7, jQuery, Bootstrap 4 and MySQL 5. Please note that a MySQL database will be needed to run the script, using just one single table (simple, told you!).
All the instructions to install the script are in a “Read me” file, it will take just a few minutes for you to set it up and start testing it.
Once installed, you will get a welcome page with the links to five steps covering for your integration. The code for these steps is separated into 5 respective folders to keep things as clear as possible for you. The 5 steps are:
• Create an account: Full creation of Custom Connected accounts (the sellers/shops on your platform) with all of their details required by Stripe and the regulations of their own countries, as well as their bank accounts so they can receive the payouts from their sales on your platform. In the end of the onboarding process, your Connected accounts will be ready to start making business on your website.
• Create a customer: Creation of a customer (the buyers of products/services on your platform) with the needed details.
• Payment process: Create a payment intent using the best practices Stripe Connect requires, working both with “one-to-one” (one payment to one single account) and “one-to-many” (one payment to several accounts) methods. Then you can pay using a payment card and get the results of the payment via the included Webhook script so you can record the payment, send an email to the account(s), customer and the platform when a payment has been passed etc. The payment process supports Visa/Mastercard/American Express cards, covers the 3D Secure payments (which is a requirement in the European Union) and detects fake cards, insuffisant provisions, expired cards, …
• Refund process: Select a payment and do partial or full refunds from your accounts to the customers.
• Listing: A sort of dashboard/back office base, listing most of the information you might want to display on your platform that are retrieved from Stripe, including:
– List of all your Connected accounts
– Account page with their details (information, missing information, balance, bank accounts, payments, transfers, payouts)
– List of all your customers
– Customer page with their details (information, cards, bank accounts, payment intents, charges)
– Platform activity (list all the events involving the Stripe API on your platform)
– Platform balance (available/reserved/pending balance in all currencies, list of all the transactions on your platform)
– Platform earnings (explaining how to record and display those, as the Stripe API doesn’t allow to get them)
Just so you can quickly try the script, most of the inputs are pre-filled so you don’t have to fill them all when creating a test customer, for instance.
Be aware that the Stripe Connect API can take quite some time to fully understand, so don’t expect to integrate this script in two days and be all ready! This is not a WordPress plugin so be sure to have some time to run tests, read the code, modify it and learn from your mistakes when integrating the Stripe Connect API and/with this script.
Also, this script is meant to cover the most important needs a marketplace might have in general, but obviously cannot cover the very needs of your platform, so you will indeed have to spend time adapting it, adding or removing certain functionalities etc. See it as a solid structure for your house, the walls, electricity and plumbing is done and you still need to paint the walls with the colors you like, so don’t expect to move in in two hours after your purchase!
As I was working on creating this script, I thought it’d be useful to share a bunch of advices and useful information, which I included in a “Read me” file and in the code comments to save you some time understanding the script and how Stripe Connect and its API work, as well as where to find more information on specific points of your integration.
As specified in this file, I had to create this integration for a web project and as it took a lot of time to figure out everything and code everything in a right way (dealing with errors, making the whole thing user-friendly with some JavaScript/Ajax here and there, …), I thought it could be great to help other developers to save some time too, or in other words, to create the script that I would have loved to buy if it was available somewhere before I started this, so I could have saved a lot of time myself. Now this script exists, and I am a hundred per cent confident that you will save many many hours with this script if you need to integrate the Stripe Connect API to your website!
Please note that I am not a Stripe developper and am not affiliated to Stripe in any way, so I won’t answer any question on how Stripe and its API work! I do mention the best ways to get their help if you need (they are pretty reactive in my experience), it’s all in the “Read me” file.
I will maintain this script up to date when the Stripe API is updated and changes are needed in the code though, and will try my best to be reactive and do the needed corrections if someone reports a bug or security issue in the script. Everything works perfectly as far as I know, and as the Stripe API version used is set in the script, even if Stripe updates their API, there shouldn’t be any problem using this script for a good while… I’ve seen a comment from someone using a version of the script from 2014 and their script was still working perfectly in 2020. Of course, regulations can change, so mostly if your platform is based and/or make some business in the European Union, you will need to keep an eye on the changes required from time to time.
Enjoy this script and the free time you just saved by purchasing it!
CHANGELOG
2020-02:
– Original version of the script.
2021-05:
– The script has been updated to the latest Stripe Connect API (version 2020-08-27) and Stripe PHP Library (version 7.79.0).
– The support of fraudulent cards detection has been improved.
2022-01:
– Fixed an issue with the way tokens were created during the Connected Accounts onboarding process. This part has been entirely rewritten, the tokens are now created using the Stripe.js library rather than the PHP API. This is now a requirement for platforms based in France and only recommended (so far, at least) for other countries. This is a pretty major upgrade under the hood, so if you bought the script previously and want to integrate these changes, be sure to read the code in details.
– Added a mandatory “By continuing, you agree to our terms and the Stripe Connected Account Agreement.” line at the first step of account creation.
– Removed the Stripe API publishable keys from the external javascript files, so there’s no need to change it there too when implementing the code or switching from ‘test’ to ‘live’ mode.
– On the ‘Connected account’ and ‘Customer’ details pages in the listing part of the script, added the full array of data that can be retrieved from the API so you know everything you can get from the API.
– Removed most of the custom CSS classes previously created in favor of Bootstrap’s classes.
– The documentation of the Webhook file has been improved more with useful tips.
– Added a few more tips around the use of the API and Stripe Connect in general in the “Read me” file, including an example of how to update the information of a Connected account using tokens.
– Updated the PHP library for Stripe API to the latest version to date (7.107.0). The latest Stripe Connect API version being still ‘2020-08-27’.
– Minor corrections of the comments (corrected a few english mistakes, updated links to the right pages of the stripe connect api, additional clarity on a few things).
Source