#praveen-soni_code
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/1327179310146256907
📝 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.
- praveen-soni_webhooks, 3 days ago, 10 messages
Hi
hello! how can I help?
I'm implementing subscription downgrade
$stripeSubscription = \Stripe\SubscriptionSchedule::update(
$schedule->id,
[
'phases' => [
[
'items' => [
[
'price' => $schedule->phases[0]->items[0]->price,
'quantity' => $schedule->phases[0]->items[0]->quantity,
],
],
'start_date' => $schedule->phases[0]->start_date,
'end_date' => $schedule->phases[0]->end_date,
],
[
'items' => [
[
'price' => $user_selected_service->stripe_price_id,
],
],
'start_date' => $schedule->phases[0]->end_date,
],
],
]
);
$invoice = \Stripe\Invoice::upcoming([
'subscription' => $subscription->id,
]);
Invoice is not generating for next phase
can you share the subscription schedule's id? the id has the prefix sub_sched
I need to see on stripe for any customer
Please wait
sub_sched_1QXQsmLDVEnCy4YgjVe7rAbk
so the subscription schedule is set to start the first phase on Jan 18 - this means that the first invoice will be created on Jan 18
Yes but once I schedule the downgrade subscription
I want the upcoming invoice id
so that Admin can see later its invoice
I'm not sure I understand, why do you want the upcoming invoice id? At any point in time that your Admin wants to view the upcoming invoice, you would probably want to make an API request to retrieve the upcoming invoice because it's possible that there are changes that affects the upcoming invoice
Downgrade subscription is scheduled and I'm not getting its invoice like I'm getting for normal subscription
In my admin, I'm showing the client payment history
Where i'm showing the invoice
okay, I think what you'll probably want instead is https://docs.stripe.com/api/invoices/create_preview
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
you can use https://docs.stripe.com/api/invoices/retrieve to retrieve the preview invoice object (the preview invoice id has the prefix upcoming_in)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Its not working
Can I create invoice for upcoming phase
why is it not working?
if you've tested, can you share the corresponding request id? it'd look like req_xxx [0]
[0] https://support.stripe.com/questions/finding-the-id-for-an-api-request
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
create preview is only available on stripe-php v14.3.0 or later
$schedule = \Stripe\SubscriptionSchedule::create([
'from_subscription' => $currentSubscription->stripe_id,
]);
$stripeSubscription = \Stripe\SubscriptionSchedule::update(
$schedule->id,
[
'phases' => [
[
'items' => [
[
'price' => $schedule->phases[0]->items[0]->price,
'quantity' => $schedule->phases[0]->items[0]->quantity,
],
],
'start_date' => $schedule->phases[0]->start_date,
'end_date' => $schedule->phases[0]->end_date,
],
[
'items' => [
[
'price' => $user_selected_service->stripe_price_id,
],
],
'start_date' => $schedule->phases[0]->end_date,
],
],
]
);
$invoice = \Stripe\Invoice::upcoming([
'subscription' => $subscription->id,
]);
if ($invoice) {
$invoiceId = $invoice->id ?? 'Pending'; // No invoice yet
}
$newSubscription->stripe_invoice_no = $invoiceId
the alternative is to just save the upcoming invoice data into your own DB, and load it from there
Correct me if I am doing wrong here
what are you trying to achieve here?
I'm not getting the invoice bro
what's the request id for when you retrieve the upcoming invoice? and what's the response you received?
May be its null for upcoming invoice for schedule
As its invoice is not yet generated
Before its get activated
Please be there i'm going for lunch break
ah yeah, you should use https://docs.stripe.com/api/invoices/upcoming#upcoming_invoice-schedule instead
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.