Use Multiple Stripe Accounts with WooCommerce

Sometimes a business will have a need to utilize multiple Stripe accounts for processing payments. It could be that orders for one country should be routed to a specific account while ones for the rest of the world go to a separate one. The issue here is that the official WooCommerce Stripe gateway only supports a single account. How could we override this to add multi-account support?

Disclaimer: Please make sure to thoroughly test your code! There could always be unintended side-effects, especially with selecting the correct conditions. This is intended for developers who are comfortable accepting the risks associated with custom code. If it’s not set up properly, it could cost you revenue. By using the code in this blog, you accept all responsibility for any issues or errors you run into.

When I first looked at this, it seemed like we should just extend the WC_Gateway_Stripe class to create new gateways for our separate accounts. One downside is this approach would require a change to the core WooCommerce Stripe gateway’s code. So that’s a mark against this method already.

Another option would be to use a filter that I hadn’t encountered before, pre_option_{$option}. Essentially this can be used to modify the retrieval of any WordPress option, including the Stripe gateway. To access it, we use pre_option_woocommerce_stripe_settings.

I wanted a simple test to see if my idea would work, so I decided to use the current user ID as a condition to select between different Stripe settings. To facilitate this, I set up my Stripe settings as I normally would. Then I ran this snippet one time to copy the settings to a new row in the database:

$original_options = get_option( 'woocommerce_stripe_settings' );
update_option( 'woocommerce_stripe_one_settings', $original_options );

After that, I updated the settings for my second Stripe account. The I ran the snippet again but this time saved them to woocommerce_stripe_two_settings. This gave me two distinct sets of Stripe account settings in the database to work with. To swap them out based on the user, I used this snippet:

add_filter( 'pre_option_woocommerce_stripe_settings', 'ijab_select_stripe_account_settings' );
function ijab_select_stripe_account_settings( $settings ) {

    if ( 1 === get_current_user_id() ) {
        return get_option( 'woocommerce_stripe_one_settings' );
    return get_option( 'woocommerce_stripe_two_settings' );


For testing, I installed the User Switching plugin and created a second admin account. This new account should see the setting for Stripe Two while the original admin account will see Stripe One. I switched to the second account and opened up the Stripe settings. Here’s a demo of me switching the logged in account while viewing the settings:

It works! I verified that the account keys are also updating when I make the switch too. We can also use the pre_update_option_woocommerce_stripe_settings filter to allow us to make changes to either account directly in the settings screen. Here’s how that could look:

add_filter( 'pre_update_option_woocommerce_stripe_settings', 'ijab_update_specific_stripe_account_settings' );
function ijab_update_specific_stripe_account_settings( $settings ) {

    if ( 1 === get_current_user_id() ) {
        return update_option( 'woocommerce_stripe_one_settings', $settings );
    return update_option( 'woocommerce_stripe_two_settings', $settings );


At checkout, I was able to create orders for both accounts and the payments were sent to the correct Stripe accounts!

This is a method I’m currently exploring. One of the keys is going to be finding conditions that will be consistently applied as expected. These options are loaded a lot by WP so we want to make sure the conditions make sense in every possible context.

Again, use this code at your own risk. It’s offered without guarantee or warranty but hopefully will get you pointed in the direction of the solution you need.

Leave a Reply

%d bloggers like this: