#praveen-soni_code

1 messages · Page 1 of 1 (latest)

opaque oceanBOT
#

👋 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.

modern oak
#

Hi

shadow wagon
#

hello! how can I help?

modern oak
#

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

shadow wagon
#

can you share the subscription schedule's id? the id has the prefix sub_sched

modern oak
#

I need to see on stripe for any customer

#

Please wait

#

sub_sched_1QXQsmLDVEnCy4YgjVe7rAbk

shadow wagon
#

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

modern oak
#

Yes but once I schedule the downgrade subscription
I want the upcoming invoice id

#

so that Admin can see later its invoice

shadow wagon
#

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

modern oak
#

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

shadow wagon
modern oak
#

Its not working
Can I create invoice for upcoming phase

shadow wagon
#

why is it not working?

modern oak
#

I was getting createPreview is not defined

#

or similar

shadow wagon
modern oak
#

$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
shadow wagon
#

the alternative is to just save the upcoming invoice data into your own DB, and load it from there

modern oak
shadow wagon
#

what are you trying to achieve here?

modern oak
#

I'm not getting the invoice bro

shadow wagon
#

what's the request id for when you retrieve the upcoming invoice? and what's the response you received?

modern oak
#

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

shadow wagon