How to add components to a subscription using the chargify API

341 Views Asked by At

I have two products in my subscription: monthly subscription: $29.99 yearly subscription: $260

and have two components: monthly additional user: $5 yearly additional user: $60

my application has an option to add additional users after subscription. like: if he is subscribed for monthly his charge is 29.99 and he adds an additional user, so his charge will be increased to $34.99, and then if he adds another user his charge will be 39.99, and so on.

I am subscribing users by hosted page easily and web hooks are also ok.

But cant understand how I can do this second step.

Maybe I need to add the component to the subscription by the API.

How is this possible?

I am using this API. http://github.com/abraham/chargify

And I am not able to develop my own API.

1

There are 1 best solutions below

0
On

Yes you are right and you should follow http://docs.chargify.com/api-components

It has all things defined and i am showing you sample code how to do this.

$quantityBasedComponent = new ChargifyQuantityBasedComponent();

In your case, use above class and get all quantity first and then add 1 to it if user adds subuser to its subscription and update it. THE API classes (http://github.com/abraham/chargify) you have of Abraham have all this available.