#nate-subscription-pendingitems
1 messages ยท Page 1 of 1 (latest)
what does "where that doesn't happen" mean exactly? Can I ask you to be a lot more specific about what is and isn't working? I remember working with you around something like this a few weeks/months ago if I'm not mistaken and it was super advanced already
Sure thing. I'll do my best and let you ask for clarification as needed. I create a pending invoice item with a subscription id, and then take action on the subscription that generates an invoice. I expected the pending invoice item to be attached to the invoice that is generated from that action as a line item, but it was not; it remained a pending invoice item.
Isn't this the "bug" we found together months ago?
It might not be, just my brain remembers your name and something weird with pending InvoiceItems
Haha fair enough. It's from a similar flow, but I think it's a distinct issue
Are you referring to https://discord.com/channels/841573134531821608/1141873757745582170?
yep
nice find on the thread
Okay, so if it's unrelated, let's start from the top. Can you write a clear end to end repro script that explains the issue with pending InvoiceItems? I don't really get what you described. And it's the only way to do negative line items
nate-subscription-pendingitems
Are you asking me to write out steps, or send a code snippet?
Whichever you have. If you have exact steps I'll want the exact object ids and request ids. If you have code snippets I'll use it or port it to PHP depending on how complex it is
How's this?
- Start with a monthly subscription with an item with quantity 3, unit price $15, on a test clock (
req_PfNH6oo6WFrPLP) - Advance the test clock by 14 days
- Create a negative pending invoice item for -$1 with the subscription's ID (
req_K3eNYkOj3bhsuw) - Update the subscription: reduce the quantity of the existing item to 1, add another item with quantity 1, unit price $10. Use proration behavior
always_invoice. (req_hmb2GvPcbzNS5o)
I fudged the amounts from the actual requests, but the principle should be the same
Ack and you say it's not pulling in that pending InvoiceItem?
Correct
okay let me repro
sorry the questions keep on coming so taking me some time to repro
no worries
@wispy folio okay took me a while sorry. So yeah it's sadly a known limitation ๐ฆ
I have a jira from myself a month ago going through the exact same reproduction and it's sadly known and we're unlikely to fix it any time
That's unfortunate. Is there any workaround? This has implications for our tax accounting
I can't think of any way to work around it sadly. The only viable path is to use create_prorations and then invoice yourself
Does this happen for all always_invoice updates?
I think it happens for all the ones that don't change the billing cycle
let me confirm
yeah when the billing cycle changes such as monthly->yearly we properly pull the pending InvoiceItems.
So it's only in the case where you're changing the quantity or adding an extra Price for example
And it's only when the invoice amount is negative? Or any invoice?
wrong word, did you mean InvoiceItem? If so it's any.
'frozen_time' => time(),
'name' => 'testing',
]);
$customer = $stripe->customers->create([
'test_clock' => $clock->id,
'payment_method' => 'pm_card_visa',
'invoice_settings' => [
'default_payment_method' => 'pm_card_visa',
],
]);
$subscription = $stripe->subscriptions->create([
'customer' => $customer->id,
'items' => [
[
'price' => 'price_123',
],
],
'expand' => ['latest_invoice.charge'],
]);
$invoiceItem = $stripe->invoiceItems->create([
'amount' => 211,
'currency' => 'usd',
'subscription' => $subscription->id,
'customer' => $customer->id,
'description' => 'POSITIVE PENDING',
]);
$invoiceItem2 = $stripe->invoiceItems->create([
'amount' => -599,
'currency' => 'usd',
'subscription' => $subscription->id,
'customer' => $customer->id,
'description' => 'NEGATIVE PENDING',
]);
advanceClock($clock->id, 3600*24*10, true);
$subscriptionUpdated = $stripe->subscriptions->update(
$subscription->id,
[
'items' => [
[
'id' => $subscription->items->data[0]->id,
'price' => 'price_ABC',
]
],
'proration_behavior' => 'always_invoice',
'expand' => ['latest_invoice'],
]
);```
that's my PHP script that reproduces the issue in case it helps
I did the negative and positive InvoiceItems just to be sure and none are pulled in the example you mentioned (changing the quantity)
I see. Well, thanks for confirming! I'll explore the create_prorations + invoice ourselves approach will work for us.
Sounds good! Make sure to reach out to your contacts to ask for a fix too I'd say, that'll help raise the priority ๐
Will do!
Have a great day!