#codefoot_api

1 messages · Page 1 of 1 (latest)

ruby flameBOT
#

👋 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/1354581574036754492

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

flat sage
#

Hi! Can you share an ID with me please so I can have a look?

brisk obsidian
#

As in the api request id or?

flat sage
#

Sure, or the Subscription Schedule ID or any other ID - just need something to start with.

brisk obsidian
#

GIve me a moment to get you a new example

#

Here's the sub ID. I did this all through workbench.
sub_1R72T5QayV4vikq1BpiKPoX0

Actions taken:

  1. Create new schedule
  2. Start date immediate
  3. schedule.default_settings.default_payment_method set to a payment method on the customer
  4. Create
  5. Check, invoice is in draft state
  6. Finalize invoice through workbench
  7. Invoice remains open with a weird message I haven't seen before
flat sage
#

Why are you using Schedules for this?

brisk obsidian
#

We have to use schedules for many other reasons

flat sage
#

Can you tell me more?

brisk obsidian
#

Monthly payment plan. Customer signs up to a subscriptio that is an annual commitment, paid monthly. Schedule. 12 phases.

#

Multi year subscription plans. Year 1 subscriber is on price 1, year 2, on price 2, year 3, etc.

#

The effort involved in creating the subscription then creating the schedule is a huge duplication that I'd prefer to avoid

flat sage
#

That's not how you do a monthly subscription - you only need one phase unless the price changes mid-year.

That is a fair point for annuals, assuming you know the future year prices ahead of time.

brisk obsidian
#

How do you do an annual subscription paid monthly?

#

I'm not talking a recurring monthly subscription - that is not what we need

flat sage
#

What is an annual subscription paid monthly?

#

That sounds like a monthly subscription with a different to me, no?

brisk obsidian
#

You and me both, but not to my client

#

They need to see 12 months commitment that can be programatically managed between their system and stripe, as well as produce unique financial reporting through Sigma

#

in any case, I'd like to understand my options.

Why does Stripe allow you to create a subscription using a schedule if you cannot charge for that subscription right away?

flat sage
#

You can, you just need to finalize it and request it be immediately paid via the API when you use a Subscription Schedule rather than a regular Subscription (which does generally try to take payment immediately).

Note
Unlike when you create a subscription directly, the first invoice of a subscription schedule with collection_method set to charge_automatically behaves like a recurring invoice and isn’t immediately finalized at the time the schedule’s subscription is created. The invoice begins in a draft status and is finalized by Stripe about 1 hour after creation.

This means that, for example, creating a charge-automatically subscription schedule with start_date=now also creates a subscription and an invoice in the draft status. This gives you a 1-hour window to make edits to the invoice. Later, the invoice is auto-advanced into the open or paid status depending on the outcome of the asynchronous payment attempt at finalization time.

From here: https://docs.stripe.com/billing/subscriptions/subscription-schedules#managing

brisk obsidian
#

Yeah read that earlier. I get finalizing. That leads to the example sub I shared. What do you mean by request it be immediately paid

flat sage
#

They need to see 12 months commitment that can be programatically managed between their system and stripe, as well as produce unique financial reporting through Sigma

If you can tell me more about their "programmatically managed [activities]" and "unique financial reporting", I might be able to provide some alternatives.

flat sage
brisk obsidian
#

Got ya, so:

  1. Do what I was doing
  2. Finalize invoice req
  3. Pay invoice req
#

I assume pay invoice req would fail if the invoice is in a draft state?

flat sage
#

I think /pay finalizes too; I can't remember at the moment and our docs aren't helping me.

brisk obsidian
# flat sage > They need to see 12 months commitment that can be programatically managed betw...

The concept can be likened to installments. I sign up for an annual commitment, paid monthly. As a customer, I see an outstanding balance. This balance is a calculation outside Stripe of iterations * price amount yada yada. The sigma side uses a combination of schedule data/subscription data to create unique journal entries related to accounts receivable and deferred revenue. Finally refund policy can be enforced programatically. They have typical monthly subscriptions as well. Rules are set around when the annual commitment monthly qualifies for refunds/how much depending on where they are in their schedule

#

It's an ugly use case to support. Schedule with 12 iterations was the best solution we could come up with.

flat sage
#

Ahhhh ok. 12 iterations and then end_behavior=cancel. Gotcha. Ya, that's about the right way to do what you want to do there at this point.

#
  1. Create new schedule with:
  • Start date now
  • schedule.default_settings.default_payment_method set to a payment method on the customer

Second bullet could also just be done using the Customer's invoice_settings.default_payment_method too.

  1. Get the invoice and finalize/pay it via the API

That's really all you need to do.

#

If you expand subscription.latest_invoice during the Create Subscription Schedule API call (i.e., step 1), you'll be able to get at the whole Invoice object at scheduleYouCreated.subscription.latest_invoice.

brisk obsidian
#

Thanks - appreciate this a lot

#

I'm off my work laptop right now so I'll implement sometime tomorrow.

#

Thanks!