Пример #1
0
	public function testCalculateInstallmentsAmount() {
		$request = PagarMe_Transaction::calculateInstallmentsAmount('10000', '1.5', '12');
		$installments = $request['installments'];	
		$this->assertEqual($installments["5"]["amount"], '10471');
		$this->assertEqual($installments["5"]["installment"],  '5');
		$this->assertEqual($installments["5"]["installment_amount"],  '2094');
	}
Пример #2
0
 public function testCalculateInstallmentsAmountWithInvalidFreeInstallments()
 {
     $request = PagarMe_Transaction::calculateInstallmentsAmount('90000', '2', '9', 13);
     $installments = $request['installments'];
     $this->assertEqual($installments["3"]["amount"], 90000);
     $this->assertEqual($installments["3"]["installment"], '3');
     $this->assertEqual($installments["3"]["installment_amount"], 30000);
 }
 protected function index()
 {
     $this->language->load('payment/pagar_me_cartao');
     $this->load->model('checkout/order');
     $this->load->model('account/customer');
     $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
     $customer = $this->model_account_customer->getCustomer($order_info['customer_id']);
     if ($this->customer->isLogged()) {
         $this->data['nome_cartao'] = $order_info['payment_firstname'] . ' ' . $order_info['payment_lastname'];
     }
     $this->data['total'] = str_replace(".", "", number_format($order_info['total'], 2, ".", ""));
     $this->data['button_confirm'] = $this->language->get('button_confirm');
     $this->data['text_information'] = $this->language->get('text_information');
     $this->data['text_wait'] = $this->language->get('text_wait');
     $this->data['text_information'] = $this->config->get('pagar_me_cartao_text_information');
     $this->data['url'] = $this->url->link('payment/pagar_me_cartao/confirm', '', 'SSL');
     $this->data['url2'] = $this->url->link('payment/pagar_me_cartao/error', '', 'SSL');
     /* Parcelas */
     Pagarme::setApiKey($this->config->get('pagar_me_cartao_api'));
     try {
         $numero_parcelas = floor($order_info['total'] / $this->config->get('pagar_me_cartao_valor_parcela'));
         $max_parcelas = $numero_parcelas ? $numero_parcelas : 1;
         if ($max_parcelas > $this->config->get('pagar_me_cartao_max_parcelas')) {
             $max_parcelas = $this->config->get('pagar_me_cartao_max_parcelas');
         }
         $this->data['parcelas'] = PagarMe_Transaction::calculateInstallmentsAmount($this->data['total'], $this->config->get('pagar_me_cartao_taxa_juros'), $max_parcelas, $this->config->get('pagar_me_cartao_parcelas_sem_juros'));
     } catch (Exception $e) {
         $this->log->write("Erro Pagar.me: " . $e->getTraceAsString());
         die;
     }
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/pagar_me_cartao.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/payment/pagar_me_cartao.tpl';
     } else {
         $this->template = 'default/template/payment/pagar_me_cartao.tpl';
     }
     // incluindo css
     if (file_exists('catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pagar_me_cartao.css')) {
         $this->data['stylesheet'] = 'catalog/view/theme/' . $this->config->get('config_template') . '/stylesheet/pagar_me_cartao.css';
     } else {
         $this->data['stylesheet'] = 'catalog/view/theme/default/stylesheet/pagar_me_cartao.css';
     }
     $this->render();
 }