#asommer12 - Connect

1 messages ยท Page 1 of 1 (latest)

buoyant fiber
#

Hello! What's up?

river prism
#

Hey Rubeus

#

I'll give you some context and then ask you two specific questions

#

I build billing software. On an arbitrary cadence, my company determines how much our customers ought to charge their customers. We generate invoice printouts, and then my customers manually create invoices on Stripe to charge their customers. Make sense?

#

My customers have asked me to automate the final part, so that I can charge their customers directly when that all happens

#

Stripe Connect seems like the right way to do this

#

So

#
  1. I'm looking at the Invoicing with Connect docs (https://stripe.com/docs/invoicing/connect#direct). In the dashboard, I am able to manually create one-off invoices. But I don't see anywhere in the documentation about how to create a one-off invoice programmatically. I'd need to define the line_items and amounts. Is there a way to do that?
#

That's the most important question, but I'll start typing out my follow-up too

buoyant fiber
river prism
#

Okay amazing. So if I have 4 line_items, I'd need to make 5 consecutive calls to Stripe -- 1 to create each line item, and then 1 to sweep them all up into an invoice? Is that the idea?

buoyant fiber
#

Yep!

river prism
#

Okay cool

#

Are you working for the next 45+ minutes?

#

I might hold off on my second question for a moment (which was a fallback plan) and try this first

#

Can I ping back here in 15-20 with follow ups please?

buoyant fiber
#

Yep, I'll be here for a while longer.

river prism
#

great, brb

#

thank you

#

okay beautiful

#

that worked

#

two follow-ups to that

#
  1. I see in my Stripe Dashboard that an invoice was created, but I don't see the pending invoice on the customer's account. Is that because it takes an hour for the Invoice to show up there? It will show up soon?
buoyant fiber
river prism
#
  1. I see that there are options for "automatically process invoice with payment on-file" versus "send invoice to customer." If the customer has a payment method on-file, great, then the invoice will process automatically. If the customer does not have a payment method on file, will the invoice FAIL? Or fall back to sending the customer an email?
buoyant fiber
#

I believe the Invoice will fail, but you should test it to make sure you understand exactly what will happen.

river prism
#

and then finally

  1. If I do not finalize the Invoice manually (if I let Stripe run its normal course), will the invoice eventually be sent to the customer? Or is "send invoice" something I need to manually trigger too?
buoyant fiber
#

If the Invoice is set to send_invoice Stripe will send it for you when the time comes, you don't need to explicitly trigger it (although you can using the API if you want).

#

Also note that Stripe does not send emails in test mode.

river prism
#

Amazing

#

Thank you

buoyant fiber
#

Happy to help!

river prism
#

Okay, one more alternate flavor of questions

#

Let's say I wanted to use Charges instead of Invoices

#

I would use a PaymentIntent

#

I built that out, and I was running a few tests, and I'm seeing some strange behavior perhaps you can help me with:

#

I created a PaymentIntent on a ConnectedAccount's Customer. The API succeeded, and I see it in the Dashboard

#

But I also see "Incomplete, The customer has not entered their payment method."

#

However, the Customer DOES have a Payment Method on file

#

Could you perhaps help me understand what might be going on here?

buoyant fiber
#

Can you give me the Payment Intent ID so I can take a look?

river prism
#

pi_3KWUMwRStBrARgKU0BrJRez1

#

You'll see several attempts there. I created a few which failed, then I added a Payment Method manually, and then I tried again (the most recent). But It doesn't seem to be finding the Visa ending in 1111

#

(a Test card)

buoyant fiber
#

Looking...

river prism
#

no rush, thank you

buoyant fiber
river prism
#

Okay

buoyant fiber
#

Payment Intents require you to specify a specific Payment Method, there's no such thing as a default Payment Method on a Customer for a Payment Intent.

river prism
#

so the payment method I'd like to default to payment-on-file -- is that not the default behavior?

#

Ohhhhhhhh

#

Okay that's good to know

buoyant fiber
#

You can specify one associated with the Customer, but you still have to specify it.

river prism
#

I see

#

And with Invoices that's not the case, correct? With invoices, if I set charge_automatically then it will use a default payment method on file, right?

buoyant fiber
#

For confirmation, that should ideally happen client-side while the Customer is on-session so they can handle any async steps, like 3D Secure or an async payment flow for non-card payments.

river prism
#

Right, there is no client-side interaction for my use-case

#

This is recurring billing that happens offline

buoyant fiber
#

Ah, okay, then you need to specify both off_session: true and confirm: true when making the API call.

river prism
#

Okay and if I do that, I **also ** still need to provide the payment_method ID right?

river prism
#

Okay amazing

#

Thank you

buoyant fiber
#

No problem!

river prism
#

This is super helpful

#

Let's leave this channel open for a few mins longer if you don't mind

buoyant fiber
#

Are these payments US and/or Canada only?

river prism
#

Not necessarily

buoyant fiber
#

Okay, so in order to minimize the chances authentication will be required for these off-session payments you need to make sure you're setting up the Payment Methods for future use. Are you doing that with a Setup Intent or anything like that now? Basically I'm asking how you're creating the Payment Methods in the first place?

river prism
#

Great question

#

I am not handling that part as the Platform

#

I am expecting my Connected Account to set that up

#

Is that abnormal?

buoyant fiber
#

No, that's not abnormal.

#

Just watch out for connected accounts not doing that properly and be prepared to answer their questions about higher-than-expected declines. ๐Ÿ™‚

river prism
#

And in that case, I would need to instruct my ConnectedAccount that they need to set up cards with off-session

#

right

#

Sounds like Invoicing might be cleaner for this use-case, right?

buoyant fiber
#

If you're using existing Payment Methods this applies to both Payment Intents and Invoices.

#

Invoices generate Payment Intents under the hood.

#

Payment Intents are a lower-level object in Stripe that allow you to charge a specific amount. Invoices are an abstraction built on top of Payment Intents to add functionality like line items and whatnot.

river prism
#

Right

#

So whichever route I choose, I will need to instruct my ConnectedAccounts to ensure that the PaymentMethods they collect are setup for off-session use

buoyant fiber
river prism
#

OR, I need to specify send_invoice on the invoice to avoid this risk

buoyant fiber
#

Yeah, sending the Invoice to the Customer will result in them being on-session when they pay and, thus, present to handle authentication or async flows.

river prism
#

Beautiful

#

That's good enough for me for now

buoyant fiber
#

If you do the off-session payments you'll need to watch out for declines due to authentication being required and in those cases bring the Customer online to try again while on-session.

river prism
#

My future optimizations would include using charge_automatically but only after I can ensure that my ConnectedAccounts set up their payment methods properly with off-session

#

Thanks so much @buoyant fiber

buoyant fiber
#

Sounds like a good approach! ๐Ÿ™‚

#

Happy to help!

river prism
#

Wait, one more question haha

#

This one is probably more simple

#

I have an invoice with 3 line items

#

I make 4 calls to Stripe:

  • create item
  • create item
  • create item
  • create Invoice
#

let's say the second call fails

#

When I try to re-create the invoice, how do I ensure that there aren't duplicates of the first line item in the resulting invoice?

#

Is there a good method for idempotency on the line items?

#

(Looking at docs as I type)

buoyant fiber
#

You can enable that, then perform a check after the Invoice is created to confirm everything looks good, then add missing items as needed to cover all your bases.

river prism
#

stripe.setMaxNetworkRetries(2);

This applies only for GET requests or POST too?

buoyant fiber
#

It applies to all requests.

river prism
#

amazing

#

thank you

buoyant fiber
#

@river prism Hello! I'm about to end my shift and was wondering if you had any remaining questions?

river prism
#

i do!

#

maybe I'm too late here haha

#

all good, I'll follow up with someone else