#pulley871_code
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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?
yea
๐งโ๐ป 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
foocontains the valuebar.
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)
/**
* 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
So what is the preview returning? What are you expecting it to return?
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
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?
It can. You would just specify proration_behavior and proration_date
https://docs.stripe.com/api/invoices/create_preview#create_create_preview-subscription_details-proration_behavior
https://docs.stripe.com/api/invoices/create_preview#create_create_preview-subscription_details-proration_date
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
thanks โค๏ธ ill give this a go