Closed markomitranic closed 1 year ago
Any updates?
Hi @markomitranic @lightness
I tried below sample codes and these are working fine. Please try this once. To Retrieve Subscription :
import { ChargeBee, _subscription } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "site", api_key : "api-key"}); chargebee.subscription.retrieve("subs_id").request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(
${result.subscription}
); var subscription: typeof chargebee.subscription = result.subscription; var customer: typeof chargebee.customer = result.customer; var card: typeof chargebee.card = result.card; } });
To Create Subscription :
import { ChargeBee, _subscription } from 'chargebee-typescript'; var chargebee = new ChargeBee(); chargebee.configure({site : "site", api_key : "api-key"}); chargebee.subscription.create_with_items("cust_id",{ subscription_items : [ { item_price_id : "itemPriceId", billing_cycles : 2, quantity : 1 }] }).request(function(error,result) { if(error){ //handle error console.log(error); }else{ console.log(
${result}
); var subscription: typeof chargebee.subscription = result.subscription; console.log(${result.subscription}
); var customer: typeof chargebee.customer = result.customer; var card: typeof chargebee.card = result.card; var invoice: typeof chargebee.invoice = result.invoice; var unbilled_charges: Array= result.unbilled_charges; } });
If this will not work for you, could you please provide more context on the issue and provide us the code that you are trying to run.
Same result.
Exact script was:
/* eslint-disable @typescript-eslint/no-var-requires */
const { ChargeBee } = require('chargebee-typescript');
const chargebee = new ChargeBee();
chargebee.configure({
site: '<SITE>',
api_key: '<API-KEY>',
});
chargebee.subscription.retrieve('77CnlTW8wTPg5i4q').request(function (error, result) {
if (error) {
console.log(error);
} else {
console.log(`${result.subscription}`);
const subscription = result.subscription;
const customer = result.customer;
const card = result.card;
console.log('>>>', subscription, customer, card);
}
});
Result:
/path/project/node_modules/chargebee-typescript/lib/resources/model.js:53
set_vals.push(new (resources)[this.sub_types[k]](item));
^
TypeError: resources[this.sub_types[k]] is not a constructor
at Subscription.load (/path/project/node_modules/chargebee-typescript/lib/resources/model.js:53:39)
at new Model (/path/project/node_modules/chargebee-typescript/lib/resources/model.js:28:14)
at new Subscription (/path/project/node_modules/chargebee-typescript/lib/resources/subscription.js:7:1)
at Result.get (/path/project/node_modules/chargebee-typescript/lib/result.js:284:16)
at Result.get subscription [as subscription] (/path/project/node_modules/chargebee-typescript/lib/result.js:26:34)
at /path/project/scripts/test.js:14:27
at Timeout._onTimeout (/path/project/node_modules/chargebee-typescript/lib/util.js:92:21)
at listOnTimeout (internal/timers.js:557:17)
at processTimers (internal/timers.js:500:7)
Please, note, that issue is not reproduced for some other subscriptions. But for this subscription it's reproduced consistently
@lightness What version you currently using of chargebee-typescript?
Latest one: 2.17.0. With 2.16.0 also reproduced
@lightness Could you please Raise a support ticket for this, with all the relevant details. So we can meet over a call to debug this.
Hi @lightness @markomitranic This issue has been fixed in v2.17.1. Requesting you to please use the latest version.
It's fixed! Thanks!
This morning, I started seeing this error coming out of
chargebee-typescript
. More specifically:I'm seeing this on the subscription API endpoint and only sometimes, seems on certain entities. I was unable to find out what is wrong with them more specifically, so I ended up replacing
result.subscription
withJSON.parse(String(result))["subscription"]
:P not ideal, by no means.I was hoping to get any insight from you what might be the issue. I'm on the latest npm version.