crucialwebstudio / chargify-sdk-php

Chargify SDK for PHP
Apache License 2.0
26 stars 44 forks source link

Suggestion to clarify docs on Subscription migrate() #8

Closed brynnb closed 8 years ago

brynnb commented 8 years ago

Took me probably an hour of confusion before realizing the $id you pass into migrate($id) is the ID of the existing subscription, not the ID of the plan you wish to migrate to. I was trying to figure out how to create an instance of a Subscription object that referred to an existing subscription, then calling ->migrate($newProductID) on that. As far as I can tell, you cannot create an instance of an existing Subscription. Only option I found was to use listByCustomer() but that returns an array when you use offsetGet().

For posterity and anyone else who finds this and is confused, it will look something like this:

$chargify->subscription()->setProductId($newProductID)->migrate($existingSubscriptionID);

dan-bowen commented 8 years ago

Thanks for the feedback. I agree that these methods could be more intuitive. I also realize we need better documentation, which we'll be working on. In the meantime I have documented the code to make this a little more clear. Please see this commit: https://github.com/chargely/chargify-sdk-php/commit/ee324c449a9617c525afc47e63e3146b5eae0cbb

brynnb commented 8 years ago

Even just a single sentence and single line of code for the popular features would be a tremendous help for a lot people. For people unfamiliar with APIs, or unfamiliar working with code structured like this specific API, it can be time consuming to figure out these basic things.

Thanks for all the work!

brynnb commented 8 years ago

Another confusing example:

In my Laravel app (that has a wrapper for Chargify SDK) I get the info of a customer by doing this:

$customer = Chargify::customer()->setReference($user->id)->readByReference();

I would expect something more like this:

$customer = Chargify::customer(["reference"=>"some-reference"]);

or at the very least, something like

$customer = Chargify::customer()->readByReference("some-reference");

so that it works in the same way as reading it by ID (which the SDK allows)

$customer = Chargify::customer()->readByChargifyId(112942);

Not the most intuitive concept for someone who might be new.

dan-bowen commented 8 years ago

Thanks for the suggestions. I'll keep these in mind as we continue to develop the SDK. BTW... I just tagged v0.1.0 which uses Guzzle 6.

brynnb commented 8 years ago

Awesome thank you.