#mas-usequeuecom_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/1354873611906846782
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi! Your current solution works; are you having issues with it?
No issues, was trying to find a better and fool-proof way to add this. Also, if we add the cancel_at to be 12 months into the future (so Date.now + 12.months) this would successfully end the subscription after their last 12 month payment, right? Or will there be a proration given it's not exaclty the same cancel_at datetime?
It could include a proration in theory, ya. Fair point. This might be a better approach: https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#installment-plans
Ignore the name - it's the model/approach you want for what you're doing here.
I could also disable proration right
๐ค
So to make sure i understand it correctly, instead of adding a cancel_at to the subscription, we'd instead do the code below after the subscription is created. but based on the code below, how does it know which subscription to do this to? Ito only takes in the customer_id and customer could purchase more than one item.
Or
Does this modify the product price to now always be an installment? So whenever a client buys that subscription, it'll always end after 12 months automatically?
Stripe::SubscriptionSchedule.create({
customer: '{{CUSTOMER_ID}}',
start_date: 'now',
end_behavior: 'cancel',
phases: [
{
items: [
{
price: '{{PRICE_ID}}',
quantity: 1,
},
],
iterations: 12,
},
],
})
Got it!
One thing of note is that when you do that, Stripe does not automatically attempt payment of rhe first invoice immediately; it treats it like a recurring invoice and waits an hour.
You can override that though by calling the Pay Invoice API though.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Okay just checked the docs and to make it work for a specific subscription after checkout i'll need to pass in from_subscription and it'll do it to that subscription. So the code below should successfully automatically cancel the subscription after 12 months.
Stripe::SubscriptionSchedule.create({
customer: CUSTOMER_ID,
from_subscription: SUB_IDNUMBER,
end_behavior: 'cancel',
phases: [
{
items: [
{
price: PRICE_IDNUMBER,
quantity: 1,
},
],
iterations: 12,
},
],
})
Decided to go with below and seems to work exactly how we want. Thanks for the help!
cancel_at = Time.current + service_price_pay_over_month.pay_over_time_months.months
cancel_at_unix = cancel_at.to_i
Stripe::Subscription.update(
subscription.id,
{
cancel_at: cancel_at_unix,
}
)
There we go. ๐ You're welcome! ๐