divspace / chargeigniter

Chargify API for CodeIgniter
23 stars 11 forks source link

Migration problem #5

Closed riscphree closed 13 years ago

riscphree commented 13 years ago

We were trying to use your code to upgrade/downgrade, and we just re-wrote it so that it works, code follows.

You have:

public function upgrade_subscription($subscription_id, $data) {
  $data = array(
   'subscription' => $data
  );

When it needs to be 'migration', as seen below. This is the working code.

public function upgrade_subscription($subscription_id, $data) {
    $data = array(
        'migration' => array('product_id' => $data)
    );

    $result = $this->query('/subscriptions/'.$subscription_id.'/migrations.json', 'post', $data);
    return $result;
    if($result->code == 200) {
        $subscription = json_decode($result->response);
        if(count($subscription) == 1) {
            return $subscription->subscription;
        }

        return false;
    }
    $this->error($result->response, $result->code);
}

Feel free to close this.

ChargeIgniter commented 13 years ago

Thank you. This has been updated.