Collect payments then pay out
This guide explains how to accept payments and move funds to the bank accounts of your service providers or sellers. For demonstration purposes, we’ll build a home-rental marketplace that connects homeowners to potential tenants. We’ll also show you how to accept payments from tenants (customers) and pay out homeowners (your platform’s users).
Prerequisites
- Register your platform.
- Add business details to activate your account.
- Complete your platform profile.
- Customize brand settings. Adding a business name, icon, and brand color is required for Connect Onboarding.
Set up StripeServer-side
Install Stripe’s official libraries to access the API from your application:
Create a connected account
When a user (seller or service provider) signs up on your marketplace, you must create a corresponding user Account (referred to as a connected account). You can’t accept payments and move funds to the bank account of your user without a connected account. Connected accounts represent your users in the Stripe API and collect the information required to verify the user’s identity. In our home-rental example, the connected account represents the homeowner.
Create an Express connected account and prefill information
Use the /v1/accounts
API to create an Express account and set type
to express
in the account creation request.
If you’ve already collected information for your connected accounts, you can prefill that information on the account object for the user and it won’t be collected again in the Connect Onboarding flow. Any information on the account can be prefilled, including company or individual information, external account information, and more.
Create an account link
You can create an account link by calling the Account Links API with the following parameters:
account
refresh_url
return_url
type
=account_onboarding
Redirect your user to the account link URL
The response to your Account Links request includes a value for the key url
. Redirect to this link to send your user into the flow. URLs from the Account Links API are temporary and are single-use only, because they grant access to the connected account user’s personal information. Authenticate the user in your application before redirecting them to this URL. If you want to prefill information, you must do so before generating the account link. After you create the account link for an Express account, you can’t read or write information for the account.
Don’t email, text, or otherwise send account link URLs directly to your user. Instead, redirect the authenticated user to the account link URL from within your platform’s application.
Handle the user returning to your platform
Connect Onboarding requires you to pass both a return_url
and refresh_url
to handle all cases where the user is redirected to your platform. It’s important that you implement these correctly to provide the best experience for your user.
You can use HTTP for your return_url
and refresh_url
while in test mode (for example, to test with localhost), but live mode only accepts HTTPS. Be sure to swap testing URLs for HTTPS URLs before going live.
return_url
Stripe issues a redirect to this URL when the user completes the Connect Onboarding flow. This doesn’t mean that all information has been collected or that there are no outstanding requirements on the account. This only means the flow was entered and exited properly.
No state is passed through this URL. After a user is redirected to your return_url
, check the state of the details_submitted
parameter on their account by doing either of the following:
- Listening to
account.updated
webhooks - Calling the Accounts API and inspecting the returned object
refresh_url
Stripe redirects your user to the refresh_url
in these cases:
- The link is expired (a few minutes went by since the link was created).
- The user already visited the URL (the user refreshed the page or clicked back or forward in the browser).
- Your platform is no longer able to access the account.
- The account has been rejected.
Your refresh_url
should trigger a method on your server to call Account Links again with the same parameters, and redirect the user to the Connect Onboarding flow to create a seamless experience.
Handle users that haven’t completed onboarding
A user that’s redirected to your return_url
might not have completed the onboarding process. Use the /v1/accounts
endpoint to retrieve the user’s account and check for charges_enabled
. If the account isn’t fully onboarded, provide UI prompts to allow the user to continue onboarding later. The user can complete their account activation through a new account link (generated by your integration). You can check the state of the details_submitted
parameter on their account to see if they’ve completed the onboarding process.
Enable payment methods
View your payment methods settings and enable the payment methods you want to support. Card payments, Google Pay, and Apple Pay are enabled by default but you can enable and disable payment methods as needed.
Before the payment form is displayed, Stripe evaluates the currency, payment method restrictions, and other parameters to determine the list of supported payment methods. Payment methods that increase conversion and that are most relevant to the currency and customer’s location are prioritized. Lower priority payment methods are hidden in an overflow menu.
Accept a payment
We recommend using Stripe Checkout, a prebuilt Stripe-hosted page, to accept payments. Checkout supports multiple payment methods and automatically shows the most relevant ones to your customer. You can also use the Payment Element, a prebuilt UI component that is embedded as an iframe in your payment form, to accept multiple payment methods with a single frontend integration.
Testing
Test your account creation flow by creating accounts and using OAuth.
Use test payment details and the test redirect page to verify your integration. Click the tabs below to view details for each payment method.
Disputes
As the settlement merchant on charges, your platform is responsible for disputes. Make sure you understand the best practices for responding to disputes.
Payouts
By default, any funds that you transfer to a connected account accumulate in the connected account’s Stripe balance and are paid out on a daily rolling basis. You can change the payout frequency by going into the connected account’s detail page, clicking the right-most button in the Balance section, and selecting Edit payout schedule.
Refunds
To issue a refund, go to the Payments page to identify the specific one you want to refund. Click on the payment and click Refund to issue a refund to the customer.