Wordpress
How to set up and assign payments to multiple Stripe accounts in WooCommerce
How can I use Google Core Web Vitals to optimize my WordPress
Divi increases the speed of your visual layout
How to collapse and expand text at will within content in Wordpress
How to modify Astra theme settings for pages and posts in batch instead of one by one
How to organize meetings with Zoom video calls from a WordPress website
How to set a minimum and maximum order in your WooCommerce store
How to change the order of Divi submenu items
How to remove all Divi shortcodes when changing themes
How to auto link to WooCommerce product tabs from short description
How to remove JavaScript to reply to comments in WordPress if you don't need it
How to add a custom message when paying in WooCommerce according to the selected country
How to fix critical WordPress error
How to turn off the default animation on Divi image galleries
Do you remember that we already figured out how to set up multiple PayPal accounts in WooCommerce? Well, by popular demand, today we are going to see how to set up multiple Stripe accounts in WooCommerce.
Stripe has become a really attractive payment platform, and thanks to free plugins like the one proposed in the WooCommerce installation itself, configuring it is as simple as adding the secret key and the publishable key, production or tests, in the WooCommerce settings
But there is only one field, general for all transactions in the online store, not one per user.
Now fortunately there are ways that we can switch Stripe accounts, either programmatically, under what conditions, by product ID, etc.
How to map different Stripe accounts based on product with code
In this code example we are going to see how to use multiple Stripe accounts conditionally, if there is a specific product ID in the cart. The code looks for a product ID in the order and switches Stripe keys if it matches that ID.
This only works when there is only 1 product, so you may have to prevent more than 1 product from being added to the cart, additionally. This can be done easily in the inventory tab of the product data
function ayudawp_id_producto( $id ) {
$product_cart_id = WC()->cart->generate_cart_id( $id );
$in_cart = WC()-<cart->find_product_in_cart( $product_cart_id );
if ( $in_cart ) return true;
return false;
}
add_filter( 'wc_stripe_params', 'ayudawp_stripe_clave_publicable', 9999 );
function ayudawp_stripe_clave_publicable( $params ) {
if ( ! ayudawp_id_producto( 12345 ) ) return $params;
$params[ 'key' ] = 'pk_live_................';
return $params;
}
add_filter( 'wc_stripe_payment_request_params', 'clasesordenador_clave_publicable_condicional', 9999 );
function ayudawp_clave_publicable_condicional( $params ) {
if ( ! clasesordenador_id_producto( 12345 ) ) return $params;
$params[ 'stripe' ][ 'key' ] = 'pk_live_................';
return $params;
}
add_filter( 'woocommerce_stripe_request_headers', 'clasesordenador_clave_privada_condicional', 9999 );
function ayudawp_clave_privada_condicional( $headers_args ) {
if ( ! ayudawp_id_producto( 12345 ) ) return $headers_args;
$headers_args[ 'Authorization' ] = 'Basic ' . base64_encode( 'sk_live_..........' . ':' );
return $headers_args;
}
You must add the code to the functions.php file of the active theme or to a customization plugin, as you prefer.
Different Stripe account per seller
Another, more advanced possibility is to use a multi-vendor system, in which each vendor authorizes payments from the marketplace through Stripe Connect and automatic payments to their respective account.
This is easy to configure with plugins such as WooCommerce MultiVendor / MarketPlace, where you must initially connect the Stripe Connect gateway as administrator and select it as the gateway for payments to sellers in the plugin settings.
In addition, each seller must connect through Stripe Connect with their own Stripe account so that automatic payments can be activated.
This can be done in the administration area or on the page of your user account.
Once the above is done, each seller will automatically receive payments, once the previously defined commission has been satisfied, in their own Stripe account, automatically.
As you have seen it is not only possible to use multiple Stripe accounts in WooCommerce but there are several ways to address this need, I hope I have helped you.
Date update on 2021-02-16. Date published on 2021-02-16. Category: Computer class Author: Oscar olg Fuente: ayudawp