#dan_api

1 messages · Page 1 of 1 (latest)

brazen marshBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1215326852902555648

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

old burrowBOT
dire radish
#

I couldn't add as much information to that popup as I needed to.

But basically, the deposit is taken with Stripe Checkout when the customer accepts a quote. The quote is accepted and an invoice is generated automatically.

mellow pecan
#

source_transaction really only works for amounts less than or equal to the source transaction passed

dire radish
#

I see, am I maybe doing things a bit wrong here then?

Should the deposit be being paid off the invoice instead of being a seperate transaction?

#

We're a new startup, so there's no cleared funds in our account yet, so I can't make the payment to our repairer, I used the source_transaction to make sure the transfer was done automatically.

mellow pecan
#

Just curious, why do you need to do the transfers separately? Why not do destination charges?

dire radish
#

I'm not sure what that is, I thought it would have been straightforward enough to make the transfer to the repairers connected account once the customer paid the invoice

mellow pecan
#

Things can get complicated when you handle transfers yourself

#

Destination charges are really the recommended flow

#

Separate charges and transfers are only recommended if you have a specific usecase

dire radish
#

But I think the transfer amount will always be larger than the source_transaction becuase of the deposit

mellow pecan
#

Well you'd specify transfer_data in the deposit too

#

So they'd be separate transfers technically

#

But my recommendation is to do the above flow if possible

#

Otherwise, you'll need to wait for your account balance to have the proper funds for transfer

#

Or just do 2 separate transfers yourself

dire radish
#

I'm not charging the repairer's connected account, I'm sending them money. I'm sending them the money the customer paid but keeping a platform cut

#

How long does it usually take for funds to be available for transfer?

mellow pecan
dire radish
#

By the way, all of this worked in Stripe's test environment, this is why I'm confused

dire radish
mellow pecan
#

Yeah let me know if that flow doesn't work for you for some reason

#

But it'll massively simplify things

#

You won't need to worry about transferring yourself

#

It'll be handled automatically

dire radish
#

Does that mean that the repairer will see what we take as a cut though? We've tried to stay away from that

mellow pecan
#

No

#

You can specify how much is transferred to them

dire radish
#

Okay, and we would use the application fee, to keep our cut?

mellow pecan
#

No

dire radish
#

Sorry

mellow pecan
#

You'd just keep whatever amount you don't transfer them

#

The idea is you specify exactly how much out of the total to transfer them

#

Recommend reading the guide

#

The connect account only sees what you transfer them

dire radish
#

Okay, thank you for your time

mellow pecan
#

No problem. Let us know if that doesn't work for you

#

We can help you come up with a different solution

#

But I always recommend destination charges if possible over separate charges and transfers

#

It makes things so much easier

dire radish
#

I'm just trying to work out how the customer finishes and pays the invoice

#

As right now, we send them the invoice hosted url

mellow pecan
#

Do you not want them to pay that way?

#

It's the same param

dire radish
#

Sorry, I'm just really confused as I thought I had it working, so I'm trying to get it right in my brain.

So, in Stripe via the API, we create a quote and it's sent to customer
Customer accepts the quote and pays a deposit via the Stripe checkout
When the quote is marked as accepted the invoice is auto generated by Stripe

#

Is all the above to stay the same?

mellow pecan
#

Yeah that would all work the same

#

The only thing that's different here is you no longer have to worry about transfers

#

Again, recommend reading the guide

dire radish
#

Okay, I think I've got it right, thanks so much for your patience

mellow pecan
#

No problem

dire radish
#

Actually, By the time the charge is made, it would only be for the remainder of the invoice minus the deposit, which has nothing to do with the invoice, so the repairer would always get £35 less on that paymentintent charge

#

So if the customer paid £35 deposit and their bill was £190, their final charge would be £155 and that would go to the repairer, when the repairer was due £190

#

Does that mean, I still need to do customer transfers becuse of the deposit messing things up?

mellow pecan
#

So the transfer would be less than the total payment intent amount?

dire radish
#

In this scenario that failed today.

The job cost the customer £190
The customer had already paid £35 deposit
The repairer in this case was getting the whole amount of £190

But in normal cases we would not normally be giving them the whole amount, this job was quoted wrong.

Usually we would have kept £60 of the £190 and send £130 to the connected account.

mellow pecan
#

Yeah I mean if transfer is <= to the payment intent amount it shouldn't fail with source trasnfer

dire radish
#

We need to keep the deposit in case the repairer doesn't show or the job is cancelled

mellow pecan
#

But based on your original message, it's no surprise that this failed

dire radish
#

So when the customer comes to pay (so long as things are quoted correctly)

I could send them a link to my platform which creates a checkout session, can I pass the invoice through the checkout session or payment for the invoice that already exists and use the transfer_Data on the payment intent to go to the connected account?

#

Again I apologise, I can only imagine this is infuriating

mellow pecan
#

Not sure I understand the question

dire radish
#

So, I get that instead of making a charge then doing transfers, instead I can make a payment intent with part of the amount going to the connected account, so let's say I now have created that payment intent, how do I present this to the customer, to pay it? Would I create a checkout session for the customer with this payment intent?

#

My thoughts were that I could send them a link to my platform which auto redirects to Stripe checkout for them to pay

#

Instead of waiting for them to pay the invoice, listening for webhooks, then making a transfer int eh code

mellow pecan
#

You can do it direclty in checkout

#

No need to create a payment intent

#

transfer_data can be easily inserted into your current flow

old burrowBOT
dire radish
#

Okay, so then how does the invoice get marked as paid? I now have my customer coming back to the site, a checkout session is created with payment_intent.transfer_data which will send part of this to my connected account, but I still have the invoice which was generated from the quote which will still remain open

left sorrel
#

Hello codename_duchess has to step out so I am catching up here...

dire radish
#

Okay, thanks codename_duchess for your time

#

Sorry, I know I'm coming across dumb here, I'm just a little confused, I think it's becuase I've set up the flow all wrong.

#

Hi Pompey

#

Realise it's not in your scope, I'd just be massively grateful if you could assist me on a top level flow or what I might be doing wrong

left sorrel
#

No worries not dumb questions at all. So the current question is how does the invoice that is generated from a quote? If so, do you have the ID of an invoice that I can check?

#

Apologies, more threads than I realized. If that isn't an accurate summary, can you summarize your open questions for me?

dire radish
#

No problem yea, this is the invoice ID from today: in_1OqvMwIzvUgZFm3P9UeIpxaN

#

I'm moving stuff around so that instead of making a transfer via the API after the customer has paid that invoice, instead, I'm going to send the customer a link to our platform which redirects the customer to a Stripe Checkout session. This session will have a payment_intent.transfer_data with the amount we want to give the repairer and their connect ID.

#

But, after that's done, there'll be an open invoice still around, how do I mark that invoice as paid, when it was techinically paid in the checkout session.

#

Have I made that make sense? 🤦‍♂️

left sorrel
#

I'm actually surprised if you are seeing that behavior. Do you have the ID of a checkout session that this happened with? When Checkout Sessions generate an email as a receipt for the payment, the invoice status should already be paid instead of open.

For in_1OqvMwIzvUgZFm3P9UeIpxaN, that invoice was created with a payment_behavior of charge_automatically (I can check, but I think it gets that from the quote). So when that invoice finalized, Stripe automatically charged the customer's default payment method.

dire radish
#

Sorry, I'm complicating things, the above is what I plan to do, what happened in the case of that invoice, is what I currently think I'm doing wrong.

Right now, the invoice is created off the back of a quote the customer accepted at the start of the flow.

#

That invoice was paid via the hosted invoice page.

#

But codename_duchess propsed that instead of making transfers, use payment intents and move some of the amount to the connected account which makes sense and seems cleaner.

#

But regardless of either, in my new way of thinking of doing this, if I send the customer to a stripe checkout to pay the final balance, there's still going to be an invoice open, becuase I've sent the customer through a checkout session and not to a hosted invoice payment page

left sorrel
#

I just tested in test mode and the invoice is created with a status of paid. So you should be good there

#

And yeah, destination charges definitely sound like a good fit here. They are more or less an automated way to do separate charges and transfers. So the same results (and you will still need to make another transfer if you want to send 190 while only charging 135), but simpler overall.

dire radish
#

When you say the invoice is created with the status of paid, is that an invoice created by the checkout session? If so, this is where I'm confused. I already have an invoice before this stage as it was created when the customer accepted the quote.

#

It's an invoice with a credit note of £35 for their deposit which we took

#

The final amount of this invoice is what I had planned to charge in the checkout session for the final payment from the customer, but I'm unsure how to make that invoice paid.

left sorrel
#

Ah gotcha, can you tell me more about why you want to use Checkout and the Quote here? You are right that that solution would leave an open invoice, in which case you could just cancel the invoice. But I have a feeling that we can make this simpler. What specific functionality from each are you looking to utilize here?

dire radish
#

So the quote is created so that we can send to our customers on a pdf.

The checkout I was going to use so that I can send that payment_intent.transfer_data so that I can make the transfer from the final payment into the connect account

left sorrel
#

Quotes actually do have a transfer_data parameter as well. So you can definitely make destination charges while only using the Quote and the Invoice that that generates. https://docs.stripe.com/api/quotes/create#create_quote-transfer_data-destination
When you say PDF, I assume you mean the Quote PDF from before the user accepts? If so, the Quote is likely the way to go. If you only need a PDF for the receipt, you can use Checkout and tell it to generate an invoice when the payment is done https://docs.stripe.com/api/checkout/sessions/create#create_checkout_session-invoice_creation

dire radish
#

We don't know which connected account the transfer is going to be made to until after the quote is accepted.

#

So I wouldn't be able to pass transfer_data on quote creation

#

Can this field be updated on a quote once I we have that data?

left sorrel
#

Ah apologies I missed that, then you definitely will want to stay with the separate charges and transfers flow that you are already working with. Destination charges can only have their destination on creation. Not knowing the destination until after the payment is a classic use case for SC&C

dire radish
#

No, so the flow is:

User submits car damage
We generate a quote (which is immediatley finalised)
Quote is sent to customer
Customer accepts quote (invoice is created)
Customer pays £35 deposit via checkout session
Repairer (with connect account) is assigned
Repairer carries out the work
Repairer marks work as complete
Invoice is finalised
Transfer is made to connect account
Hosted invoice payment URL is sent to user

#

That's how it is now ⬆️

#

So, what I could do, instead of doing the transfer on the webhook when the invoice is paid, I could update the quote with transfer_data when we know the connect account id and remove the transfer I do in the webhook.

left sorrel
#

Do you find out the connected account after the quote is accepted but before the payment is actually made?

dire radish
#

Correct, yeah

#

The payment can't be made until we know where it's going to

left sorrel
#

Gotcha, so transfer_data can only be set before the invoice is finalized or before the Checkout Session is created. If you won't always know where the funds are going by then, SC&C is the way to go.

#

And again, I do think it may be worth using just Checkout or just the Quote and its Invoice for simplicity here. You can use both but you'd need an extra step to delete the extraneous open invoice

brazen marshBOT
dire radish
#

Okay, I think by adding the transfer_data to the quote when I have it is the way to go. I'll just make sure that there's never a case whereby we're transferring more that what's on the quote.

I need to pay one of our connect accounts, but the funs aren't available to send yet, how long does this usually take? Their our first user and I don't want them to think we're witholding their money.

flint vessel
#

Hello! I'm taking over and catching up...