#skoshkarli

1 messages · Page 1 of 1 (latest)

bleak quiverBOT
daring pike
#

Basically the case i have is, users subscribes to one subscription product, then cancels and subscribes to another

#

i was told to do an immediate cancellation with prorate:true

#

which seems to create a new invoice which is correct, but the original invoice never gets fully processed and stays as draft

hard lily
#

Hi, taking a look here

#

It looks like an update was made within a minute of creating the initial subscription (while the invoice was still in draft status). Let me try to reproduce this on my end.

daring pike
#

update was made by Avatax?

#

i mean even if i cancel the original subscription this invoice was for, the invoice should still get charged after an hour, right?

#

i use pay_immediately flag set to false

#

which should make it delay by an hour to allow for Avatax to add taxes

hard lily
#

You went from a monthly price to a yearly plan while the first invoice was in a draft status

daring pike
#

correct

#

so the credit got applied to the annual product on the invoice, but the monthly invoice never got charged

hard lily
daring pike
#

no no, thats a credit

#

not a charge

hard lily
#

Ok, we are on the same page.

jovial sky
#

👋 taking over here

daring pike
#

can i just continue with one person please

#

i dont' want to have to re-explain something

#

i think @hard lily is still trying to test it

jovial sky
#

You don't need to, just gimme some mins to catch up. We are also talking

daring pike
#

it was advised to me by you guys to do it this way

#

if it was expected then why was i told to do this?

#

i spent number of days refactoring my code and only now noticed that these draft invoices are not being charged

#

what do you suggest to do to resolve this?

jovial sky
#

I am looking at the older thread to grasp the context

daring pike
#

ok

jovial sky
#

Um I get the original discussion when we reached a conclusion that cancel a Sub with prorate=true, then create a new Sub will pick up the prorated amount immediately. But why do you still want the old Invoice to be charged? More specifically:

  1. The old Invoice has $9.99 for a month and $0.87 adjusted by Avatax
  2. The new Invoice has prorated of -$9.99 of the unused part in 1., $99.99 for an annual charge, then $7.88 adjusted by Avatax

So I think new Invoice get charged and old Invoice never get charged, should be the correct calculation in the end, no?

daring pike
#

no because i am short 9.99 + tax now

#

because it never got charged

#

and the 2nd invoice is reduced by that amount

#

but i never received the money

#

because its still in draft

jovial sky
#

No you are not short. The new Invoice off by $9.99 because that's an unused time

daring pike
#

unused time means you are giving customer a credit to use on their new subscription

#

but if you never charged the customer to begin with

#

how can you provide a credit

#

you need to charge first on the initial invoice

#

but the initial invoice stays in draft forever

jovial sky
#

Ah I see what you mean. One moment

#

How about just ... manuall call finalize then pay for that Invoice?

#

Canceling a subscription causes all open and draft invoices for that subscription to have their auto_advance property set to false. This occurs to prevent unexpected automatic payment attempts and reminder emails. This effectively pauses automatic collection for these invoices. You can still manually attempt to collect payment and manually send emails.

daring pike
#

will that charge?

jovial sky
#

that seems to do the trick too

daring pike
#

let me try this real quick one sec

#

uhmm no so invoice_now is creating another invoice which refunds the customer

#

i don't want to be providing refunds, just a credit on the next invoice

#

so the audo_advance property, are you saying if i set that to true on the invoice, it will advance when it was supposed to? (an hour after initally created)

#

@jovial sky

jovial sky
#

No it's a bit different. Don't set the auto_advance property back to true, simply call the Finalize Invoice API and then Pay Invoice API

#
daring pike
#

I want to give it the full hour if its in draft, in case taxes have not been calculated yet

#

to allow Avatax to do its thing

jovial sky
#

You mean Avatax could send additional invoice items in 1 hour?

#
  1. Set the auto_advance back to true and hope 1 hour later the Invoice will process as expected
  2. Simply wait 1 hour on your own then manually call the Finalize and Pay Invoice.

I prefer 2 but that could make implementation complicated. Agree that 1 would be easier

#

You can test it real quick I think, using a Test Clock on the Customer

daring pike
#

waiting is not really an option, i dont have a service that would do this

#

is it possible to pull of a time off of the invoice (when it will be charged) and apply that ?

#

looks like there is a next_payment_attempt on it

jovial sky
daring pike
#

maybe if i use auto_advance with next_payment_attempt ?

jovial sky
#

Yep looking at the next_payment_attempt. I am a bit concern about closed but let's try it

#

So to set the auto_advance back to true I think you can immediately set it back and it will calculate 1 hour after draft to finalize and charge. You don't need to wait exactly 1 hour then set it back

daring pike
#

ok let me try

#

so i did auto_advance: true only and it created a new invoice and refunded the user

#

i have a feeling that auto_advance: true, on a cancelled subscription will always refund ?

#

instead of giving a prorated credit

jovial sky
#

Umm I just want to see it too. Could you provide the newly tested Id?

#

I would like to see the refund action

daring pike
jovial sky
#

Did you create a new Subscription?

daring pike
#

yeah

#

i always test with a new user and a new subscription

#

ah sorry

jovial sky
#

Was sub_1MPGCAErhtagFlzSsjBSeWWY you new Subscription?

daring pike
#

i left the invoice_now

#

one sec, let me remove and retry

daring pike
#

so

#

update doesnt take next_payment_attempt

#

Received unknown parameter: next_payment_attempt

#

i tried setting auto_advance to true and collection_method to "charge automatically"

#

but none of that worked

#

@jovial sky

#

i dont understand how your proration works at this point. it doens't make sense that i create a new subscription and i say to prorate and it gives me the credit but doesn't charge the initial invoice

#

this has to be a bug on your end

#

i dont care if its in a draft or not, that invoice has to be finalized if you are applying a prorated amount from it onto another invoice

jovial sky
#

By doesn't work, didn't it do anything when the time comes? Can you share a Subscription Id?

daring pike
#

i mean that its the same result as before

#

nothing has changed

#

it stays in draft mode

#

and automatic collection is off

#

how can i set next_payment_attempt?

jovial sky
daring pike
#

so you think i should not do auto_advance: true ?

jovial sky
#

Hmm looks like it doesn't have effects. Can you try to manually finalize and pay the Invoice? I know in reality you need to wait for a bit more time, but just to test let's see if you can finalize and pay it

daring pike
#

so to call finalizeInvoice ?

#

ok i am going to call finalize on this invoice now

#

via curl

#

done

#

its now just an open invoice

#

never got charged

jovial sky
#

Yes then call Pay API

#

Finalize API and Pay API are 2 different APIs

daring pike
#

done

#

so that processed the payment

#

but it does so immediately

jovial sky
#

Okie so to summarize what we have tried, seems that directly call Finalize and Pay is the only way. Once the Subscription is cancelled, all "automatic" mechanism like auto_advance or calculating next payment is off, and the draft Invoice are treated as individual Invoices

#

I think you would need a queue mechanism or anykind of scheduler, that after 1 hour (or any hours you want) to trigger the Finalize and the Pay API

#

Sorry it's how the Subscription is designed, per the Doc

Canceling a subscription causes all open and draft invoices for that subscription to have their auto_advance property set to false. This occurs to prevent unexpected automatic payment attempts and reminder emails. This effectively pauses automatic collection for these invoices. You can still manually attempt to collect payment and manually send emails.

daring pike
#

how does the AvaTax webhook set the next_payment_attempt?

#

it doesn't seem like an option available via the api based on the docs

jovial sky
#

Which part specifically?

daring pike
#

next_payment_attempt is set to an hour from when an invoice is created initially

#

and that gets reset when the subscription is cancelled

jovial sky
daring pike
#

i guess maybe thats not done via api but is done during the intial create subscription call

#

using the pay_immediately flag

jovial sky
#

Yeah that's not a settable property

#

(not every properties are settable)

daring pike
#

another question, do i have to finalize an invoice before paying it? I am tempted to go ahead and finalize the invoice before the new subscription is created and not allowing for the full hour

#

it seems like the prorated amount gets carried over at that time, so i am thinking if taxes were not calculated then they wouldn't show up anyway on the new invoice

jovial sky
#

Yes you need. It's the Invoice "state machine" when Draft --- (Call Finalize API) --> Open ---- (Call Pay API) ----> Paid

daring pike
#

got it

#

ok thank you for the info, i will try it this way and see if it works for me

jovial sky
#

Hopefully! Sorry for the back and forth