divspace/chargeigniter

Migration problem

riscphree opened this issue · 1 comments

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.

Thank you. This has been updated.