Пример #1
0
 public function get_installments()
 {
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     if ($order_info) {
         $data['total'] = number_format(floatval($order_info['total'] * 100), 0, '', '');
         $data['brand'] = $this->request->post['brand'];
         $options = $this->gerencianet_config_payment_api();
         $params = array('total' => $data['total'], 'brand' => $data['brand']);
         try {
             $api = new Gerencianet($options);
             $installments = $api->getInstallments($params, array());
             $this->result_api($installments, true);
         } catch (GerencianetException $e) {
             $errorResponse = array("code" => $e->code, "error" => $e->error, "message" => $e->errorDescription);
             $this->result_api($errorResponse, false);
         } catch (Exception $e) {
             $errorResponse = array("code" => 0, "message" => $e->getMessage());
             $this->result_api($errorResponse, false);
         }
     }
 }
Пример #2
0
<?php

require __DIR__ . '/../../vendor/autoload.php';
use Gerencianet\Exception\GerencianetException;
use Gerencianet\Gerencianet;
$file = file_get_contents(__DIR__ . '/../config.json');
$options = json_decode($file, true);
$params = ['total' => '20000', 'brand' => 'visa'];
try {
    $api = new Gerencianet($options);
    $installments = $api->getInstallments($params, []);
    print_r($installments);
} catch (GerencianetException $e) {
    print_r($e->code);
    print_r($e->error);
    print_r($e->errorDescription);
} catch (Exception $e) {
    print_r($e->getMessage());
}