#asommer12-Connect

1 messages · Page 1 of 1 (latest)

karmic pine
#

Sure, what is your issues?

flint wedge
#

hey there

#

so two questions:

#
  1. I've sent many invoices through Connect in Test mode this afternoon, and they are all still showing up in Draft status. I was under the impression these would close automatically after 1 hour. Am I missing something?
#

Here's a sample ID:

#

in_1KWVvIRStBrARgKUk7zZJ5tB

#
  1. I'm curious about the on_behalf_of parameter and transfer_data parameter. My company builds billing software, and I am hoping to send invoices to my Connected Account's Customers "on behalf of" the Connected Account.

It sounds like I need the on_behalf_of parameter, but I'm wondering about transfer_data. Is this field also required? If I want all funds to go to the Connected Account, do I need to specify anything?

#

I have a third question too about idempotency, but I'll wait til we get through these first two first

#

?

karmic pine
#

Sorry I am a bit stretched. Will look in a few mins

#

Looking at 1.

#

In my understanding it will be finalized after approximately 1 hour. If it's not, maybe your webhook doesn't respond to invoice.created event properly

flint wedge
#

I don't have any webhooks set up

#

i am looking in the dashboard

karmic pine
flint wedge
#

and in my dashboard it still shows as draft

#

I don't have any webhooks

karmic pine
#

Stripe waits an hour after receiving a successful response to the invoice.created event before attempting payment. If a successful response isn’t received within 72 hours, Stripe attempts to finalize and send the invoice.

flint wedge
#

Hold on

karmic pine
#

I think that's the gotcha

flint wedge
#

So can you elaborate on that?

#

I need to take additional action after an Invoice is created?

#

to move it out of draft status?

#

To be clear, there is no subscription here

#

This is a one-off invoice that I am creating

karmic pine
#

Yeah, but that's the same for normal Invoice about Webhook

#

To summarize: If Stripe fails to receive a successful response to invoice.created, then finalizing all invoices with automatic collection will be delayed for up to 72 hours. Responding properly to invoice.created includes handling all webhook endpoints configured for your account, along with the webhook endpoints of any platforms to which you’ve connected. Updating a subscription in a way that synchronously attempts payment (on the initial invoice, and on some kinds of updates) does not cause this webhook wait.

flint wedge
#

"includes handling all webhook endpoints configured for your account"

#

I don't have any webhooks configured

karmic pine
#

Yeah I think if you setup one, it will work properly

#

evt_1KWVvJRStBrARgKUzBwUADVy

#

This is your invoice.created event

flint wedge
#

And so what do I need to do when I get a webhook?

#

I need to call another API?

karmic pine
#

Basically you need one server to be able to respond to Stripe's event. We send events notifying actions happened in your Stripe account

flint wedge
#

Okay but one clarification

#

I just need to return a 200 to that webhook? Or I need to send another API

#

?

karmic pine
#

Just need to return 200/201 to that webhook event

#

Stripe only cares if we have received 200/201 or not

flint wedge
#

So basically, it is a requirement that I set up an invoice.createed webhook, listen for that, and reply 200?

#

And if I don't do that, then it will take 72 hours, but ultimately Stripe will eventually finalize the Invoice. Is that right?

karmic pine
#

yes

#

Looking at 2.

#

Yes you need transfer_data, when you do Invoice with Destination Charge. Normally you will need 2 parameters under transfer_data

#

amount, and destination

#

if you don't specify amount, the whole amount will comes to the Connected Account

flint wedge
#

"Destination Charge"

karmic pine
#

Like, you can create and Invoice of $100, specify a transfer_data of $80 to an acct_xxx

flint wedge
#

do I need to do that?

#

does on_behalf_ofautomatically make it a Destination Charge?

karmic pine
#

Then $20 will remain, and $80 goes into the Connected Account

flint wedge
#

I think my use case is simpler -- I just want the entire amount to go to my Connected Account (not my personal account)

karmic pine
#

No, Destination Charge means using transfer_data. on_behalf_of is an additional parameter on top of Destination Charge

flint wedge
#

okay

karmic pine
#

I think my use case is simpler -- I just want the entire amount to go to my Connected Account (not my personal account)

#

Sure, then just specify the destination

flint wedge
#

okay thank you

#

Final question

#

I am creating invoices with multiple line items

#

But regularly I'm seeing duplicates of those line items in the outcome

#

Is there a way to specify an idempotency key to ensure line items only get created once?

karmic pine
#

yeah I think idempotency key is usable to all POST request

#

so it should applied to Create Invoice Item API too

flint wedge
#

ah, what is that key? how do i specify it?

karmic pine
flint wedge
#

the Node SDK doeesn't include that automatically?

#

ah i guess it cannot

#

okay very helpful, thank oyu

karmic pine
#
stripe.charges.create({
  amount: 2000,
  currency: "usd",
  source: "tok_visa", // obtained with Stripe.js
  description: "My First Test Charge (created for API docs)"
}, {
  idempotencyKey: "9OPm9nHLsrRQVcjr"
}, function(err, charge) {
  // asynchronously called
});
#

There is an example here

flint wedge
#

perfect

#

thanks so much 👍

karmic pine
#

np and good luck!

flint wedge
#

one follow up

#

it's not clear from the docs whether in the Node library it's transfer_data or transferData -- any guidance?

#

ah, underscore

#

nvm, thank you

#

hold on

#

I actually have one final question

#

I just got this error:

#

The 'transfer_data[destination]' param cannot be set to your own account.

karmic pine
#

Yeah it should be a Connected Account

flint wedge
#

Does this mean that I'm supposed to EITHER

    transfer_data: {
      destination: ConnectedAccountId (body)
    }

OR

    stripeAccount: ConnectedAccountId (header)

but not both?

#

here's my request that threw an error

  const stripeInvoice: any = await stripe.invoices.create({
    customer: customer.stripeCustomerId,
    description: invoice.invoiceId,
    on_behalf_of: ConnectedAccountId,
    transfer_data: {
      destination: ConnectedAccountId
    }
  }, {
    stripeAccount: ConnectedAccountId,
    idempotencyKey: ABC
  });

karmic pine
#

You need the former

#

hmm

#

hold on

#

yeah you need the former

#

the latter is doing "Direct Charge"

#

Just remove stripeAccount: ConnectedAccountId,

flint wedge
#

hold on, this is contradictory to everything else I've heard

#

my goal, as the platform, is to make charges to my connected-account's customers

#

why would I use destination charges and not direct charges?

karmic pine
#

Yes, both Destination Charge and Direct Charge can do that. It depends on which Connected Account type you have. I will find the official guide. It will explain better than me

#

For Standard Account it's Direct Charge. For express/custom it's Destination Charge

flint wedge
#

perfect