#kennyjack_best-practices

1 messages ยท Page 1 of 1 (latest)

upper turretBOT
#

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

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

alpine marlin
#

$payload = [
"customer" => "cus_xxxx"
"schedule" => "sub_sched_xxxx"
"schedule_details" => [
"phases" => [
[
"start_date" => 1745988567
"end_date" => 1777524567
"items" => [
[
"price" => "price A-a"
"quantity" => 1
]
]
]
[
"items" => [
[
"price" => "price C"
"quantity" => 1
]
]
"iterations" => 12
]
]
]
]
Invoice::upcoming($payload);

#

When i check the response, it take into account of the price A-a with price C.
The correct outcome i want to achieve is (price C - price A - proration) $300 - $100 - proration amount

wheat iris
#

hi there!

alpine marlin
#

Hello

#

Is anything I need to explain further?

wheat iris
#

Upcoming invoice is a preview of the next invoice. That means it could contain both the proration items for the change you make and also the amount for the next month. To only see the proration, you have to inspect the lines of the upcoming invoice and only sum up the ones that are marked proration:true.

alpine marlin
#

Is there another way to do it?
Because have a schedule is very strict. You can't update existing schedule.

When I not include my existing schedule in schedule_details.phases which is price A-a, it will throw me an error

wheat iris
#

You can't update existing schedule.
what do you mean by this? you can update an existing schedule

alpine marlin
#

With above my code, it will always return me the price C amount $300, and there is no poration

alpine marlin
#

With above my code, did you know why it will always return me the price C amount $300, and there is no proration?

wheat iris
#

it's when you call the upcoming invoice endpoint?

#

can you share the Subscription ID (sub_xxx)?

alpine marlin
#

Let me know if you need further info or the actual code. Thanks

wheat iris
#

and what's the reponse you get when you call the upcoming invoice endpoint?

upper turretBOT
#

๐Ÿง‘โ€๐Ÿ’ป How to format code on Discord

Inline code: wrap in single backticks (`)

This:

The variable `foo` contains the value `bar`.

Will turn into this:

The variable foo contains the value bar.

Code blocks: wrap in three backticks (```)

Also, you can specify the language after the first three backticks to get syntax highlighting.

This:

```javascript
function foo() {
return 'bar';
}
```

Will turn into this:

function foo() {
  return 'bar';
}```

Notes about **code blocks**:
- Specifying the language is optional (e.g., you can omit `javascript` in the example above)
  - If you don't specify the language you won't get syntax highlighting
- When you're inside a code block (after you type \`\`\`) the `Return`/`Enter` key will add a new line instead of sending your message
  - Once you end the code block `Return`/`Enter` works normally again

You can [read more about message formatting on Discord's website.](https://support.discord.com/hc/en-us/articles/210298617)
alpine marlin
#

since the message too long, i'm not allow to send it on discord. I've attached the response

upper turretBOT
worn ledge
#

Hey! Taking over for my colleague. Let me catch up.

alpine marlin
#

Thanks

worn ledge
#

What proration you are expecting to see exactly ?

#
  • Product A originally costs $100 (referred to as Price A).
  • Product C costs $300 (referred to as Price C).
    A user is on a yearly subscription to Product A at the original price of $100.
    Midway through the year, the price of Product A increases to $150, now referred to as Price A-a.
  • I create a subscription schedule so that at the end of the current billing cycle, the user will be charged the new price of $150 for the next cycle.
    In the meantime, the user decides to upgrade to Product C.
    Can you create a fresh new Subscription with test clock https://docs.stripe.com/billing/testing/test-clocks
    Share the creation request
    Then share the request with the update you want to make
    And what are you epxecing from the upcoming invoice endpoint ?
alpine marlin
#

I might need sometime to get back to you. Please don't close this ticket

worn ledge
#

I'll keep it open yeah. But due to inactivity it can be closed

#

Or we can narrow this Subscription sub_1RJSaJArTeYcLw6yf6JFm3s0

#

it's ok too

#

Creation request: req_UpzYQmU7RSaPEU

#

Create a Subscription Schedule from the Subscription: req_6tPJHcQGAg5I8n

alpine marlin
#

sure we can look into sub_1RJSaJArTeYcLw6yf6JFm3s0

worn ledge
#

Update Subscription with price price_1R7DhsArTeYcLw6yl1wAighO : req_51TpeD8MH6auOf

#

Here in this request, you specified proration_behavior: "none", so no proration will be created

#

Is this ok so far ?

alpine marlin
worn ledge
#

Ok. now what are you expecting from the upcoming invoice and what proration you are looking for ?

alpine marlin
#

For the upcoming invoice, I'm upgrade to a product's price price_1KX0lEArTeYcLw6yla88Vatn ($2700).
Since the subscription subscribe to a product price price_1PmpGcArTeYcLw6yySKT5l4b ($1200)

I'm expecting the upcoming invoice will have the unused amount of product price price_1PmpGcArTeYcLw6yySKT5l4b (stripe return back the unused amount)
Not the full amount price_1KX0lEArTeYcLw6yla88Vatn` ($2700) get charged

worn ledge
#

Ok good, now can you share the params you are passing to th upcoming invoice endpoint?

alpine marlin
#

$payload = [ 'customer' => 'cus_SDuO6HkCsS3b2L', 'schedule' => 'sub_sched_1RJSgzArTeYcLw6ySyhs7066', 'schedule_details' => [ 'phases' => [ [ 'start_date' => 1745988567, 'end_date' => 1777524567, 'items' => [ [ 'price' => 'price_1R7DhsArTeYcLw6yl1wAighO', // existing 'quantity' => 1, ], ], ], [ 'items' => [ [ 'price' => 'price_1KX0lEArTeYcLw6yla88Vatn', // upgrade plann price 'quantity' => 1, ], ], 'iterations' => 12, ], ], ], ];

Stripe\Invoice::upcoming($payload);

worn ledge
#

So here, you added an item, you didn't replaced the existing one

#

is that what you want ?

alpine marlin
#

The reason I didn't replaced the existing one, because it not allow as i get this message
The subscription schedule update is missing at least one phase with a start_date to anchor end dates to

#

What scenario that i need to replaced the existing one?

wheat iris
#

hi! I'm taking over this thread.

alpine marlin
#

What I want is to get the upcoming invoice calculate with the new product's price price_1KX0lEArTeYcLw6yla88Vatn ($2700).
And it ignored the existing subscription schedule that i made. (And i don't want to release the schedule before user confirm to change to new product's price)

wheat iris
#

give me some time to catchup

alpine marlin
#

Ok, thanks.

#

I might away for few hours. Incase the ticket auto close. Is there a way to catchup on what we have previously discuss?

wheat iris
#

if the thread close, you can still read its content. and if you have follow up questions, you can always open a new thread

alpine marlin
#

ok sure. Thanks alot

wheat iris
#

The reason I didn't replaced the existing one, because it not allow as i get this message
just to clarify, you can absolutely replace one price by another in a Subscription Schedule. so I think your next step is to make that work.

#

The subscription schedule update is missing at least one phase with a start_date to anchor end dates to
can you share the Request ID (req_xxx) where you got that error?