PagarMe_Transaction::charge PHP Method

charge() public method

public charge ( )
    public function charge()
    {
        $this->create();
    }

Usage Example

 public function payment()
 {
     $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->config->get('dados_status')) {
         if ($customer['cpf'] != '') {
             $document_number = $this->removeSeparadores($customer['cpf']);
             $customer_name = $order_info['payment_firstname'] . " " . $order_info['payment_lastname'];
         } else {
             $document_number = $this->removeSeparadores($customer['cnpj']);
             $customer_name = $customer['razao_social'];
         }
         $numero = $order_info['payment_numero'];
         $complemento = $order_info['payment_company'];
     } else {
         $document_number = $this->removeSeparadores($order_info['payment_tax_id']);
         $customer_name = $order_info['payment_firstname'] . " " . $order_info['payment_lastname'];
         $numero = 'Sem número';
         $complemento = '';
     }
     Pagarme::setApiKey($this->config->get('pagar_me_cartao_api'));
     $transaction = new PagarMe_Transaction(array('amount' => $this->request->post['amount'], 'card_hash' => $this->request->post['card_hash'], 'installments' => $this->request->post['installments'], 'postback_url' => HTTP_SERVER . 'index.php?route=payment/pagar_me_cartao/callback', "customer" => array("name" => $customer_name, "document_number" => $document_number, "email" => $order_info['email'], "address" => array("street" => $order_info['payment_address_1'], "neighborhood" => $order_info['payment_address_2'], "zipcode" => $order_info['payment_postcode'], "street_number" => $numero, "complementary" => $complemento), "phone" => array("ddd" => substr(preg_replace('/[^0-9]/', '', $order_info['telephone']), 0, 2), "number" => substr(preg_replace('/[^0-9]/', '', $order_info['telephone']), 2)))));
     $transaction->charge();
     $status = $transaction->status;
     // status da transação
     $id_transacao = $transaction->id;
     $json = array();
     $this->log->write($status);
     $this->load->model('payment/pagar_me_cartao');
     if ($status == 'paid' || $status == 'processing') {
         $this->model_payment_pagar_me_cartao->addTransactionId($this->session->data['order_id'], $id_transacao, $this->request->post['installments'], $this->request->post['bandeira']);
         $json['success'] = true;
     } else {
         $this->model_payment_pagar_me_cartao->addTransactionId($this->session->data['order_id'], $id_transacao);
         $json['success'] = false;
     }
     $this->response->setOutput(json_encode($json));
 }
All Usage Examples Of PagarMe_Transaction::charge
PagarMe_Transaction