divspace / chargeigniter

Chargify API for CodeIgniter
23 stars 11 forks source link

Getting results of failed CC charge #1

Closed kmesiab closed 13 years ago

kmesiab commented 13 years ago

I am creating a customer and subscription at the same time. I'm assuming a general failure of some sort as the results of the function call ->create_subscription returns NULL.

How can I get information on why this charge failed?

kmesiab commented 13 years ago

Fixed by adjusting function chargify function to:

public function create_subscription($data) {
    $data = array(
        'subscription' => $data
    );

    $result = $this->query('/subscriptions.json', 'post', $data);

    if($result->code == 201) {
        $subscription = json_decode($result->response);

        if(count($subscription) == 1) {
            return $subscription->subscription;
        }

        return false;
    }

    $this->error($result->response, $result->code);
    return json_decode($result->response);
}
ChargeIgniter commented 13 years ago

I'm going to guess that the error wasn't displaying because you had debug mode off, please make sure this is set to true:

$debug = true;