#sajid_api

1 messages ยท Page 1 of 1 (latest)

dire hemlockBOT
#

๐Ÿ‘‹ 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/1288268561902604419

๐Ÿ“ 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.

tight fable
#

It dont allow me to pass the price but it asks to pass price id

#

const subscriptionSchedule = await stripe.subscriptionSchedules.create({
customer,
start_date: startDate, // Or specify a future start date
end_behavior: 'release', // Or 'cancel'
phases: [
{
items: lineItems,
iterations, // Number of billing cycles for this phase
billing_cycle_anchor: 'automatic',
discounts: couponId ? [{ coupon: couponId }] : undefined, // Updated to use discounts
metadata: {
invoiceNo,
// Add any additional metadata here
}
},
],
});

#

here is my code

woven kite
#

Hi there

#

Do you have a request ID?

tight fable
#

Yes

#

req_Vi0OBhiNkUBO6b

woven kite
tight fable
#

phases.items.price_data.product
string
Required
The ID of the product that this price will belong to.

#

do i need to create product in invoice whenever i create an invoice?

woven kite
#

I don't really understand your question. Subscription Schedules apply to Subscriptions. With Subscriptions, Stripe automatically creates Invoices.

Are you asking about Invoices for one-off (not recurring) prices?

tight fable
#

No, like my recurrsive schedules dont have subscription like structure. like it is multivendor tenant website. where each recurring invoice that lanslord create in my platform has different pricing and items based on line items like rent, security etc.

woven kite
#

Just to make sure I understand correctly, does this mean you're creating Schedules where each phase will create a new in-line price for what may be different amounts?

tight fable
#

Yes. it will be different for every tenant or it depends on lease. like it will be totally dynamic.

#

Is there way in stripe to do that?

woven kite
#

Hm, is there a particular reason for using Subscriptions in that case? The reason I ask is because Subscriptions typically use the same recurring price per billing period, with the occasional outlier (e.g., a user can add a one-off item to an invoice if a customer pays for some add-on during a given period)

#

Using Subscriptions and Schedules or having to update a Subscription Invoice every month/period seems like it's overcomplicating the issue. Would you be open to creating one-off Invoices instead for each payment?

tight fable
#

Invoice line items might change occasionally. but i want to say for every user it will be different.

woven kite
#

Right, so one off invoices likely makes the most sense here

tight fable
#

phases would have same line items might change over time. but i meant to say the schedule will be different for each user. based on property like its rent, seurity fee etc.

woven kite
#

By "Schedule will be different", do you mean some users may have monthly payments, others may have payments every year, etc, or something else?

tight fable
#

like me describe in detail

#

The data differ for each user:

  • line items
  • prices
  • frequency
woven kite
#

Okay, sure.

#

I think it would be best to discuss a specific example

tight fable
#

ok sure

#

like one tenant is renting a house:
has lineItems - rent, secuirty fee, electricity bill
has frequency - weekly
has prices - $500 rent, $200 security, $300 electercity bill

other tenant rent a house has:
has lineItems - rent, secuirty fee, electricity bill , maintaince fee, gas bill
has frequency - monthly
has prices - $400 rent, $300 security, $100 electercity bill, $50gas bill

likeweise each user will differ in this way

#

hope i clear the idea.

woven kite
#

I see, okay. Let's call the first tenant Tenant A. For Tenant A, will the weekly prices for $500 rent, $200 security, $300 electricity bill remain the same each week?

tight fable
#

In this case landlord has two options:
1 - edit current phase
2 - edit all coming phases (from now onward)

can add extra line item, and can change the prices for existing line item for tenant A.

woven kite
#

Okay, so these items/categories may not remain the same each week.

tight fable
#

Yes.

woven kite
#

I still think working with Subscriptions and Schedules may be overcomplicating this.

tight fable
#

So what is solution for this?

woven kite
#

edit all coming phases
Does the landlord also have the option to edit specific future weeks?

tight fable
#

No specific weeks.

woven kite
#

So a Schedule might only ever have two phases: the current phase and the second phase, which applies to all biling periods going forward?

#

The alternative to Schedules and Subscriptions is to continue to keep track of the item prices on your end and create one-off invoices at the start of each period. For Tenant A, this would mean creating Invoices on a weekly basis based on what the landlord has saved in your application for the rates for this particular tenant

tight fable
#

But I want to overcome the headache of cron job for checking due date and invoice date on daily basis to create invoices for users.

#

so i want to do it by stripe.

woven kite
#

If you're really set on using Schedules, you can still create one-off Prices using price_data for each item in a given phase but you'd still have to create Products separately. For the tenants you outlined above, you can create four Products, one for "Rent", "Security", "Electricity", Gas". For the Schedule for Tenant A, you can use phases.items.price_data to create the $500 price for Rent, and use the "Rent" Product ID as the value of phases.items.price_data.product

tight fable
#

so there will be seperate product for for each item. and multiple items for each user. would it be best approach?

woven kite
#

Let's be really clear about terms here since I want to make sure we're on the same page

#

A Product can be the parent for multiple/many Prices. This tracks with what you've outlined above: you can represent "Rent" as a single Product with many Prices under it. You can also represent "Security" as a single Product with many Prices under it

tight fable
#

and how will it refrence to specific price.

woven kite
#

So for Tenant A: $500 rent, $200 security, $300 electricity bill

You'd have a Phase with three items, each item with a different price. You can either create a Price for each of the amounts above first and pass the Price ID when you create the Schedule: https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases-items-price

Or you can create the Price and the Schedule at the same time by using price_data: https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases-items-price_data

dire hemlockBOT
woven kite
#

So let's say you create:
prod_123 for Rent
prod_456 for Security
prod_789 for Electricity

If you decide to create one-off Prices using price_data (because you know the prices for these items may change next week), you would add three items. For each item, phases.items.price_data will vary based on the amount and the product. So, for the Rent item, phases.items.price_data.product will be prod_123 and phases.items.price_data.unit_amount will be 50000. For the Security item, phases.items.price_data.product will be prod_456 and phases.items.price_data.unit_amount will be 20000, etc.

tight fable
#

So I need to create a product. And will enter amount in phase. So total will be three products. Rent, security and electricity. Right?

gaunt panther
#

๐Ÿ‘‹ taking over here

#

Yes, correct

tight fable
#

Like I have 12 iterations. Can I have options to edit for spefic iteration. Like adding more items or changing prices?

gaunt panther
#

You would represent the changes on the phases. Each phase you can change the prices on its item

#

I strongly encourage to test in in Test mode. You can use Billing Test Clocks to simulate the time advancement

tight fable
#

Because I don't know that if any change would happen in future

#

Ok I will test it tomorrow please don't lock this thread.

gaunt panther
#

We would need to lock when we switch staff. Feel free to reopen a new thread when you comeback, it will directly link to this