#japoorv-java-invoice

1 messages · Page 1 of 1 (latest)

teal hemlock
#

What exactly to you mean by reading and attaching here?

#

When you call the upcoming invoice endpoint, a "fake" invoice is created and returned for you to inspect based on the parameters you sent

#

You can't actually use this invoice for payment, though, as it doesn't really exist

#

Can you provide a specific example of the request you're making and the results you see, to explain what isn't working like you expect?

fallen wolf
#

Okay so basically we are want to find out the new price (with proration) that the customer would be charged when he updates the quantities. To get this "new" price we create a InvoiceUpdateParam with the new quantities and also apply a coupon to it. When we call the invoice.upcoming on this invoiceUpdateParam then we don't see the new price with the discount coupon (though we see the discount coupon being added).

The attached file is the object that we receive when we do Invoice.upcoming(invoiceUpdateParam).

I know this is confusing please bear with me,

#

"lines": {
"object": "list",
"data": [
{
"amount": 300000,
"currency": "usd",
"description": "25 API × Api Endpoints (at $120.00 / year)",
"discount_amounts": [
{
"amount": 45000,
"discount": "di_1Jn2ZfSGbEHxf91bnIxVQTv8"
}

So if you see this portion of the file you will see that it says the amount is 300000. In description you can see it says 25*120 = 300000, it also shows a discount of 45000 however the amount shown is 3000000

teal hemlock
#

Can you share the request you make to the upcoming invoice endpoint?

#

I don't be able to see the response so thanks for sharing that

#

but i can see the parameters you send

#

The data you shared seems to do the expected thing though right?

fallen wolf
#

This is the invoiceUpdateParam

teal hemlock
#

You should 25x $120 = $3000

#

15% discout = $450 (shown)

#

total is 3000 - 450 = 2550 (the upcoming invoice total)

#

So which part is not doing what you expect?

fallen wolf
#

Yes exactly but the amount is still 30000 as in the first line of my pasted snippet.
Shouldn't that amount be the discounted one ?

teal hemlock
#

in the data you share i see "amount_due": 255000,

fallen wolf
#

No so that is the total for the entire invoice. I actually wanted to know the total for different line items. So if you scroll down to lines section and then see the amount then it shows 300000

teal hemlock
#

yes, and each line item also has discount_amounts

#
"data": [
      {
        "amount": 300000,
        "currency": "usd",
        "description": "25 API × Api Endpoints (at $120.00 / year)",
        "discount_amounts": [
          {
            "amount": 45000,
            "discount": "di_1Jn2ZfSGbEHxf91bnIxVQTv8"
          }
        ],
fallen wolf
#

Yes so do I need to explicitly calculate the discounted amount ?

teal hemlock
#

no its right there

#

45000

fallen wolf
#

no I mean 30000 -45000

teal hemlock
#

that's applied at the total for the invoice automatically, if you want it per line item to display in your own presentation then yes you need to subtract those

fallen wolf
#

Oh okay, that was want I wanted to now.

#

Thanks a lot for looking into this.
You guys are the best !

teal hemlock
#

quite welcome 🙂