#Orph

1 messages · Page 1 of 1 (latest)

exotic sorrelBOT
gray leaf
main lily
#

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.

gray leaf
main lily
#

Okay, so yeah, the archived thing. Those invoice items are showing up as archived and aren't applying to the updated subscription

gray leaf
#

Not sure I understand, can you provide more details?

main lily
#

ii_0MF5vCv46aBdrNu1LhW3zjn5 is one that was generated and it was immediately declared archived on creation for some reason. (live)

gray leaf
#

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.

main lily
#

Yeah, meant the product, but yeah, that's definitely not the behavior I'm expecting.

gray leaf
#

What behavior are you expecting?

main lily
#

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.

gray leaf
#

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.

main lily
#

Yeah, that's the thing. It appears we're not even sending a price_id of any sort when we're creating these items.

gray leaf
#

What do you mean?

main lily
#

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.

gray leaf
#

The Product is already set on the Subscription.

main lily
#

Now I'm not following I admit.

gray leaf
#

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?

main lily
#

Oh, that just adds the subscription id if it exists

#

so there is that subscription key, shouldve mentioned that

gray leaf
#

Gotcha. So, taking a step back, can you describe in detail, with an example scenario, what you want to happen?

main lily
#

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?

gray leaf
#

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?

main lily
#

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?

gray leaf
#

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.

main lily
#

I see that. But WHY. Why is active=false

gray leaf
#

active is false because the Product was archived.

main lily
#

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?

gray leaf
#

You can also do that if you'd like, yep. Make sure you specify a Product ID in there that's not archived.

main lily
#

Okay, this gets me in the right direction at least, so, thank you.