#nate-subscription-pendingitems

1 messages ยท Page 1 of 1 (latest)

rain birchBOT
lone nacelle
#

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

wispy folio
#

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.

lone nacelle
#

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

wispy folio
#

Haha fair enough. It's from a similar flow, but I think it's a distinct issue

lone nacelle
#

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

wispy folio
#

Are you asking me to write out steps, or send a code snippet?

lone nacelle
#

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

wispy folio
#

How's this?

  1. Start with a monthly subscription with an item with quantity 3, unit price $15, on a test clock (req_PfNH6oo6WFrPLP)
  2. Advance the test clock by 14 days
  3. Create a negative pending invoice item for -$1 with the subscription's ID (req_K3eNYkOj3bhsuw)
  4. 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

lone nacelle
#

Ack and you say it's not pulling in that pending InvoiceItem?

wispy folio
#

Correct

lone nacelle
#

okay let me repro

#

sorry the questions keep on coming so taking me some time to repro

wispy folio
#

no worries

rain birchBOT
lone nacelle
#

@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

wispy folio
#

That's unfortunate. Is there any workaround? This has implications for our tax accounting

lone nacelle
#

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

wispy folio
#

Does this happen for all always_invoice updates?

lone nacelle
#

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

wispy folio
#

And it's only when the invoice amount is negative? Or any invoice?

lone nacelle
#

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)

wispy folio
#

I see. Well, thanks for confirming! I'll explore the create_prorations + invoice ourselves approach will work for us.

lone nacelle
#

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 ๐Ÿ™‚

wispy folio
#

Will do!

lone nacelle
#

Have a great day!