In this article, we explain how to integrate the Stripe Connect payment gateway into on-demand applications using the Stripe PHP library. Stripe Connect is commonly used in marketplace and on-demand platforms where payments need to be split between the platform and service providers.
What are On-Demand apps?
On-demand applications deliver services to customers through independent contractors or service providers who are paid via the platform. In many cases, the platform’s brand is central to the entire transaction. Rather than acting as a simple software provider, the platform manages pricing, ensures service quality, handles customer support, and oversees payments.
For example, in an on-demand service app, pricing is usually set by the platform. Although the service itself is delivered by a third party, the platform controls the user experience and payment flow from start to finish.
Understanding Stripe Connect Custom Accounts
When building an on-demand application with Stripe Connect, you typically need to create Custom accounts on behalf of your service providers. With Custom accounts, Stripe does not directly interact with your contractors. Instead, the platform is fully responsible for managing all required information and compliance.
This means the platform must:
Handle all identity verification requirements
Set up bank accounts for contractor payouts
Ensure contractors agree to platform terms and services
Integrating Stripe Connect With On-Demand Apps in PHP
1. Download the Stripe PHP Library
Start by downloading the latest Stripe PHP library. For this tutorial, version 6.30.5 is used.
Using Composer:
Install the library via PHP Composer and create a configuration file to store your Stripe credentials.
After installation, add your Secret Key and Publishable Key to the config file:
require_once('vendor/autoload.php');
$stripe = [
"secret_key" => "********",
"publishable_key" => "*******",
];
\Stripe\Stripe::setApiKey($stripe['secret_key']);
2. Creating Stripe Accounts for Service Providers
Once you have collected the required contractor information, create a new Stripe account for each service provider.
require_once('./config.php');
$account = \Stripe\Account::create([
'country' => '{Country}',
'type' => '{custom | express}',
'email' => '[email protected]',
'requested_capabilities' => ['platform_payments'],
'business_profile' => [
'url' => '{Business URL}',
],
'business_type' => 'individual',
'individual' => [
'first_name' => '{First Name}',
'last_name' => '{Last Name}',
'address' => [
'city' => '{City}',
],
'dob' => [
'day' => '{Day}',
'month' => '{Month}',
'year' => '{Year}',
],
'ssn_last_4' => '{SSN Last 4}',
],
'tos_acceptance' => [
'date' => time(),
'ip' => $_SERVER['REMOTE_ADDR'],
],
]);
For additional optional parameters, refer to Stripe’s official documentation:
https://stripe.com/docs/api/accounts/create
3. Adding a Bank Account for Payouts
To enable payouts, you must attach an external bank account to the newly created Stripe account. This allows Stripe to transfer funds directly to the service provider.
$account = \Stripe\Account::retrieve('{Stripe Account ID}');
$account->external_accounts->create([
'external_account' => '{Bank Account Parameters}',
]);
You can find the complete list of supported parameters here:
https://stripe.com/docs/api/external_account_bank_accounts/create
4. Processing Payments to Contractors
To pay contractors, process the charge on your platform account and specify the destination parameter. This identifies the Stripe account that should receive the funds.
$charge = \Stripe\Charge::create([
'amount' => '{Amount}',
'currency' => '{Currency}',
'source' => '{Card Token}',
'destination' => '{Contractor Account ID}',
'application_fee' => '{Platform Fee}',
]);
This setup allows your platform to deduct its commission while transferring the remaining amount to the contractor.
For further details, visit:
https://stripe.com/docs/recipes/on-demand-app
Conclusion
Stripe Connect provides a robust and scalable solution for handling payments in on-demand and marketplace applications. By properly managing custom accounts, bank payouts, and destination charges, platforms can deliver a seamless and secure payment experience for both customers and service providers.
If you are planning to integrate Stripe Connect into your on-demand application, feel free to contact The Right Software for professional implementation and support.


