protected function send_to_conekta()
 {
     global $woocommerce;
     include_once 'conekta_gateway_helper.php';
     Conekta::setApiKey($this->secret_key);
     Conekta::setLocale("es");
     $data = getRequestData($this->order);
     try {
         $line_items = array();
         $items = $this->order->get_items();
         $line_items = build_line_items($items);
         $details = build_details($data, $line_items);
         $charge = Conekta_Charge::create(array("amount" => $data['amount'], "currency" => $data['currency'], "monthly_installments" => $data['monthly_installments'] > 1 ? $data['monthly_installments'] : null, "card" => $data['token'], "reference_id" => $this->order->id, "description" => "Compra con orden # " . $this->order->id, "details" => $details));
         $this->transactionId = $charge->id;
         if ($data['monthly_installments'] > 1) {
             update_post_meta($this->order->id, 'meses-sin-intereses', $data['monthly_installments']);
         }
         update_post_meta($this->order->id, 'transaction_id', $this->transactionId);
         return true;
     } catch (Conekta_Error $e) {
         $description = $e->message_to_purchaser;
         global $wp_version;
         if (version_compare($wp_version, '4.1', '>=')) {
             wc_add_notice(__('Error: ', 'woothemes') . $description, $notice_type = 'error');
         } else {
             error_log('Gateway Error:' . $description . "\n");
             $woocommerce->add_error(__('Error: ', 'woothemes') . $description);
         }
         return false;
     }
 }
 public function testRefund()
 {
     authorizeFromEnv();
     $c = Conekta_Charge::create(array('amount' => 2000, 'currency' => 'mxn', 'description' => 'Some desc', 'card' => array('number' => '4242424242424242', 'exp_month' => 5, 'exp_year' => 2015, 'cvc' => 123, 'name' => 'Mario Moreno')));
     $c->refund();
     $this->assertTrue($c->status == "refunded");
 }
 public function testBadData()
 {
     authorizeFromEnv();
     try {
         Conekta_Charge::create();
     } catch (Conekta_InvalidRequestError $e) {
         $this->assertEqual(400, $e->getHttpStatus());
     }
 }
function conektabanorte_link($params)
{
    # Variables de Conekta
    $private_key = $params['private_key'];
    # Variables de la Factura
    $invoiceid = $params['invoiceid'];
    $amount = $params['amount'];
    $currency = $params['currency'];
    # Variables del cliente
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];
    $results = array();
    # Preparamos todos los parametros para enviar a Conekta.io
    $data_amount = str_replace('.', '', $amount);
    $data_currency = strtolower($currency);
    $data_description = 'Pago Factura No. ' . $invoiceid;
    # Incluimos la libreria de Conecta
    require_once 'conekta/lib/Conekta.php';
    # Creamos el Objeto de Cargo
    Conekta::setApiKey($private_key);
    # Arraglo con informacion de tarjeta
    $conekta = array('description' => $data_description, 'reference_id' => 'factura_' . $invoiceid, 'amount' => intval($data_amount), 'currency' => $data_currency, 'bank' => array('type' => 'banorte'));
    try {
        $charge = Conekta_Charge::create($conekta);
        # Transaccion Correcta
        $data = json_decode($charge);
        $service_name = $data->payment_method->service_name;
        $service_number = $data->payment_method->service_number;
        $type = $data->payment_method->type;
        $reference = $data->payment_method->reference;
        $ticket = 1;
    } catch (Exception $e) {
        $code = "Error al intentar generar pago en OXXO";
        $ticket = 0;
    }
    if ($ticket == 1) {
        $code = '<form action="conekta_banorte.php" method="post" target="_blank">';
        $code .= '<input type="hidden" name="service_name" value="' . $service_name . '" />';
        $code .= '<input type="hidden" name="service_number" value="' . $service_number . '" />';
        $code .= '<input type="hidden" name="reference" value="' . $reference . '" />';
        $code .= '<input type="hidden" name="monto" value="' . $amount . '" />';
        $code .= '<input type="hidden" name="concepto" value="' . $data_description . '" />';
        $code .= '<input type="submit" value="Pagar ahora" />';
        $code .= '</form>';
    }
    return $code;
}
 public static function card($amount, $number, $exp_month, $exp_year, $cvc, $name)
 {
     Conekta::setApiKey(self::$api_key);
     $data = array('card' => array('number' => $number, 'exp_month' => $exp_month, 'exp_year' => $exp_year, 'cvc' => $cvc, 'name' => $name), 'description' => self::$description, 'amount' => $amount, 'currency' => self::$currency);
     try {
         $charge = Conekta_Charge::create($data);
         echo 'Thanks for your donation';
     } catch (Exception $e) {
         // Catch all exceptions including validation errors.
         echo $e->getMessage();
     }
 }
 public function testDecline()
 {
     authorizeFromEnv();
     try {
         Conekta_Charge::create(array('amount' => 2000, 'currency' => 'mxn', 'description' => 'Some desc', 'card' => array('number' => '4000000000000002', 'exp_month' => 5, 'exp_year' => 2015, 'cvc' => 123, 'name' => 'Mario Moreno')));
     } catch (Conekta_CardError $e) {
         $this->assertEqual(402, $e->getHttpStatus());
         $body = $e->getJsonBody();
         $this->assertTrue($body['object'] == 'error');
         $this->assertTrue($body['message'] == 'The card was declined');
     }
 }
 function makePayment($amount, $refId, $token, $user)
 {
     if (!$amount || !$refId || !$token) {
         return false;
     }
     try {
         $charge = Conekta_Charge::create(array("amount" => $amount, "currency" => "MXN", "description" => "Compra en Plaza de la Tecnología", "reference_id" => $refId, "card" => $token, "details" => array("email" => $user['email'])));
         return $charge;
     } catch (Conekta_Error $e) {
         return $e->getMessage();
         //el pago no pudo ser procesado
     }
 }
Exemple #8
0
 public function cobra_cliente()
 {
     require_once "lib/Conekta.php";
     Conekta::setApiKey("key_uexJEsPgPzz55V4HzYugow");
     // Llave Privada Conekta
     try {
         $charge = Conekta_Charge::create(array("amount" => 31000, "currency" => "MXN", "description" => "Pizza Delivery", "reference_id" => "orden_de_id_interno", "card" => "tok_test_visa_4242", "details" => array("email" => "*****@*****.**", "line_items" => array(array("name" => "Box of Cohiba S1s", "sku" => "cohb_s1", "unit_price" => 31000, "description" => "Imported from Mex.", "quantity" => 2, "type" => "pizza-purchase")))));
     } catch (Conekta_Error $e) {
         echo $e->getMessage();
         //el pago no pudo ser procesado
     }
     $this->consultas();
 }
Exemple #9
0
 public function checkout()
 {
     $response['responseStatus'] = "Not OK";
     // private key of conekta dashboard
     Conekta::setApiKey('key_Fq5U8GUU28hTqgxy4md4TQ');
     try {
         $charge = Conekta_Charge::create(array("amount" => $this->input->post("amount"), "currency" => "MXN", "description" => $this->input->post("description"), "reference_id" => $this->input->post("reference_id"), "card" => $this->input->post("token")));
         var_dump($charge);
         //echo json_encode($charge);
     } catch (Conekta_Error $e) {
         echo $e->getMessage();
         //El pago no pudo ser procesado
     }
 }
Exemple #10
0
 public static function card($amount, $number, $exp_month, $exp_year, $cvc, $name)
 {
     Conekta::setApiKey(self::$api_key);
     $data = array('card' => array('number' => $number, 'exp_month' => $exp_month, 'exp_year' => $exp_year, 'cvc' => $cvc, 'name' => $name), 'description' => self::$description, 'amount' => $amount, 'currency' => self::$currency);
     try {
         $charge = Conekta_Charge::create($data);
         $token = $charge->status;
         if ($token == 'paid') {
             require_once '../model/init.php';
             require_once '../model/mail_pagos_exitosos.php';
             header('Location: ../aprobado.html');
         }
     } catch (Exception $e) {
         // Catch all exceptions including validation errors.
         //            echo $e->getMessage();
         //            $error = $charge->status;
         //            echo $error;
         header('Location: ../rechazado.html');
     }
 }
 protected function send_to_conekta()
 {
     global $woocommerce;
     include_once 'conekta_gateway_helper.php';
     Conekta::setApiKey($this->secret_key);
     Conekta::setLocale("es");
     $data = getRequestData($this->order);
     $line_items = array();
     $items = $this->order->get_items();
     $line_items = build_line_items($items);
     $details = build_details($data, $line_items);
     try {
         $charge = Conekta_Charge::create(array("amount" => $data['amount'], "currency" => $data['currency'], "reference_id" => $this->order->id, "description" => "Recibo de pago para orden # " . $this->order->id, "cash" => array("type" => "oxxo"), "details" => $details));
         $this->transactionId = $charge->id;
         update_post_meta($this->order->id, 'conekta-id', $charge->id);
         update_post_meta($this->order->id, 'conekta-creado', $charge->created_at);
         update_post_meta($this->order->id, 'conekta-expira', $charge->payment_method->expiry_date);
         update_post_meta($this->order->id, 'conekta-barcode', $charge->payment_method->barcode);
         update_post_meta($this->order->id, 'conekta-barcodeurl', $charge->payment_method->barcode_url);
         return true;
     } catch (Conekta_Error $e) {
         $description = $e->message_to_purchaser;
         global $wp_version;
         if (version_compare($wp_version, '4.1', '>=')) {
             wc_add_notice(__('Error: ', 'woothemes') . $description, $notice_type = 'error');
         } else {
             error_log('Gateway Error:' . $description . "\n");
             $woocommerce->add_error(__('Error: ', 'woothemes') . $description);
         }
         return false;
     }
 }
 public function getPay()
 {
     if (Request::ajax()) {
         try {
             $oferta = $this->oferta->find(Request::get('Oferta'));
             $precio = $oferta->Precio * 100;
             $key = $oferta->vendedor()->first()->Privada;
             \Conekta::setApiKey($key);
             $charge = \Conekta_Charge::create(array("amount" => $precio, "currency" => "MXN", "description" => "Refacccion para " . $oferta->getPublish()->Nombre, "reference_id" => $oferta->idOferta, "card" => Request::get('Token')));
             if ($charge->status === 'paid') {
                 $oferta->Estado = 'B';
                 $oferta->Status = '4';
                 $oferta->save();
                 $publicacion = $oferta->getPublish();
                 $publicacion->Status = '2';
                 $publicacion->save();
                 $dataBuy = array('forma' => 'Pago REFANET', 'status' => 'A', 'oferta' => $oferta->idOferta, 'publicacion' => $publicacion->idPublicacion);
                 $compra = $this->saveBuy($dataBuy);
                 $dataNote = array('Usuario' => $oferta->vendedor()->first()->Usuario, 'Contenido' => 'Han realizado el pago por ' . '<strong>' . $publicacion->refaccion()->first()->Nombre . '</strong> ', 'Url' => '/Vendedor/Ventas/', 'Publicacion' => $publicacion->idPublicacion);
                 $this->nota->newNote($dataNote);
                 return array('ok' => true);
             } else {
                 return array('ok' => false);
             }
         } catch (Conekta_Error $e) {
             echo $e->getMessage();
             //El pago no pudo ser procesado
         }
     }
 }
Exemple #13
0
 public function getPay()
 {
     if (Request::ajax()) {
         \Conekta::setApiKey('key_w5B9koxHsk7MxCry');
         $plan = Request::get('Plan');
         $vendedor = Session::get('Seller');
         try {
             $intervalo = 'P1M';
             if ($plan === 'Mes') {
                 $precio = 400;
             } else {
                 if ($plan === 'Anual') {
                     $precio = 3990;
                     $intervalo = 'P1Y';
                 } else {
                     if ($plan === 'Semestral') {
                         $precio = 2000;
                         $intervalo = 'P6M';
                     }
                 }
             }
             $cliente = $this->cliente->newClient($vendedor);
             $fecha = new DateTime(date("Y-m-d"));
             $intervalo = new DateInterval($intervalo);
             $fin = $fecha->add($intervalo);
             $contrato = $this->contrato->newContract($cliente->idClientes, $fin, $plan);
             //Creamos la sesion de contrato para mostrar los datos al final
             Session::put('Contrato', $contrato->idContrato);
             $charge = \Conekta_Charge::create(array("amount" => $precio * 100, "currency" => "MXN", "description" => "Pago " . Request::get('Plan') . ' del vendedor ' . $vendedor, "reference_id" => $contrato->idContrato . '/' . $cliente->idClientes, "card" => Request::get('Token')));
             if ($charge->status === 'paid') {
                 $data = array('Forma' => 'Tarjeta de crédito', 'Monto' => $precio, 'Contrato' => $contrato->idContrato);
                 $pago = $this->pago->newPay($data);
                 return array('ok' => true);
             } else {
                 return array('ok' => false);
             }
         } catch (Conekta_Error $e) {
             echo $e->getMessage();
             //El pago no pudo ser procesado
         }
     }
 }
Exemple #14
0
function conektacard_capture($params)
{
    # Variables de Conekta
    $private_key = $params['private_key'];
    # Variables de la Factura
    $invoiceid = $params['invoiceid'];
    $amount = $params['amount'];
    $currency = $params['currency'];
    # Variables del cliente
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];
    # Informacion de la Tarjeta
    $cardtype = $params['cardtype'];
    $cardnumber = $params['cardnum'];
    $cardexpiry = $params['cardexp'];
    $cardissuenum = $params['cccvv'];
    $results = array();
    # Preparamos todos los parametros para enviar a Conekta.io
    $card_num = $cardnumber;
    $card_cvv = $cardissuenum;
    $card_exp_month = substr($cardexpiry, 0, 2);
    $card_exp_year = substr($cardexpiry, 2, 4);
    $card_name = $firstname . ' ' . $lastname;
    $data_amount = str_replace('.', '', $amount);
    $data_currency = strtolower($currency);
    $data_description = 'Pago Factura No. ' . $invoiceid;
    # Incluimos la libreria de Conecta 1.0
    // Usaremos la libreria 1.0 para procesar tarjeta de Credito / Debito
    // Parche para enviar cargos sin tokenizar !!!
    // Todavia no resuelvo el problema para tokenizar los datos de la tarjeta ... alguien que me ayude???
    // CarlosCesar110988@gmail.om
    require_once 'conekta/lib_1.0/Conekta.php';
    # Creamos el Objeto de Cargo
    Conekta::setApiKey($private_key);
    # Arraglo con informacion de tarjeta
    $card = array('number' => $card_num, 'exp_month' => intval($card_exp_month), 'exp_year' => intval('20' . $card_exp_year), 'cvc' => intval($card_cvv), 'name' => $card_name, 'address' => array('street1' => $address1, 'city' => $city, 'state' => $state, 'zip' => $postcode, 'country' => $country));
    try {
        # Arraglo con informacion del cargo
        # Actualizacion 1.3 * 15 Agosto - 2015 Gracias a C. Randall
        $conekta = array('card' => $card, 'description' => $data_description, 'amount' => intval($data_amount), 'currency' => $data_currency, 'details' => array('email' => $email, 'phone' => $phone, 'name' => $firstname . ' ' . $lastname, 'line_items' => array(array('name' => $data_description, 'sku' => $invoiceid, 'unit_price' => intval($data_amount), 'description' => $data_description, 'quantity' => 1, 'type' => 'service-purchase'))));
        $charge = Conekta_Charge::create($conekta);
        # Transaccion Correcta
        $data = json_decode($charge);
        $results['status'] = 'success';
        $results['transid'] = $data->payment_method->auth_code;
        $results['data'] = 'OK';
    } catch (Exception $e) {
        # Transaccion Declinada
        $results['status'] = 'declined';
        $results['transid'] = $data->payment_method->auth_code;
        $results['data'] = $e->getMessage();
    }
    # Validamos los resultados
    if ($results['status'] == 'success') {
        return array('status' => 'success', 'transid' => $results['transid'], 'rawdata' => 'OK');
    } elseif ($gatewayresult == 'declined') {
        return array('status' => 'declined', 'rawdata' => $results);
    } else {
        return array('status' => 'error', 'rawdata' => $results);
    }
}
<?php

require_once "lib/Conekta.php";
Conekta::setApiKey("key_9sBD44QqHXusjLLFhRBKZQ");
try {
    $charge = Conekta_Charge::create(array('description' => 'Pago de servicio FAST PRICE', 'reference_id' => '9839-wolf_pack', 'amount' => 1228700, 'currency' => 'MXN', 'card' => 'tok_test_visa_4242', 'details' => array('name' => 'Arnulfo Quimare', 'phone' => '403-342-0642', 'email' => '*****@*****.**', 'customer' => array('logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, 'score' => 9), 'line_items' => array(array('name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food')))));
} catch (Exception $e) {
    echo $e;
}
require_once '../views/header.inc';
require_once '../views/helperPago.php';
require_once '../views/footer.inc';
function conektacard_capture($params)
{
    # Variables de Conekta
    $private_key = $params['private_key'];
    # Variables de la Factura
    $invoiceid = $params['invoiceid'];
    $amount = $params['amount'];
    $currency = $params['currency'];
    # Variables del cliente
    $firstname = $params['clientdetails']['firstname'];
    $lastname = $params['clientdetails']['lastname'];
    $email = $params['clientdetails']['email'];
    $address1 = $params['clientdetails']['address1'];
    $address2 = $params['clientdetails']['address2'];
    $city = $params['clientdetails']['city'];
    $state = $params['clientdetails']['state'];
    $postcode = $params['clientdetails']['postcode'];
    $country = $params['clientdetails']['country'];
    $phone = $params['clientdetails']['phonenumber'];
    # Informacion de la Tarjeta
    $cardtype = $params['cardtype'];
    $cardnumber = $params['cardnum'];
    $cardexpiry = $params['cardexp'];
    $cardissuenum = $params['cccvv'];
    $results = array();
    # Preparamos todos los parametros para enviar a Conekta.io
    $card_num = $cardnumber;
    $card_cvv = $cardissuenum;
    $card_exp_month = substr($cardexpiry, 0, 2);
    $card_exp_year = substr($cardexpiry, 2, 4);
    $card_name = $firstname . ' ' . $lastname;
    $data_amount = str_replace('.', '', $amount);
    $data_currency = strtolower($currency);
    $data_description = 'Pago Factura No. ' . $invoiceid;
    # Incluimos la libreria de Conecta
    require_once 'conekta/lib/Conekta.php';
    # Creamos el Objeto de Cargo
    Conekta::setApiKey($private_key);
    # Arraglo con informacion de tarjeta
    $card = array('number' => $card_num, 'exp_month' => intval($card_exp_month), 'exp_year' => intval('20' . $card_exp_year), 'cvc' => intval($card_cvv), 'name' => $card_name, 'address' => array('street1' => $address1, 'city' => $city, 'state' => $state, 'zip' => $postcode, 'country' => $country));
    try {
        # Arraglo con informacion del cargo
        $conekta = array('card' => $card, 'description' => $data_description, 'amount' => intval($data_amount), 'currency' => $data_currency);
        $charge = Conekta_Charge::create($conekta);
        # Transaccion Correcta
        $data = json_decode($charge);
        $results['status'] = 'success';
        $results['transid'] = $data->payment_method->auth_code;
        $results['data'] = 'OK';
    } catch (Exception $e) {
        # Transaccion Declinada
        $results['status'] = 'declined';
        $results['transid'] = $data->payment_method->auth_code;
        $results['data'] = $e->getMessage();
    }
    # Validamos los resultados
    if ($results['status'] == 'success') {
        return array('status' => 'success', 'transid' => $results['transid'], 'rawdata' => 'OK');
    } elseif ($gatewayresult == 'declined') {
        return array('status' => 'declined', 'rawdata' => $results);
    } else {
        return array('status' => 'error', 'rawdata' => $results);
    }
}
Exemple #17
0
function conektaSPEI()
{
    require_once "libraries/conekta/Conekta.php";
    Conekta::setApiKey("key_eYvWV7gSDkNYXsmr");
    $charge = Conekta_Charge::create(array('description' => 'Stogies', 'reference_id' => '9839-wolf_pack', 'amount' => 20000, 'currency' => 'MXN', 'bank' => array('type' => 'spei'), 'details' => array('name' => 'Arnulfo Quimare', 'phone' => '403-342-0642', 'email' => '*****@*****.**', 'customer' => array('logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, 'score' => 9), 'line_items' => array(array('name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food')), 'billing_address' => array('street1' => '77 Mystery Lane', 'street2' => 'Suite 124', 'street3' => null, 'city' => 'Darlington', 'state' => 'NJ', 'zip' => '10192', 'country' => 'Mexico', 'tax_id' => 'xmn671212drx', 'company_name' => 'X-Men Inc.', 'phone' => '77-777-7777', 'email' => '*****@*****.**'))));
    print $charge->payment_method->clabe;
    print $charge->payment_method->bank;
}
Exemple #18
0
<?php

error_reporting(E_ALL);
require_once "../conekta/lib/Conekta.php";
Conekta::setApiKey("key_eYvWV7gSDkNYXsmr");
Conekta::setLocale('es');
try {
    // Llamada a Conekta...
    $charge = Conekta_Charge::create(array('description' => 'Stogies', 'reference_id' => '9839-wolf_pack', 'amount' => 20000, 'currency' => 'MXN', 'card' => 'tok_test_insufficient_funds', 'details' => array('name' => 'Arnulfo Quimare', 'phone' => '403-342-0642', 'email' => '*****@*****.**', 'customer' => array('logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, 'score' => 9), 'line_items' => array(array('name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'category' => 'food')), 'billing_address' => array('street1' => '77 Mystery Lane', 'street2' => 'Suite 124', 'street3' => null, 'city' => 'Darlington', 'state' => 'NJ', 'zip' => '10192', 'country' => 'Mexico', 'tax_id' => 'xmn671212drx', 'company_name' => 'X-Men Inc.', 'phone' => '77-777-7777', 'email' => '*****@*****.**'))));
} catch (Conekta_Error $e) {
    echo $e->getMessage();
}
// $token = $charge->status;
//
//
//if ($token == 'paid') {
//
////require_once 'init.php';
header('Location: ../aprobado.html');
//}else {
//    //header('Location: ../rechazado.html');
//}
?>

Exemple #19
0
<?php

require_once "libraries/conekta/Conekta.php";
Conekta::setApiKey("key_nvJm2aBVNEd1qxPwxzzwrA");
$name = $_POST["name"];
$email = $_POST["email"];
$concept = $_POST["concept"];
$amount = $_POST["amount"];
$dir = '/var/www/html/facturas/';
$charge = Conekta_Charge::create(array('description' => 'Fanbot Plan', 'reference_id' => '01', 'amount' => $amount . '00', 'currency' => 'MXN', 'bank' => array('type' => 'spei'), 'details' => array('name' => $name, 'email' => $email, 'customer' => array(), 'line_items' => array(array('name' => 'Fanbot plan mensual', 'description' => $concept, 'unit_price' => $amount . '00', 'quantity' => 1, 'sku' => '750', 'category' => 'Interacción')), 'billing_address' => array())));
echo '"Nombre":"' . $name . '"';
echo '{';
echo '"Nombre":"' . $charge->details["name"] . '"';
echo ',';
echo '"Email":"' . $charge->details["email"] . '"';
echo ',';
echo '"Concepto":"' . $charge->details["line_items"][0]["description"] . '"';
echo ',';
echo '"Cantidad":"' . $charge->amount . '"';
echo ',';
echo '"CLABE":"' . $charge->payment_method->clabe . '"';
echo '}';
echo '<br>';
if (!file_exists($dir) && !is_dir($dir)) {
    mkdir($dir);
}
if (move_uploaded_file($_FILES['xmlfile']['tmp_name'], $dir . $email . '-' . $charge->payment_method->clabe . '-factura.xml')) {
    echo "El fichero es válido y se subió con éxito.\n";
} else {
    echo "¡Posible ataque de subida de ficheros!\n";
}
 public function process_payment($invitado = false, $guardar_tarjeta = false)
 {
     require_once "conekta/Conekta.php";
     Conekta::setApiKey($this->privatekey);
     /*CREAMOS USUARIO*/
     $id_comprador = get_user_meta($this->comprador, '_id_conekta', true);
     if (!$id_comprador) {
         try {
             $comprador = get_user_by('id', $this->comprador);
             $customer = Conekta_Customer::create(array("name" => $comprador->display_name, "email" => $comprador->user_email, "cards" => array($this->token)));
             update_user_meta($this->comprador, '_id_conekta', $customer->id);
             /*COMO ES LA PRIMERA VEZ CONFIGURAMOS EL TOKEN CON LA TARJETA ACTIVA DEL USUARIO*/
             $this->token = reset($customer->cards);
             $this->token = $this->token->id;
         } catch (Conekta_Error $e) {
             //El pago no pudo ser procesado
             $mensaje = $e->getMessage();
             $this->mensajes->add_error($mensaje);
             return;
         }
     } else {
         /*ES UN USUARIO YA CREADO*/
         /*TOCA COMPROBAR QUE EL TOKEN SEA EXISTENTE*/
         $tarjetas = get_tarjetas($this->comprador);
         if (!isset($tarjetas[$this->token]) && $guardar_tarjeta) {
             try {
                 /*añadimos tarjeta al usuario*/
                 $customer = Conekta_Customer::find($id_comprador);
                 $card = $customer->createCard(array('token' => $this->token));
                 $tarjeta = array('token' => $card->id, 'nombre' => $card->name, 'digitos' => $card->last4, 'brand' => $card->brand);
                 if ($guardar_tarjeta) {
                     guardar_tarjeta_en_user($tarjeta, $this->comprador);
                 }
                 $this->token = $tarjeta['token'];
             } catch (Conekta_Error $e) {
                 //El pago no pudo ser procesado
                 $mensaje = $e->getMessage();
                 $this->mensajes->add_error($mensaje);
                 return;
             }
         }
     }
     $data_user = get_user_by('id', $this->comprador);
     /*GENERAMOS DATOS DE TRANSACCION*/
     $transaccion = array("amount" => $this->monto, "currency" => "MXN", "description" => "Compra en Síclo.com", "card" => $this->token, "details" => array("email" => $data_user->user_email, "line_items" => array()));
     /*
      **GENERAREMOS LOS DATOS DE LOS LINE_ITEMS
      **TANTO EN PRODUCTOS COMO EN PAQUETES
      */
     if ($this->paquete_objeto) {
         $transaccion['details']["line_items"][] = array("name" => "Paquete de " . $this->paquete_objeto->data['cantidad'] . " clases", "unit_price" => $this->paquete_objeto->data['precio'], "description" => "Paquete de " . $this->paquete_objeto->data['cantidad'] . " clases", "quantity" => 1, "type" => "paquete-clases");
     }
     if ($this->productos) {
         foreach ($this->productos as $producto) {
             $transaccion['details']["line_items"][] = array("name" => $producto['producto']->titulo, "unit_price" => $producto['producto']->precio, "description" => $producto['producto']->titulo, "quantity" => $producto['cantidad'], "type" => "producto-back");
         }
     }
     //CREAR PEDIDO
     $args = array('post_title' => "", 'post_status' => 'pending', 'post_type' => 'pedido', 'post_author' => $this->comprador);
     $idPedido = wp_insert_post($args);
     if ($idPedido) {
         $this->idPedido = $idPedido;
         /*GUARDAMOS ENVÍO DE DATOS*/
         update_post_meta($idPedido, 'transaccion', $transaccion);
         update_post_meta($idPedido, '_info_paquete', $this->paquete_objeto);
         update_post_meta($idPedido, '_paquete', $this->paquete);
         update_post_meta($idPedido, '_productos', $this->productos);
         update_post_meta($idPedido, '_expiracion', $this->paquete_objeto->fecha_expiracion($this->paquete_objeto->data['expiracion'], true));
         /*SE GUARDA PARA MOSTRARLO EN EL HISTORIAL*/
     } else {
         $this->mensajes->add_error('No se ha podido finalizar la transaccion.');
         return;
     }
     $transaccion["reference_id"] = urlencode($idPedido);
     try {
         $pago = Conekta_Charge::create($transaccion);
         /*GUARDAMOS SIEMPRE RESPUESTA*/
         update_post_meta($idPedido, 'respuesta_transaccion', serialize($pago));
         $tarjeta = array('token' => $this->token, 'nombre' => $pago->payment_method->name, 'digitos' => $pago->payment_method->last4, 'brand' => $pago->payment_method->brand);
         if ($guardar_tarjeta) {
             guardar_tarjeta_en_user($tarjeta, $this->comprador);
         }
         mail_de_compra_clases($idPedido);
         $this->finalizar_compra($invitado);
         return;
     } catch (Conekta_Error $e) {
         //El pago no pudo ser procesado
         $mensaje = $e->getMessage();
         $this->mensajes->add_error($mensaje);
         /*GUARDAMOS SIEMPRE RESPUESTA*/
         update_post_meta($idPedido, 'respuesta_transaccion', $mensaje);
         return;
     }
 }
     $errors['colony'] = 'Ingresa el nombre de la colinia.';
 }
 if (empty($_POST['colony'])) {
     $errors['colony'] = 'Ingresa el nombre de la colinia.';
 }
 if (empty($_POST['city'])) {
     $errors['city'] = 'Ingresa el nombre de la ciudad donde vives.';
 }
 if (empty($_POST['state'])) {
     $errors['state'] = 'Ingresa el nombre del la ciudad o estado donde vives.';
 }
 if (empty($_POST['postal_code'])) {
     $errors['postal_code'] = 'Ingresa el número de código postal';
 }
 try {
     $charge = Conekta_Charge::create(array('amount' => '40000', 'currency' => 'MXN', 'description' => 'Libro', 'reference_id' => '9839-wolf_pack', 'card' => $_POST['conektaTokenId'], 'details' => array('name' => $user_name, 'phone' => $phone, 'email' => $user_email, 'customer' => array('corporation_name' => 'Conekta Inc.', 'logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, 'score' => 9), 'line_items' => array(array('name' => 'Box of Cohiba S1s', 'description' => 'Imported From Mex.', 'unit_price' => 20000, 'quantity' => 1, 'sku' => 'cohb_s1', 'type' => 'Libto')))));
     $toke = $charge->status;
     if ($toke == 'paid') {
         require_once '../model/pago_libro.php';
         require_once '../model/pago_cliente.php';
         $pertence = 'compra_libro';
         mysqli_select_db($con, "{$dbname}");
         $query = mysqli_query($con, "INSERT INTO Usuarios (Nombre,Email,telefono,calle,num_ext,num_int,colonia,ciudad,del_mun,codigo_postal,pertenece_a) VALUES ('{$user_name}','{$user_email}','{$phone}','{$street}','{$ext_number}','{$int_number}','{$colony}','{$city}','{$state}','{$postal_code}','{$pertence}')");
         mysqli_close($con);
         $output = json_encode(array('type' => 'message', 'text' => 'Feliciades tu pago ha sido aprobado,recibirás un correo con más detalles'));
         die($output);
     }
 } catch (Exception $ex) {
     $output = json_encode(array('type' => 'error', 'text' => 'Lo sentimos tu pago no pudo ser procesado,Intentalo de nuevo.', 'error' => $ex->getMessage()));
     die($output);
 }
 /**
  * Process a payment, where the magic happens
  *
  * @param string $token CONEKTA Transaction ID (token)
  */
 public function processPayment($token, $type, $monthly_installments)
 {
     /* If 1.4 and no backward, then leave */
     if (!$this->backward) {
         return;
     }
     if (!$token && $type == "card") {
         if (version_compare(_PS_VERSION_, '1.4.0.3', '>') && class_exists('Logger')) {
             Logger::addLog($this->l('Conekta - Payment transaction failed.') . ' Message: A valid Conekta token was not provided', 3, null, 'Cart', (int) $this->context->cart->id, true);
         }
         $controller = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc.php' : 'order.php';
         $location = $this->context->link->getPageLink($controller, true) . (strpos($controller, '?') !== false ? '&' : '?') . 'step=3&message_to_purchaser=token&conekta_error=1#conekta_error';
         Tools::redirectLink($location);
     }
     require_once dirname(__FILE__) . '/lib/conekta-php/lib/Conekta.php';
     Conekta::setApiKey(Configuration::get('CONEKTA_MODE') ? Configuration::get('CONEKTA_PRIVATE_KEY_LIVE') : Configuration::get('CONEKTA_PRIVATE_KEY_TEST'));
     $cart = $this->context->cart;
     $customer = new Customer((int) $cart->id_customer);
     $address_delivery = new Address((int) $cart->id_address_delivery);
     $address_fiscal = new Address((int) $cart->id_address_invoice);
     // get shipping info
     $carrier = new Carrier((int) $cart->id_carrier);
     $shipping_price = $cart->getTotalShippingCost() * 100;
     $shipping_carrier = "other";
     $shipping_service = "other";
     if (isset($carrier)) {
         $shipping_carrier = $carrier->name;
         $shipping_service = implode(",", $carrier->delay);
     }
     // build line items
     $items = $cart->getProducts();
     $line_items = array();
     foreach ($items as $item) {
         $line_items = array_merge($line_items, array(array('name' => $item['name'], 'unit_price' => (double) $item['price'] * 100, 'description' => $item['description_short'], 'quantity' => $item['cart_quantity'], 'sku' => $item['reference'], 'type' => "producto")));
     }
     $details = array("email" => $customer->email, "phone" => $address_delivery->phone, "name" => $customer->firstname . " " . $customer->lastname, "line_items" => $line_items, "shipment" => array("price" => $shipping_price, "carrier" => $shipping_carrier, "service" => $shipping_service, "address" => array("street1" => $address_delivery->address1, "city" => $address_delivery->city, "state" => State::getNameById($address_delivery->id_state), "country" => $address_delivery->country, "zip" => $address_delivery->postcode)), "billing_address" => array("street1" => $address_fiscal->address1, "zip" => $address_fiscal->postcode, "company_name" => $address_fiscal->company, "phone" => $address_fiscal->phone, "state" => State::getNameById($address_fiscal->id_state), "city" => $address_fiscal->city, "country" => $address_fiscal->country));
     try {
         if ($type == "cash") {
             $charge_details = array('amount' => $this->context->cart->getOrderTotal() * 100, 'reference_id' => (int) $this->context->cart->id, 'cash' => array('type' => 'oxxo'), 'details' => $details, 'currency' => $this->context->currency->iso_code, 'description' => $this->l('PrestaShop Customer ID:') . ' ' . (int) $this->context->cookie->id_customer . ' - ' . $this->l('PrestaShop Cart ID:') . ' ' . (int) $this->context->cart->id);
             $charge_response = Conekta_Charge::create($charge_details);
             $barcode_url = $charge_response->payment_method->barcode_url;
             $reference = $charge_response->payment_method->barcode;
             $order_status = (int) Configuration::get('waiting_cash_payment');
             $message = $this->l('Conekta Transaction Details:') . "\n\n" . $this->l('Reference:') . ' ' . $reference . "\n" . $this->l('Barcode:') . ' ' . $barcode_url . "\n" . $this->l('Amount:') . ' ' . $charge_response->amount * 0.01 . "\n" . $this->l('Processed on:') . ' ' . strftime('%Y-%m-%d %H:%M:%S', $charge_response->created_at) . "\n" . $this->l('Currency:') . ' ' . Tools::strtoupper($charge_response->currency) . "\n" . $this->l('Mode:') . ' ' . ($charge_response->livemode == 'true' ? $this->l('Live') : $this->l('Test')) . "\n";
             $checkout = Module::getInstanceByName('conektaprestashop');
             $checkout->extra_mail_vars = array('{barcode_url}' => (string) $barcode_url, '{barcode}' => (string) $reference);
         } elseif ($type == "spei") {
             $charge_details = array('amount' => $this->context->cart->getOrderTotal() * 100, 'reference_id' => (int) $this->context->cart->id, 'bank' => array('type' => 'spei'), 'details' => $details, 'currency' => $this->context->currency->iso_code, 'description' => $this->l('PrestaShop Customer ID:') . ' ' . (int) $this->context->cookie->id_customer . ' - ' . $this->l('PrestaShop Cart ID:') . ' ' . (int) $this->context->cart->id);
             $charge_response = Conekta_Charge::create($charge_details);
             $reference = $charge_response->payment_method->receiving_account_number;
             $order_status = (int) Configuration::get('waiting_spei_payment');
             $message = $this->l('Conekta Transaction Details:') . "\n\n" . $this->l('Amount:') . ' ' . $charge_response->amount * 0.01 . "\n" . $this->l('Processed on:') . ' ' . strftime('%Y-%m-%d %H:%M:%S', $charge_response->created_at) . "\n" . $this->l('Currency:') . ' ' . Tools::strtoupper($charge_response->currency) . "\n" . $this->l('Mode:') . ' ' . ($charge_response->livemode == 'true' ? $this->l('Live') : $this->l('Test')) . "\n";
             $checkout = Module::getInstanceByName('conektaprestashop');
             $checkout->extra_mail_vars = array('{receiving_account_number}' => (string) $reference);
         } elseif ($type == "banorte") {
             $charge_details = array('amount' => $this->context->cart->getOrderTotal() * 100, 'reference_id' => (int) $this->context->cart->id, 'bank' => array('type' => 'banorte'), 'details' => $details, 'currency' => $this->context->currency->iso_code, 'description' => $this->l('PrestaShop Customer ID:') . ' ' . (int) $this->context->cookie->id_customer . ' - ' . $this->l('PrestaShop Cart ID:') . ' ' . (int) $this->context->cart->id);
             $charge_response = Conekta_Charge::create($charge_details);
             $reference = $charge_response->payment_method->reference;
             $service_name = $charge_response->payment_method->service_name;
             $service_number = $charge_response->payment_method->service_number;
             $order_status = (int) Configuration::get('waiting_banorte_payment');
             $message = $this->l('Conekta Transaction Details:') . "\n\n" . $this->l('Amount:') . ' ' . $charge_response->amount * 0.01 . "\n" . $this->l('Processed on:') . ' ' . strftime('%Y-%m-%d %H:%M:%S', $charge_response->created_at) . "\n" . $this->l('Currency:') . ' ' . Tools::strtoupper($charge_response->currency) . "\n" . $this->l('Mode:') . ' ' . ($charge_response->livemode == 'true' ? $this->l('Live') : $this->l('Test')) . "\n";
             $checkout = Module::getInstanceByName('conektaprestashop');
             $checkout->extra_mail_vars = array('{reference}' => (string) $reference);
             $checkout->extra_mail_vars = array('{service_name}' => (string) $service_name);
             $checkout->extra_mail_vars = array('{service_number}' => (string) $service_number);
         } else {
             $charge_details = array('amount' => $this->context->cart->getOrderTotal() * 100, 'reference_id' => (int) $this->context->cart->id, 'card' => $token, 'monthly_installments' => $monthly_installments > 1 ? $monthly_installments : null, 'details' => $details, 'currency' => $this->context->currency->iso_code, 'description' => $this->l('PrestaShop Customer ID:') . ' ' . (int) $this->context->cookie->id_customer . ' - ' . $this->l('PrestaShop Cart ID:') . ' ' . (int) $this->context->cart->id);
             $charge_mode = true;
             $charge_details['capture'] = $charge_mode;
             $charge_response = Conekta_Charge::create($charge_details);
             $order_status = (int) Configuration::get('PS_OS_PAYMENT');
             $message = $this->l('Conekta Transaction Details:') . "\n\n" . $this->l('Amount:') . ' ' . $charge_response->amount * 0.01 . "\n" . $this->l('Status:') . ' ' . ($charge_response->status == 'paid' ? $this->l('Paid') : $this->l('Unpaid')) . "\n" . $this->l('Processed on:') . ' ' . strftime('%Y-%m-%d %H:%M:%S', $charge_response->created_at) . "\n" . $this->l('Currency:') . ' ' . Tools::strtoupper($charge_response->currency) . "\n" . $this->l('Mode:') . ' ' . ($charge_response->livemode == 'true' ? $this->l('Live') : $this->l('Test')) . "\n";
         }
         $this->validateOrder((int) $this->context->cart->id, (int) $order_status, $this->context->cart->getOrderTotal(), $this->displayName, $message, array(), null, false, $this->context->customer->secure_key);
         if (version_compare(_PS_VERSION_, '1.5', '>=')) {
             $new_order = new Order((int) $this->currentOrder);
             if (Validate::isLoadedObject($new_order)) {
                 $payment = $new_order->getOrderPaymentCollection();
                 if (isset($payment[0])) {
                     $payment[0]->transaction_id = pSQL($charge_response->id);
                     $payment[0]->save();
                 }
             }
         }
         if (isset($charge_response->id) && $type == "cash") {
             Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_transaction, amount, status, currency, mode, date_add, reference, barcode, captured) VALUES (\'payment\', ' . pSQL((int) $this->context->cart->id) . ', ' . pSQL((int) $this->currentOrder) . ', \'' . pSQL($charge_response->id) . '\',\'' . $charge_response->amount * 0.01 . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' . $reference . '\',\'' . $barcode_url . '\',\'' . ($charge_response->livemode == 'true' ? '1' : '0') . '\' )');
         } elseif (isset($charge_response->id) && $type == "spei") {
             Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_transaction, amount, status, currency, mode, date_add, reference, captured) VALUES (\'payment\', ' . (int) $this->context->cart->id . ', ' . (int) $this->currentOrder . ', \'' . pSQL($charge_response->id) . '\', \'' . $charge_response->amount * 0.01 . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' . $reference . '\', \'' . ($charge_response->livemode == 'true' ? '1' : '0') . '\' )');
         } elseif (isset($charge_response->id) && $type == "banorte") {
             Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_transaction, amount, status, currency, mode, date_add, reference, captured) VALUES (\'payment\', ' . (int) $this->context->cart->id . ', ' . (int) $this->currentOrder . ', \'' . pSQL($charge_response->id) . '\', \'' . $charge_response->amount * 0.01 . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(),\'' . $reference . '\', \'' . ($charge_response->livemode == 'true' ? '1' : '0') . '\' )');
         } elseif (isset($charge_response->id)) {
             Db::getInstance()->Execute('INSERT INTO ' . _DB_PREFIX_ . 'conekta_transaction (type, id_cart, id_order, id_transaction, amount, status, currency, mode, date_add, captured) VALUES (\'payment\', ' . (int) $this->context->cart->id . ', ' . (int) $this->currentOrder . ', \'' . pSQL($charge_response->id) . '\',\'' . $charge_response->amount * 0.01 . '\', \'' . ($charge_response->status == 'paid' ? 'paid' : 'unpaid') . '\', \'' . pSQL($charge_response->currency) . '\', \'' . ($charge_response->livemode == 'true' ? 'live' : 'test') . '\', NOW(), \'1\')');
         }
         if (version_compare(_PS_VERSION_, '1.5', '<')) {
             $redirect = 'order-confirmation.php?id_cart=' . (int) $this->context->cart->id . '&id_module=' . (int) $this->id . '&id_order=' . (int) $this->currentOrder . '&key=' . $this->context->customer->secure_key;
         } else {
             $redirect = $this->context->link->getPageLink('order-confirmation', true, null, array('id_order' => (int) $this->currentOrder, 'id_cart' => (int) $this->context->cart->id, 'key' => $this->context->customer->secure_key, 'id_module' => (int) $this->id));
         }
         Tools::redirect($redirect);
     } catch (Conekta_Error $e) {
         $message = $e->message_to_purchaser;
         if (version_compare(_PS_VERSION_, '1.4.0.3', '>') && class_exists('Logger')) {
             Logger::addLog($this->l('Payment transaction failed') . ' ' . $message, 2, null, 'Cart', (int) $this->context->cart->id, true);
         }
         $controller = Configuration::get('PS_ORDER_PROCESS_TYPE') ? 'order-opc.php' : 'order.php';
         $location = $this->context->link->getPageLink($controller, true) . (strpos($controller, '?') !== false ? '&' : '?') . 'step=3&conekta_error=1&message=' . $message . '#conekta_error';
         Tools::redirectLink($location);
     }
 }
 public function payment()
 {
     Conekta::setApiKey("key_U7qsxjuAzRny1F5ogKXFyw");
     Conekta::setLocale('ES');
     $reg = Input::get('reg_id');
     $pedido = Pedidos::find(Input::get('id'));
     $card = Input::get('conektaTokenId');
     $monto = $pedido->total;
     $restaurantes = Restaurantes::find($pedido->id_restaurante)->first();
     $user = $usuario = User::where('id', '=', $pedido->id_usuario)->first();
     try {
         $charge = Conekta_Charge::create(array("description" => "Conekta tastyfoods", "amount" => $monto * 100, "currency" => "MXN", "reference_id" => "orden_de_id_interno", "card" => $card, 'details' => array('name' => $user->nombre, 'email' => $user->username, 'customer' => array('corporation_name' => 'Conekta Inc.', 'logged_in' => true), 'line_items' => array(array('name' => 'pedido de comida', 'description' => 'Conekta tastyfoods', 'unit_price' => $monto, 'quantity' => 1, 'sku' => 'cohb_s1', 'type' => 'food')))));
     } catch (Conekta_Error $e) {
         return Response::json($e->getMessage());
     }
     $pedido->estatus = 'pagada';
     $pedido->tipo = 'tarjeta';
     $pedido->save();
     $restaurantes->pagadas = $restaurantes->pagadas + 1;
     $restaurantes->save();
     date_default_timezone_set('America/Mexico_City');
     $hora = date('Y-m-d H:i:s');
     // $nuevamas = strtotime ( '+2 minute' , strtotime ( $notificacion ) ) ;
     // $nuevamas = date ( 'Y-m-d H:i:s' , $nuevamas );
     // if($reg != ""){
     //           PushNotification::app('Tasty')
     //                 ->to($reg)
     //                 ->send('Califica el sabor de los platillos que acabas de consumir!');
     //         }
     // return Response::json($charge->status);
 }
 public function testSuccesfulCapture()
 {
     $pm = self::$valid_payment_method;
     $card = self::$valid_visa_card;
     $capture = array('capture' => false);
     setApiKey();
     $cpm = Conekta_Charge::create(array_merge($pm, $card, $capture));
     $this->assertTrue($cpm->status == 'pre_authorized');
     $cpm->capture();
     $this->assertTrue($cpm->status == 'paid');
 }
Exemple #25
0
<?php

require_once "libraries/conekta/Conekta.php";
Conekta::setApiKey("key_nvJm2aBVNEd1qxPwxzzwrA");
$amount = $_POST["amount"];
$conektaTokenId = $_POST["conektaTokenId"];
$name = $_POST["name"];
$street1 = $_POST["street1"];
$street2 = $_POST["street2"];
$city = $_POST["city"];
$state = $_POST["state"];
$zip = $_POST["zip"];
$rfc = $_POST["rfc"];
$companyName = $_POST["company_name"];
$phone = $_POST["phone"];
$email = $_POST["email"];
$charge = Conekta_Charge::create(array('description' => 'Fanbot Plan', 'reference_id' => '01', 'amount' => $amount . '00', 'currency' => 'MXN', 'card' => $conektaTokenId, 'details' => array('name' => $name, 'phone' => $phone, 'email' => $email, 'customer' => array('logged_in' => true, 'successful_purchases' => 14, 'created_at' => 1379784950, 'updated_at' => 1379784950, 'offline_payments' => 4, 'score' => 9), 'line_items' => array(array('name' => 'Fanbot plan mensual', 'description' => 'Pago mensual Fanbot', 'unit_price' => $amount . '00', 'quantity' => 1, 'sku' => '750', 'category' => 'Interacción')), 'billing_address' => array('street1' => $street1, 'street2' => $street2, 'street3' => null, 'city' => $city, 'state' => $state, 'zip' => $zip, 'country' => 'Mexico', 'tax_id' => $rfc, 'company_name' => $companyName, 'phone' => $phone, 'email' => $email))));
echo $charge->status;
Exemple #26
0
 $cantidad = $_POST['cantidad'];
 $calle = $_POST['calle'];
 $numero = $_POST['numero'];
 $colonia = $_POST['colonia'];
 $mpio = $_POST['mpio'];
 $edo = $_POST['edo'];
 $cp = $_POST['cp'];
 $dia_manana = date('d', time() + 172800);
 $mes_manana = date('m', time() + 172800);
 $ano_manana = date('Y', time() + 172800);
 Conekta::setApiKey("key_9zfeT8G8yYVrCRizd6ywRg");
 $sql = mysqli_connect($host, $usr, $pwd);
 mysqli_select_db($sql, $database);
 $result = mysqli_query($sql, "SELECT * FROM productos where id = '" . $id . "'");
 while ($query = mysqli_fetch_array($result)) {
     $charge = Conekta_Charge::create(array('description' => $query['description'], 'reference_id' => $id, 'amount' => $query['price'] * $cantidad, 'currency' => 'MXN', 'cash' => array('type' => 'oxxo', 'expires_at' => $ano_manana . '-' . $mes_manana . '-' . $dia_manana), 'details' => array('name' => $nombre . " " . $ap . " " . $am, 'phone' => $tel, 'email' => $mail, 'customer' => array('corporation_name' => null, 'logged_in' => false, 'successful_purchases' => null, 'created_at' => null, 'updated_at' => null, 'offline_payments' => 0, 'score' => 0), 'line_items' => array(array('name' => $id, 'description' => $query['description'], 'unit_price' => $query['price'], 'quantity' => $cantidad, 'sku' => $id, 'type' => 'Anime')), 'shipment' => array('carrier' => 'estafeta', 'service' => 'national', 'price' => 20000, 'address' => array('street1' => $calle, 'street2' => $numero, 'street3' => $colonia, 'city' => $mpio, 'state' => $edo, 'zip' => $cp, 'country' => 'Mexico')))));
     $message .= '<html>';
     $message .= '<head>';
     $message .= '<link href="http://belldandy.esy.es/css/payment.css" rel="stylesheet" type="text/css"/ >';
     $message .= '<link href="http://belldandy.esy.es/css/paymentprint.css" rel="stylesheet" type="text/css"/ media="print">';
     $message .= '</head>';
     $message .= '<body onload="window.print();">';
     $message .= '<div id="pay">';
     $message .= '<br><br>';
     $message .= '<div id="OXXO">';
     $message .= '<center><h2>Ficha de Pago en OXXO</h2></center>';
     $message .= '</div>';
     $message .= '<br><br><br>';
     $costo = $charge->amount / 100;
     $message .= '<br><label id="p"> Id Compra: ' . $charge->id . '</label><br>';
     $message .= '<br><label id="p"> Total: $' . $costo . '</label><br>';
Exemple #27
-1
 public function processPayment($event)
 {
     if (!class_exists('Conekta')) {
         error_log("Plugin miss Conekta PHP lib dependency. Clone the repository using 'git clone --recursive git@github.com:conekta/conekta-magento.git'", 0);
         throw new Mage_Payment_Model_Info_Exception("Payment module unavailable. Please contact system administrator.");
     }
     if ($event->payment->getMethod() == Mage::getModel('Conekta_Bank_Model_Bank')->getCode()) {
         Conekta::setApiKey(Mage::getStoreConfig('payment/bank/privatekey'));
         Conekta::setLocale(Mage::app()->getLocale()->getLocaleCode());
         $billing = $event->payment->getOrder()->getBillingAddress()->getData();
         $email = $event->payment->getOrder()->getCustomerEmail();
         if ($event->payment->getOrder()->getShippingAddress()) {
             $shipping = $event->payment->getOrder()->getShippingAddress()->getData();
         }
         $items = $event->payment->getOrder()->getAllVisibleItems();
         $line_items = array();
         $i = 0;
         foreach ($items as $itemId => $item) {
             $name = $item->getName();
             $sku = $item->getSku();
             $price = $item->getPrice();
             $description = $item->getDescription();
             $product_type = $item->getProductType();
             $line_items = array_merge($line_items, array(array('name' => $name, 'sku' => $sku, 'unit_price' => $price, 'description' => $description, 'quantity' => 1, 'type' => $product_type)));
             $i = $i + 1;
         }
         $shipp = array();
         if (empty($shipping) != true) {
             $shipp = array('address' => array('street1' => $shipping['street'], 'city' => $shipping['city'], 'state' => $shipping['region'], 'country' => $shipping['country_id'], 'zip' => $shipping['postcode'], 'phone' => $shipping['telephone'], 'email' => $email));
         }
         $days = $event->payment->getMethodInstance()->getConfigData('my_date');
         $expiry_date = Date('Y-m-d', strtotime("+" . $days . " days"));
         try {
             $charge = Conekta_Charge::create(array('bank' => array('type' => 'banorte', 'expires_at' => $expiry_date), 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), 'amount' => intval((double) $event->payment->getOrder()->grandTotal * 100), 'description' => 'Compra en Magento', 'reference_id' => $event->payment->getOrder()->getIncrementId(), 'details' => array('name' => preg_replace('!\\s+!', ' ', $billing['firstname'] . ' ' . $billing['middlename'] . ' ' . $billing['firstname']), 'email' => $email, 'phone' => $billing['telephone'], 'billing_address' => array('company_name' => $billing['company'], 'street1' => $billing['street'], 'city' => $billing['city'], 'state' => $billing['region'], 'country' => $billing['country_id'], 'zip' => $billing['postcode'], 'phone' => $billing['telephone'], 'email' => $email), 'line_items' => $line_items, 'shipment' => $shipp)));
         } catch (Conekta_Error $e) {
             throw new Mage_Payment_Model_Info_Exception($e->message_to_purchaser);
         }
         $event->payment->setBankExpiryDate($expiry_date);
         $event->payment->setBankServiceName($charge->payment_method->service_name);
         $event->payment->setBankServiceNumber($charge->payment_method->service_number);
         $event->payment->setBankName($charge->payment_method->type);
         $event->payment->setBankReference($charge->payment_method->reference);
         $event->payment->setChargeId($charge->id);
         //Update Quote
         $order = $event->payment->getOrder();
         $quote = $order->getQuote();
         $payment = $quote->getPayment();
         $payment->setBankExpiryDate($expiry_date);
         $payment->setBankServiceName($charge->payment_method->service_name);
         $payment->setBankServiceNumber($charge->payment_method->service_number);
         $payment->setBankName($charge->payment_method->type);
         $payment->setBankReference($charge->payment_method->reference);
         $payment->setChargeId($charge->id);
         $quote->collectTotals();
         $quote->save();
         $order->setQuote($quote);
         $order->save();
     }
     return $event;
 }
Exemple #28
-1
 public function processPayment($event)
 {
     if (!class_exists('Conekta')) {
         error_log("Plugin miss Conekta PHP lib dependency. Clone the repository using 'git clone --recursive git@github.com:conekta/conekta-magento.git'", 0);
         throw new Mage_Payment_Model_Info_Exception("Payment module unavailable. Please contact system administrator.");
     }
     if ($event->payment->getMethod() == Mage::getModel('Conekta_Oxxo_Model_Oxxo')->getCode()) {
         Conekta::setApiKey(Mage::getStoreConfig('payment/oxxo/privatekey'));
         Conekta::setLocale(Mage::app()->getLocale()->getLocaleCode());
         $order = $event->payment->getOrder();
         $customer = $order->getCustomer();
         $shipping_address = $order->getShippingAddress();
         $billing = $order->getBillingAddress()->getData();
         $email = $order->getCustomerEmail();
         if ($shipping_address) {
             $shipping_data = $shipping_address->getData();
         }
         $items = $order->getAllVisibleItems();
         $line_items = array();
         $i = 0;
         foreach ($items as $itemId => $item) {
             $name = $item->getName();
             $sku = $item->getSku();
             $price = $item->getPrice();
             $description = $item->getDescription();
             $product_type = $item->getProductType();
             $line_items = array_merge($line_items, array(array('name' => $name, 'sku' => $sku, 'unit_price' => $price, 'description' => $description, 'quantity' => 1, 'type' => $product_type)));
             $i = $i + 1;
         }
         $shipp = array();
         if (empty($shipping_data) != true) {
             $shipp = array('price' => intval((double) $order->getShippingAmount() * 100), 'service' => $order->getShippingMethod(), 'carrier' => $order->getShippingDescription(), 'address' => array('street1' => $shipping_data['street'], 'city' => $shipping_data['city'], 'state' => $shipping_data['region'], 'country' => $shipping_data['country_id'], 'zip' => $shipping_data['postcode'], 'phone' => $shipping_data['telephone'], 'email' => $email));
         }
         $days = $event->payment->getMethodInstance()->getConfigData('my_date');
         $expiry_date = Date('Y-m-d', strtotime("+" . $days . " days"));
         try {
             $charge = Conekta_Charge::create(array('cash' => array('type' => 'oxxo', 'expires_at' => $expiry_date), 'currency' => Mage::app()->getStore()->getCurrentCurrencyCode(), 'amount' => intval((double) $order->grandTotal * 100), 'description' => 'Compra en Magento', 'reference_id' => $order->getIncrementId(), 'details' => array('name' => preg_replace('!\\s+!', ' ', $billing['firstname'] . ' ' . $billing['middlename'] . ' ' . $billing['firstname']), 'email' => $email, 'phone' => $billing['telephone'], 'billing_address' => array('company_name' => $billing['company'], 'street1' => $billing['street'], 'city' => $billing['city'], 'state' => $billing['region'], 'country' => $billing['country_id'], 'zip' => $billing['postcode'], 'phone' => $billing['telephone'], 'email' => $email), 'line_items' => $line_items, 'shipment' => $shipp), 'coupon_code' => $order->getCouponCode(), 'custom_fields' => array('customer' => array('website_id' => $customer->getWebsiteId(), 'entity_id' => $customer->getEntityId(), 'entity_type_id' => $customer->getEntityTypeId(), 'attribute_set_id' => $customer->getAttributeSetId(), 'email' => $customer->getEmail(), 'group_id' => $customer->getGroupId(), 'store_id' => $customer->getStoreId(), 'created_at' => $customer->getCreatedAt(), 'updated_at' => $customer->getUpdatedAt(), 'is_active' => $customer->getIsActive(), 'disable_auto_group_change' => $customer->getDisableAutoGroupChange(), 'get_tax_vat' => $customer->getTaxvat(), 'created_in' => $customer->getCreatedIn(), 'gender' => $customer->getGender(), 'default_billing' => $customer->getDefaultBilling(), 'default_shipping' => $customer->getDefaultShipping(), 'dob' => $customer->getDob(), 'tax_class_id' => $customer->getTaxClassId()), 'discount_description' => $order->getDiscountDescription(), 'discount_amount' => $order->getDiscountAmount(), 'shipping_amount' => $shipping_address->getShippingAmount(), 'shipping_description' => $shipping_address->getShippingDescription(), 'shipping_method' => $shipping_address->getShippingMethod())));
         } catch (Conekta_Error $e) {
             throw new Mage_Payment_Model_Info_Exception($e->message_to_purchaser);
         }
         $event->payment->setOxxoExpiryDate($expiry_date);
         $event->payment->setOxxoBarcodeUrl($charge->payment_method->barcode_url);
         $event->payment->setOxxoBarcode($charge->payment_method->barcode);
         $event->payment->setChargeId($charge->id);
         //Update Quote
         $order = $order;
         $quote = $order->getQuote();
         $payment = $quote->getPayment();
         $payment->setOxxoExpiryDate($expiry_date);
         $payment->setOxxoBarcodeUrl($charge->payment_method->barcode_url);
         $payment->setOxxoBarcode($charge->payment_method->barcode);
         $payment->setChargeId($charge->id);
         $quote->collectTotals();
         $quote->save();
         $order->setQuote($quote);
         $order->save();
     }
     return $event;
 }
Exemple #29
-1
 public function processPayment($event)
 {
     if (!class_exists('Conekta')) {
         error_log("Plugin miss Conekta PHP lib dependency. Clone the repository using 'git clone --recursive git@github.com:conekta/conekta-magento.git'", 0);
         throw new Mage_Payment_Model_Info_Exception("Payment module unavailable. Please contact system administrator.");
     }
     if ($event->payment->getMethod() == Mage::getModel('Conekta_Oxxo_Model_Oxxo')->getCode()) {
         Conekta::setApiKey(Mage::getStoreConfig('payment/oxxo/privatekey'));
         $billing = $event->payment->getOrder()->getBillingAddress()->getData();
         $email = $event->payment->getOrder()->getEmail();
         if ($event->payment->getOrder()->getShippingAddress()) {
             $shipping = $event->payment->getOrder()->getShippingAddress()->getData();
         }
         $items_collection = $event->payment->getOrder()->getItemsCollection(array(), true);
         $line_items = array();
         for ($i = 0; $i < count($items_collection->getColumnValues('sku')); $i++) {
             $name = $items_collection->getColumnValues('name');
             $name = $name[$i];
             $sku = $items_collection->getColumnValues('sku');
             $sku = $sku[$i];
             $price = $items_collection->getColumnValues('price');
             $price = $price[$i];
             $description = $items_collection->getColumnValues('description');
             $description = $description[$i];
             $product_type = $items_collection->getColumnValues('product_type');
             $product_type = $product_type[$i];
             $line_items = array_merge($line_items, array(array('name' => $name, 'sku' => $sku, 'unit_price' => $price, 'description' => $description, 'quantity' => 1, 'type' => $product_type)));
         }
         $shipp = array();
         if (empty($shipping) != true) {
             $shipp = array('price' => $shipping['grand_total'], 'address' => array('street1' => $shipping['street'], 'city' => $shipping['city'], 'state' => $shipping['region'], 'country' => $shipping['country_id'], 'zip' => $shipping['postcode'], 'phone' => $shipping['telephone'], 'email' => $email));
         }
         $days = $event->payment->getMethodInstance()->getConfigData('my_date');
         $expiry_date = Date('Y-m-d', strtotime("+" . $days . " days"));
         try {
             $charge = Conekta_Charge::create(array('cash' => array('type' => 'oxxo', 'expires_at' => $expiry_date), 'amount' => intval((double) $event->payment->getOrder()->grandTotal * 100), 'description' => 'Compra en Magento', 'reference_id' => $event->payment->getOrder()->getIncrementId(), 'details' => array('name' => preg_replace('!\\s+!', ' ', $billing['firstname'] . ' ' . $billing['middlename'] . ' ' . $billing['firstname']), 'email' => $email, 'phone' => $billing['telephone'], 'billing_address' => array('company_name' => $billing['company'], 'street1' => $billing['street'], 'city' => $billing['city'], 'state' => $billing['region'], 'country' => $billing['country_id'], 'zip' => $billing['postcode'], 'phone' => $billing['telephone'], 'email' => $email), 'line_items' => $line_items, 'shipment' => $shipp)));
         } catch (Conekta_Error $e) {
             throw new Mage_Payment_Model_Info_Exception($e->getMessage());
         }
         $event->payment->setOxxoExpiryDate($expiry_date);
         $event->payment->setOxxoBarcodeUrl($charge->payment_method->barcode_url);
         $event->payment->setOxxoBarcode($charge->payment_method->barcode);
         $event->payment->setChargeId($charge->id);
         //Update Quote
         $order = $event->payment->getOrder();
         $quote = $order->getQuote();
         $payment = $quote->getPayment();
         $payment->setOxxoExpiryDate($expiry_date);
         $payment->setOxxoBarcodeUrl($charge->payment_method->barcode_url);
         $payment->setOxxoBarcode($charge->payment_method->barcode);
         $payment->setChargeId($charge->id);
         $quote->collectTotals();
         $quote->save();
         $order->setQuote($quote);
         $order->save();
     }
     return $event;
 }
 public function payment()
 {
     Conekta::setApiKey("key_yVL2GZrKn87qN2rE");
     try {
         $charge = Conekta_Charge::create(array("amount" => 5000, "currency" => "MXN", "description" => "CPMX5 Payment", "reference_id" => "orden_de_id_interno", "card" => $_POST['conektaTokenId']));
     } catch (Conekta_Error $e) {
         return View::make('payment', array('message' => $e->getMessage()));
     }
     return View::make('payment', array('message' => $charge->status));
 }