#sajid_api
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/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.
- sajid_checkout-redirect, 5 days ago, 29 messages
- sajid_subscription-customprice, 5 days ago, 19 messages
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
Ah, the issue here is product_data. Schedules require a Product ID: https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases-items-price_data-product
You can create in-line Prices (with price_data) but can't create in-line Products with product_data
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?
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?
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.
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?
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?
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?
Invoice line items might change occasionally. but i want to say for every user it will be different.
Right, so one off invoices likely makes the most sense here
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.
By "Schedule will be different", do you mean some users may have monthly payments, others may have payments every year, etc, or something else?
like me describe in detail
The data differ for each user:
- line items
- prices
- frequency
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.
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?
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.
Okay, so these items/categories may not remain the same each week.
Yes.
I still think working with Subscriptions and Schedules may be overcomplicating this.
So what is solution for this?
edit all coming phases
Does the landlord also have the option to edit specific future weeks?
No specific weeks.
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
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.
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
so there will be seperate product for for each item. and multiple items for each user. would it be best approach?
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
and how will it refrence to specific price.
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
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.
So I need to create a product. And will enter amount in phase. So total will be three products. Rent, security and electricity. Right?
Like I have 12 iterations. Can I have options to edit for spefic iteration. Like adding more items or changing prices?
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
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.
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