#pulley871_code

1 messages ยท Page 1 of 1 (latest)

signal haloBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1251233366192296049

๐Ÿ“ Have more to share? Add details, code, screenshots, videos, etc. below.

rain dagger
#

We don't have a lot of context on Laravel Cashier, but we can help with the Stripe side of things. Do you have example code that you're using to preview the upcoming Invoice?

flat robin
#

yea

signal haloBOT
#

๐Ÿง‘โ€๐Ÿ’ป 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)
flat robin
#

        /**
         * This check is removing the negative balance from the move from 3 to 4 seats on a standard subscription
         * because of the tiered pricing it would create a loop hole where customers could get unlimited refunds
         */
        if ($quantity_change === 0) {
            return 0;
        }

        $this->updateSubscriptionLinesQuantity();
        $this->subscription->items->firstWhere(fn (SubscriptionItem $item) => $item->id === $line_data->id)->quantity = $subscription_item->quantity + $quantity_change;

        $invoice = $this->subscription
            ->alwaysInvoice()
            ->previewInvoice($this->subscription->items->pluck('stripe_price')->toArray());```
#

This is just to get the proration amount from the change on the specific line that was adjusted

rain dagger
#

So what is the preview returning? What are you expecting it to return?

flat robin
#

Right now it is returning

#

An invoice with just this Line on it.
That was an example from moving from 3 to 5 quantity. Which i would anticipate that the repsonse would give me somelike $19 as the amount, but im getting these random numbers.

#

We have the subscription, we are adjusting the line quantity on the subscription then calling those chained methods on the sub

rain dagger
#

There's a ton of logic that I don't understand in your code. It looks like you're updating the Subscription immediately before previewing the Invoice, but I don't understand what you're doing with the quantity

#

Have you tried creating the Preview with the quantities instead of updating the Subscription's quantity first?

flat robin
#

Let me take a gander of that real quick

#

Does this method include proration?

rain dagger
flat robin
#

thanks โค๏ธ ill give this a go