简体   繁体   中英

How to use Stripe payouts with customer invoices

I have a question about how to implement proper payouts for my system/platform.

Let me explain a little further. I have a platform like Lyft, but instead of creating and issuing charges right after each ride. I'm creating invoice items, so that the rider is only charged once every invoice billing cycle(ex. every 2 weeks). Now, I understand there is no destination id for an invoice or invoice item using Stripe. So I need to tell Stripe somehow what funds need to go to the driver. How do I do that? It seems like the method would be to create a Stripe payout with the destination as the drivers bank account id. But after attempting this with both the drivers external acount id and the bank account id, Stripe threw an exception saying 'No such external account exists acct_123456ABCD'

Would the method I described above be the correct way to implement this? Or is there a better way or more prescribed way?

FYI - To understand why I'm creating invoice items, instead of instant charges immediately after a ride, it's because the charges for my service are all very small ($1.00-$3.00), so to avoid a Stripe flat fee of $.30/charge I'm aggregating them into an invoice, where there will be only one flat fee per billing cycle.

Thanks for any help.

For ex purposes I'll include an example of what I'm doing below. First I create an invoice item, then I create a payout.

            var invoiceItemOptions = new StripeInvoiceItemCreateOptions()
            {
                Amount = tipPricing.GetTotalAmountCharged(),
                Currency = "USD", //defaultCard.CurrencyCode,
                CustomerId = '12334567',

                Metadata = new Dictionary<String, String>() { { "EventId", 123 } }
            };

            var invoiceItemService = new StripeInvoiceItemService();
            StripeInvoiceLineItem invoiceItem = invoiceItemService.Create(invoiceItemOptions);
            StripeResponse invoiceResponse = invoiceItem.StripeResponse;

            ////////////////////////////////////////////////////////////////////////

            var payoutOptions = new StripePayoutCreateOptions()
            {
                Amount = tipPricing.GetTotalDestinationAmount(hasBeenChargedThisMonth), 
                Currency = "USD",
                Destination = bankAccount.ExternalAccountId, //bankAccount.AccountId,
                Metadata = new Dictionary<String, String>() { { "EventId", 123 } }
            };
            var payoutService = new StripePayoutService();
            StripePayout payoutCharge = payoutService.Create(payoutOptions);
            StripeResponse payoutResponse = payoutCharge.StripeResponse;

Payouts are intended to happen on the Connected Account's Balance -> Bank Account, rather than from your Platform to the Connected Account's Bank Account.

You've got at least two choices for funds flows here:

  1. You could run the Invoices (or even a $0 subscription with a two week billing cycle) on your Platform. You could listen for webhooks when invoice.payment_succeeded , then move the funds to the destination connected account using a Transfer , see https://stripe.com/docs/connect/charges-transfers . From the Connected Account's balance it will pay out to their bank account, or you can initiate a Payout (if on manual payouts, https://stripe.com/docs/connect/payouts#using-manual-payouts )
  2. You could create an Invoice Items / Invoices or a Subscription directly on the Connected Account. This gets slightly tricker as you will need to remit the fee for your platform, but you can do that with Application Fees, see https://stripe.com/docs/connect/subscriptions#working-with-invoices

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM