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

Fetching subscriptions using parameter itemId results into error

scr4bble opened this issue · comments

Code that triggers the error from API:

$all = ChargeBee_Subscription::all([
		"limit" => 100, // 100 is max
		"sortBy[asc]" => "updated_at",
		"itemId[is]" => $pp_free_plan_id,
	]);

From Documentation

itemId[<operator>]
The plan item code.
Supported operators : is, isNot, startsWith, in, notIn

Example → "itemId[is]" => "silver"
optional, string filter

Traceback:

\/chargebee\/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Guzzle.php(102): ChargeBee\\ChargeBee\\Guzzle::handleAPIRespError(400, Array, '{\"message\":\"ite...')\n#1
\/chargebee\/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Guzzle.php(27): ChargeBee\\ChargeBee\\Guzzle::processResponse('{\"message\":\"ite...', 400)\n#2
\/chargebee\/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Request.php(36): ChargeBee\\ChargeBee\\Guzzle::doRequest('get', '\/subscriptions', Object(ChargeBee\\ChargeBee\\Environment), Array, Array)\n#3
\/chargebee\/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Request.php(22): ChargeBee\\ChargeBee\\Request::send('get', '\/subscriptions', Array, Object(ChargeBee\\ChargeBee\\Environment), Array)\n#4
\/chargebee\/vendor\/chargebee\/chargebee-php\/lib\/ChargeBee\/Models\/Subscription.php(109): ChargeBee\\ChargeBee\\Request::sendListRequest('get', '\/subscriptions', Array, NULL, Array)\n#5
\/chargebee\/chargebee.php(46): ChargeBee\\ChargeBee\\Models\\Subscription::all(Array)\n```

I just found out that using 'planId' instead of 'itemId' works. So this is a problem in documentation for chargebee PHP library.

@scr4bble - could you please tell us which PHP and chargebee-php version are you using? The latest chargebee-php stable version till date is v3.1.0 which supports PHP > 5.6.0.

Try upgrading our chargebee-php to latest version and let us know if you are still facing the same issue.

Please note as per this, if you are using PHP < 5.6.0, you can download chargebee-php v2.8.3 which will not support recently added features/fixes and recommend to upgrade PHP.

I am using latest version of chargebee-php but I just found out that I was checking wrong documentation. We are using Product catalog 1.0 and the documentation mentioned in the issue is from PC 2.0.
We can close this issue. Sorry for confusion.