#Zil

1 messages · Page 1 of 1 (latest)

ripe currentBOT
knotty trout
#

Hi there!

#

So you would like to delete the draft invoice so it doesn't finalize?

boreal idol
#

Well yes, but it seems I cannot delete the draft invoice.

draft_invoices = Stripe::Invoice.list(customer: customer_id, status: :draft, subscription: subscription.processor_id)

        if draft_invoices.present?
          draft_invoice = draft_invoices.first
          Stripe::Invoice.void_invoice(draft_invoice.id)
        end
#

I cannot void it because it is in draft state

knotty trout
#

What do you mean by "can't"? Do you get an error message? Can you share the request ID?

boreal idol
#

So this throws You can only pass in open invoices. This invoice isn't open.

knotty trout
#

Ha wait, this won't work for subscriptions invoice

boreal idol
#

You can't delete invoices created by subscriptions.

#

Yup

knotty trout
boreal idol
#

I was thinking of calling Stripe to check if there are draft invoices for subscription and forbidding users to upgrade/downgrade while they use the pricing page.

#

Are there any negative consequences of having draft invoices that never finalize?

#

auto_advance: false is an option. If I process events in the background, there could still be race conditions (upgrading the last second), but the probability is much lower. In that case we would need to make a refund if it ever happens.

ripe currentBOT
knotty trout
#

Are there any negative consequences of having draft invoices that never finalize?
No I don't think so

#

auto_advance: false is an option. If I process events in the background, there could still be race conditions (upgrading the last second), but the probability is much lower. In that case we would need to make a refund if it ever happens.
Yes makes sense

boreal idol
#

Ok thanks. I will try this solution right now.

#

Should I use some time filter when fetching for an invoice, or should I just grab the last draft invoice and update it?

faint lantern
#

Hey! Taking over for my colleague.

boreal idol
#

In invoice.paid webhook I am fetching for draft invoices that might have been issued.

#

And I will be setting it to auto_advance: false

faint lantern
#

Reading the previous conversation...

#

You should refer to invoice.created event and mark the invoice as auto_advance: false

boreal idol
#

If it does not upgrade, the invoice should be collected

#

I am trying to prevent double charging the user

faint lantern
boreal idol
#

Thanks. Implemented it and it seems to work. Thanks.

faint lantern
#

Cool!