#madwifi_code

1 messages ยท Page 1 of 1 (latest)

wary briarBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1283411666536632322

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

chilly dust
#

hi there!

left bluff
#

Hi

wary briarBOT
chilly dust
#

But when I call with this, the existing line items are not removed from the invoice, instead new line item with the given plan is added.
I'm not sure what you mean. can you clarify why you want existing line items to be removed?

left bluff
#

I am trying to show the customer how the subscription would look like before they accept the update. For example, the customer might have balance, and the plan may be different, they might have coupon. So the customer should be aware on what their updated subscription should look like. So it is important to remove the existing line items from the upcoming invoice as well as this is what would be done to their existing subscription.

#

Currently because of this, an update to a monthly subscription into yearly, would yield in the period_end to show as next month, instead of next year. hope this makes sense @chilly dust

barren forum
left bluff
#

let me try

#
  {
    subscription: sub_id,
    subscription_details: {
      proration_behavior: 'create_prorations',
      items: [
        {
          id: sub_item_id,
          deleted: true,
        },
        {
          discounts: next_discount,
          plan: plan_id,
        }
      ]
    }
  }
)```

Tried with this updated code, but still the `lines` are coming back as 2. FWIW, I tried to provide the `quantity: 0` but it didn't work either. I think the `sub_item_id` -- which is subscription's item ID, is not getting selected in the above code.
barren forum
left bluff
#

let me check the logs

#

id: req_geg0TdI6mmEYRT

#

@barren forum does this help?

barren forum
#

Ah the other item is due to proration

left bluff
#

oh!

barren forum
#

look at
"description": "Unused time on Alo Moves Membership (with $29.00 off) after 11 Sep 2024",

left bluff
#

let me try and remove this.

#

@barren forum I removed the proration. and it is still showing the same (req_GYirE2uG1EtVDO) and the descriptions in the line items are:
[{:id=>"ii_1PxqZh2L3GhbnQDbkX7BOEt6", :desc=>"Unused time on ... (with $29.00 off) after 11 Sep 2024"}, {:id=>"sli_156a192L3GhbnQDb3a27d658", :desc=>"1 ร— ... (at $129.99 / year)"}]

barren forum
#

How are you removing proration? I suspect your settings not getting applied

left bluff
#

In the request I'm not sending the proration_behavior

#

should I use proration_behavior=none

barren forum
#

yes

left bluff
#

OK

barren forum
#

we prorate by default

left bluff
#

hmm, looks like without proration, I would not get the remaining amount, but with proration, the date needs to be taken from the lines of "type": "subscription", . I was taking it earlier from the period_end of the invoice. which was not correct here.

#

This is the mapping of the relevant values from the lines of invoice.
[{:id=>"ii_1PxqlJ2L3GhbnQDbRIQd9A0h", :type=>"invoiceitem", :end=>2024-10-03 15:47:08 +0530}, {:id=>"sli_14a0fc2L3GhbnQDbfbbbe780", :type=>"subscription", :end=>2025-09-11 19:09:13 +0530}]

@barren forum Thanks for the help.