#Orph
1 messages · Page 1 of 1 (latest)
Hello! Proration is calculated by Stripe based on the changes you make, and you cannot alter that calculation. If you want to adjust the amount the customer pays you can do so using negative Line Items: https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-amount
Or you can add a balance to the Customer: https://stripe.com/docs/invoicing/customer/balance
When the subscription is updated, a charge happens, but we're not wanting that, that's obviously not right in this one case.
The weird thing is those invoice items are already appearing as archived.
You can also disable proration when updating if you want to: https://stripe.com/docs/api/subscriptions/update#update_subscription-proration_behavior
Okay, so yeah, the archived thing. Those invoice items are showing up as archived and aren't applying to the updated subscription
Not sure I understand, can you provide more details?
ii_0MF5vCv46aBdrNu1LhW3zjn5 is one that was generated and it was immediately declared archived on creation for some reason. (live)
Oh, you mean the Product associated with this Invoice Item has been archived.
The Invoice Item itself isn't/can't be archived, but I see what you're saying now.
Yeah, meant the product, but yeah, that's definitely not the behavior I'm expecting.
What behavior are you expecting?
I thought with the negative amount invoice items, the subscription is updated with a proration, but with that negative line item that's greater than the proration, they wouldn't be charged.
The direct option is shutting off prorations in this case and that might be a simple enough fix, but need to review other scenarios as well.
I think the fact the product is archived instantly means it can't be added as an invoice item
So it's stuck pending forever, or something invisible eats it.
Yeah, archived Products can't be used. It sounds like you might want to create a new Product with new Prices to replace the old one?
Here's the documentation on archiving a Product for reference: https://stripe.com/docs/products-prices/manage-prices#archive-product
If you want to disable a product so that it can’t be added to new invoices or subscriptions, you can archive it. If you archive a product, any existing subscriptions that use the product remain active until they’re canceled and any existing payment links that use the product are deactivated. You can’t delete products that have an associated price, but you can archive them.
Yeah, that's the thing. It appears we're not even sending a price_id of any sort when we're creating these items.
What do you mean?
InvoiceItem::create( $with_subscription( [ 'amount' => $line_item->amount, 'currency' => STRIPE_US_CURRENCY, 'customer' => $customer_id, 'description' => $line_item->description, ] ) );
This is what's being done in PHP to create those, there's just some amount and a descriptor, I'm not sure how that's converting to a price/product that's archived.
The Product is already set on the Subscription.
Now I'm not following I admit.
The Subscription you're trying to update is already using the archived Product.
You're trying to update it, but the Product is archived, so you're seeing unexpected behavior.
Also not sure what that $with_subscription part of your code is doing.
Can you explain how that works?
Oh, that just adds the subscription id if it exists
so there is that subscription key, shouldve mentioned that
Gotcha. So, taking a step back, can you describe in detail, with an example scenario, what you want to happen?
So, to keep the first half short, we have gift codes we previously had through woocommerce, and we still honor those. We just use it as a credit for their subscription for Stripe.
As my predecessor wrote it, they generated invoice items before updating the subscription. So their idea was to generate invoice items with the negative amount (credit for the gift code), then update the subscription. Once this update happens, there's a charge created, but I thought the (incorrectly archived) price/product would have reduced that balance as that's another invoice, no?
I don't understand this part:
I thought the (incorrectly archived) price/product would have reduced that balance as that's another invoice, no?
Can you provide more details about what this means?
Why would this utterly new invoice item on an active subscription already have it's (invoice item) associated product be archived when that product never existed prior to it's creation?
Or simply, why would this already be archived on creation is my question?
Have a look at this request in your Dashboard: https://dashboard.stripe.com/logs/req_UuS2FVmHkKktip
In the response you can see that the Invoice Item is associated with the Price and archived Product which are already present on the Subscription you specified in the request.
I see that. But WHY. Why is active=false
If you want it to be associated with a different Price (one not associated with an archived Product) you can specify a Price ID when you create it: https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-price
active is false because the Product was archived.
I know that. I mean why is it automatically being set to false on creation.
I'll try creating a price with the optional params for price data, maybe that'll work?
You can also do that if you'd like, yep. Make sure you specify a Product ID in there that's not archived.
Okay, this gets me in the right direction at least, so, thank you.