Adding custom parameters to create account via Stripe Connect API

In public_html/wp-content/plugins/hivepress-marketplace/includes/controllers/class-payout.php

If I add the following code to our child theme:

				// Create new account.
				$account = hivepress()->payout->stripe()->accounts->create(
					apply_filters(
						'hivepress/v1/components/stripe/create_account',
						[
							'type'             => 'express',
							'country'          => $vendor->get_country(),
							'email'            => $vendor->get_user__email(),
							'default_currency' => get_woocommerce_currency(),

							'capabilities'     => [
								'card_payments' => [ 'requested' => false ],
								'transfers'     => [ 'requested' => true ],
							],
							
							'tos_acceptance' => ['service_agreement' => 'recipient'],

							'business_profile' => [
								'name' => $vendor->get_name(),
								'url'  => hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor->get_id() ] ),
							],
						]
					)
				);

What is the best way to achieve setting tos_acceptance to recipient? We need this for international bank transfers when an account is created rather than being set to “FULL”. I won’t be touching the class-payout.php especially if we can create a code snippet in functions.php to handle this.

Thanks,
Tom

Please try this PHP snippet instead

add_filter(
	'hivepress/v1/components/stripe/create_account',
	function($args){
		$args['tos_acceptance']['service_agreement'] = 'recipient';
		return $args;
	},
	1000
);

Testing this now thanks Yevhen

-Tom

Hello everyone,

I have a minor update on the issue. If I onboard an account manually I’m able to do it and change the service agreement as you can see. But I had to fill in all the data manually on behalf of the “customer”. Usually clicking on +Create account and choosing which kind Custom/Standard/Express will generate an onboarding link that did not happen this time that’s why I had to manually fill.

Anyway, the account has been created correctly and funds have been transferred.

Ok Yevhen,

We’ve gotten to the bottom of this and we know what custom function we need now. We need a few things to be added to the code snippet in our functions.php. When I modify the class to look like this it works!

				// Create new account.
				$account = hivepress()->payout->stripe()->accounts->create(
					apply_filters(
						'hivepress/v1/components/stripe/create_account',
						[
							'type'             => 'custom',
							'country'          => $vendor->get_country(),
							'email'            => $vendor->get_user__email(),
							//'default_currency' => get_woocommerce_currency(),

							'capabilities'     => [
								//'card_payments' => [ 'requested' => true ],
								'transfers'     => [ 'requested' => true ],
							],
							
							'tos_acceptance' => ['service_agreement' => 'recipient'],
							
							'business_profile' => [
								'name' => $vendor->get_name(),
								'url'  => hivepress()->router->get_url( 'vendor_view_page', [ 'vendor_id' => $vendor->get_id() ] ),
							],
						]
					)
				);

We need a code snippet that will do the following:

  1. Change ‘type’ => ‘custom’ instead of ‘express’
  2. Add the tos_acceptance for ‘service_agreement’ => ‘recipient’ as you’ve already provided.
  3. Make the default_currency attribute NULL or remove it entirely like I have above commented out
  4. Remove card_payments attribute from the capabilities array like I have above commented out

Hopefully this is much easier for you to write rather than following this entire thread. If we can get a code snippet for the above 4 items we are all set with this and we can launch our product!

Thanks again,
Tom

Thanks for the details, I hope someone will share their experience of setting up the whole Stripe workflow because it seems to depend on the website owner and vendor countries of residence. Please try using the same snippet suggested above, you can remove or override any of the Stripe API request parameters this way, e.g.:

add_filter(
	'hivepress/v1/components/stripe/create_account',
	function($args){
		unset($args['default_currency']);

		return $args;
	},
	1000
);
1 Like

Much appreciated!

Thanks,
Tom

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.