#derand1_best-practices
1 messages ยท Page 1 of 1 (latest)
๐ 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/1304094922038710326
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- derand1_webhooks, 20 hours ago, 18 messages
- derand1_best-practices, 2 days ago, 5 messages
I set my connected account payouts to weekly on tuesdays
Okay well then yeah you would check if the funds are available on or before Tuesday and that would be the next Payout then
There is no API that returns this specifically
Sometimes my users or myself modify the schedule, so displaiyng the next Tuesday isn't the most reliable
Sorry I should have added that in the prompt, that's what we have currently
Yeah you'll need to check on the current payout schedule of your Connected Account then
Like I said, there is no API that indicates the next payout date. Only when funds are available using the Balances API and the Balance Transaction API
So I would calculate it by fetching the Account object's [settings.payouts.schedule]?
Is there a timestamp I can use? Or do I have to extrapolate it from the intervals, anchors, etc
Correct -- you would use settings.payouts.schedule and then you have to extrapolate.
Got it thank you! That works for me.
I have another question that is pretty unrelated. Should I create another thread or is it okay if i ask you? It's about subscriptions, webhooks, and invoices.
Nope you can ask here
Gotcha. So our marketplace model goes like this:
- Customer pays upfront (we create a payment intent) and sets a start date for their reservation
- Subscription is created (using that payment intent) as a trial that ends on that start date
- We hold funds until the subscription trial ends, and their reservation begins.
- When 'invoice.created' event is sent to our webhook, we create a new invoice line item to cancel out the amount due (since the customer already paid earlier on) and transfer the customer's original payment to the Host (connect account) to stage for payout.
- Finally, we finalize the invoice.
This was written almost a year back and I believe it was to work around some of the limitations of React Native SDK. It's starting to cause problems because we couple a lot of crucial events within a single 'invoice.created'
Retries don't really work in the case of transfers failing because Stripe resends the 'invoice.created' event which causes the 'This invoice is no longer editable' error
Yeah that doesn't make much sense to me at all
First, why use a separate PaymentIntent up front and not just charge the initial amount on the Subscription itself?
The simplest thing to do here is to create a Subscription with a trial until the date that you want to start charging and then also add a one-time Price to that Subscription creation which charges for this reservation fee.
Mb, I'm blanking on the reason why we did this in such a confusing way. I recall it being related to not being able to capture funds at the time of creation and holding until the reservation starts.
Can you point me to the doc for adding a one-time price at the time of creation?
There isn't really a doc -- you just add a line item to your Subscription that is a one-time Price: https://docs.stripe.com/api/subscriptions/create#create_subscription-items
It is true though that you can't use manual capture here if that is the concern.
That said you can still just hold the funds in your platform and transfer them later to your Connected Account (assuming they are in the same region which it sounds like is true based on what you said before)
Ahh yeah, we collect payment method info & use a callback after customers click pay to create a payment intent
Then we capture it and use it to create a subscription
Is the capture asynchronous?
Like why use manual capture here?
Really you can collect the PaymentMethod and then create the Subscription and use the Subscription's PaymentIntent in this flow: https://docs.stripe.com/payments/accept-a-payment-deferred?platform=react-native&type=payment
(That didn't exist a couple years ago so might have been part of the reason you went this route originally, though I do think you still could have accomplished what you wanted with the intent-first flow too)
Oh I just realized why we needed manual capture. It's because we have a 'request' system where our Connected Accounts needed to accept reservations. We didn't want to capture PI's before that and have to deal with refunds.
Ah okay yeah that makes more sense.
So in that case I would just extend your trial until the first actual billing time. Instead of canceling out the amount on the initial Invoice
That could work, but we use that first invoice to know when to transfer funds to the Connected Account
Unless there's something else we can use?
Hmm
And we wanted to hold funds until the reservation's start date so we didn't have to deal with debiting the Connected Account if either party decides to cancel
Jesus no wonder I blanked out on this. More like I repressed it from the trauma
Both weekly and monthly options ๐ญ
Ah then that won't work
Well actually, it would work, but would require a lot of logic on your end to handle it
Hmm wait no it should be fine
Err no no nvm
lol sorry thinking through it
Would be complex -- would still require a cronjob and what not
Would not solve things
Yeah that was my original thought, but didn't want to deal with a cronjob ontop of all that compelxity already
Worst case, yeah I can do that. But our current impl. with invoice canceling is probably simplier.
Your other option is to use a $0 Price initially
So you would put the Sub on trial with a $0 Price. When you receive a customer.subscription.updated Event you would check if the status of the Sub changes from trialing to active. You would then transfer the funds and update the Sub to the $x Price to be charged going forward.
That would avoid you handling the invoice.created and having to cancel out things and the complexity there
Hmm that seems pretty good, but I'm worried about a scenario. We let our Host's update their rates for reservations. Let's say the Connected Account update their Price objects before the 'customer.subscription.updated' event, wouldn't that be a problem when trying to set the subscription to $X Price?
Yeah, so let's say a Customer reserves @ $100/month using Price Object #1
- We capture a payment intent for $100, create a subscription for $0, and save Price Object #1
- A few days later, 'customer.subscription.updated' triggers and we transfer funds & update the subscription price using Price Object #1 ($100/month)
What if in between 1 and 2, the Connected Account updates their rates? IIRC, you can't update a Price Object right? You can only delete/disable the old one and create a new one?
Sure you can't delete it but that doesn't matter at all. The only thing that matters is the Price of the Sub at the time of the first actual charge.
So if during that month the Connected Account changes their rate then you would just update the Sub to the new Price
As long as you turn off proration when you do these updates then you can update all you want with no affect on the Sub until the actual billing date.
We only want the new Prices to only apply to future reservations and honor rates at the time of reservation.
Unless I'm misunderstanding, this solution would be a problem right?
Oh then you would just need to track what the applicable Price is at time of reservation and update to that one.
So for instance you could set metadata on the Subscription when created to indicate that
Then check that metadata when you update
Oh ok, that's perfectly fine. Would I have to create a new Price object or can I just set an integer? IIRC subscriptions need one to update their Price right?