chargebee / chargebee-php

PHP library for the Chargebee API.

Home Page:https://apidocs.chargebee.com/docs/api?lang=php

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Replace Addon List seems to be not working

ErxrilOwl opened this issue · comments

I'm trying to update the subscription for a customer in which I change the addons and completely replace the old one, but it seems to be not working. It just keeps adding the addons to the current list in chargebee.

ChargeBee\ChargeBee\Models\Subscription::update($cb_id, [
      "addons" => $newAddons,
      "replaceAddonList" => true
  ]);

Hi @ErxrilOwl

Request you to try below sample code, it worked fine for me.

$result = Subscription::update($sub_id,array(
  "replaceAddonList" => true,
  "addons" => array(array(
    "id" => $newAddons,
    "quantity" => 1, 
  ),)
  ));

@cb-khushbubibay , still not working. For now, I just created a workaround where I fetch all the unbilled charges and compare which addons to remove, and re-add using the same function.

@ErxrilOwl
It appears that there might be an issue with your code, as the provided sample code worked successfully for me. It effectively replaced all the previously added addons from the subscription, leaving only the most recent addons associated with the updated subscription.
If you want a call over this issue you can raise this with our support team support@chargebee.com

Yes, I tried the same code as yours, still not working. Already raised to chargebee support, might be an account issue. Thanks