I just want to know if there is way to retrieve charges with multiples charges_id in stripe.
For example in the docs show how to get one charge. But we need get multiple charges. So, we don't want to made a multiple calls to the stripe method retrieve, this is to slow. We dont want to make this:
foreach ($result as $p_key => $payment) {
$charge = $this->CI->stripe_lib->retrieve_charge('ch_......', 'secret_key');
if (isset($charge['charge'])) {
$amount_charged = (float)$charge['charge']->amount / 100;
// echo "<pre>";
// print_r($amount_charged );
// echo "</pre>";
}
}
this is in Codeigniter. And this is the function on the library:
public function retrieve_charge($charge_id, $secret_key) {
$errors = array();
try {
\Stripe\Stripe::setApiKey($secret_key);
$charge = \Stripe\Charge::retrieve($charge_id);
return array('charge' => $charge);
} catch(Stripe_CardError $e) {
$errors = array('error' => false, 'message' => 'Card was declined.', 'e' => $e);
} catch (Stripe_InvalidRequestError $e) {
$errors = array('error' => false, 'message' => 'Invalid parameters were supplied to Stripe\'s API', 'e' => $e);
} catch (Stripe_AuthenticationError $e) {
$errors = array('error' => false, 'message' => 'Authentication with Stripe\'s API failed!', 'e' => $e);
} catch (Stripe_ApiConnectionError $e) {
$errors = array('error' => false, 'message' => 'Network communication with Stripe failed', 'e' => $e);
} catch (Stripe_Error $e) {
$errors = array('error' => false, 'message' => 'Stripe error. Something wrong just happened!', 'e' => $e);
} catch (Exception $e) {
if (isset($e->jsonBody['error']['type']) && $e->jsonBody['error']['type'] == 'idempotency_error') {
$errors = array('error' => false, 'message' => $e->getMessage(), 'e' => $e, 'type' => 'idempotency_error');
} else {
$errors = array('error' => false, 'message' => 'An error has occurred getting customer info.', 'e' => $e);
}
}
return $errors;
}
With this code: \Stripe\Charge::all(["limit" => 3]); returns all charge but in the docs I didn't see if this method returns me also a multiple charges id.
I appreciate all your help.
Thanks and I'm sorry for my english.