How to create subscriptions (using on_behalf_of parameter) with destination transfers for connected accounts?

Viewed 766

Our Goal

We have a platform, where we manage all customers, products and prices. Is it possible to have connected accounts receive payouts from subscriptions charged by the platform account? (Connected accounts can be in all regions).


We wish to add connected accounts, which can receive subscription payments. Ideal scenario is to have all charges settled on the platform account, and then transferred to connected accounts.

Option 1

From docs, the easiest is to use transfer_data[destination].

However, turns out, it's not possible if your connected accounts are from different regions. E.g. a connected account in the US, where as the platform is in Australia.

Option 2

Pass stripe_account header, but the problem here is that customers and prices need to belong to the connected account, which is not an option.

Option 3 (The only solution?)

Hence, the solution is to use a on_behalf_of=connected_account_id parameter, which is covered in the docs. The problem is that stripe.Subscription.create() API, doesn't have such parameter.

Has anyone successfully managed to create subscriptions, using on_behalf_of?

2 Answers

At the moment, Stripe doesn't officially support on_behalf_of on Subscription and the only official options available are the first 2 that you mentioned.

For option #3 it's part of a private beta that you could get access to. I'd recommend reaching out to their support team about this

Subscription create call doesn't support this but you could do it by directly setting the on_behalf_of attribute on an invoice created by the subscription. You can update the already created invoice by listening to "invoice.created" webhook event.

At your webhook :

if 'invoice.created' == event.type
  stripe_invoice = event.data.object # Stripe::Invoice
  Stripe::Invoice.update(
      stripe_invoice.id,
      {
        transfer_data: {
             destination: stripe_account #connected account ID
        },
        on_behalf_of: stripe_account #connected account ID
      },
      {
        api_key: ENV.fetch('STRIPE_SECRET_KEY'),
        stripe_version: ENV.fetch('STRIPE_API_VERSION')
      }
  )
end

You can also be sure that the invoice was of a subscription by checking the invoice type, and you will also find your subscription Id on the invoice object, which can be used to retrieve the original subscription object.

Please read: https://support.stripe.com/questions/sending-invoices-on-behalf-of-connected-accounts

Related