#asommer12-Connect
1 messages · Page 1 of 1 (latest)
hey there
so two questions:
- 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
- I'm curious about the
on_behalf_ofparameter andtransfer_dataparameter. 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
?
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
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.
Hold on
I think that's the gotcha
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
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.
"includes handling all webhook endpoints configured for your account"
I don't have any webhooks configured
Yeah I think if you setup one, it will work properly
evt_1KWVvJRStBrARgKUzBwUADVy
This is your invoice.created event
You would want to start setup Webhook. Starting from here: https://stripe.com/docs/webhooks
Basically you need one server to be able to respond to Stripe's event. We send events notifying actions happened in your Stripe account
Okay but one clarification
I just need to return a 200 to that webhook? Or I need to send another API
?
Just need to return 200/201 to that webhook event
Stripe only cares if we have received 200/201 or not
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?
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
"Destination Charge"
Like, you can create and Invoice of $100, specify a transfer_data of $80 to an acct_xxx
Then $20 will remain, and $80 goes into the Connected Account
I think my use case is simpler -- I just want the entire amount to go to my Connected Account (not my personal account)
No, Destination Charge means using transfer_data. on_behalf_of is an additional parameter on top of Destination Charge
okay
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
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?
yeah I think idempotency key is usable to all POST request
so it should applied to Create Invoice Item API too
ah, what is that key? how do i specify it?
the Node SDK doeesn't include that automatically?
ah i guess it cannot
okay very helpful, thank oyu
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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
np and good luck!
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.
Yeah it should be a Connected Account
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
});
You need the former
hmm
hold on
yeah you need the former
the latter is doing "Direct Charge"
Just remove stripeAccount: ConnectedAccountId,
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?
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
perfect