chargebee / chargebee-php

PHP library for the Chargebee API.
https://apidocs.chargebee.com/docs/api?lang=php
MIT License
72 stars 62 forks source link

Replace Addon List seems to be not working #51

Closed ErxrilOwl closed 1 year ago

ErxrilOwl commented 1 year ago

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
  ]);
cb-khushbubibay commented 1 year ago

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, 
  ),)
  ));
ErxrilOwl commented 1 year ago

@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.

cb-khushbubibay commented 1 year ago

@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

ErxrilOwl commented 1 year ago

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