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());
     }
 }
Esempio n. 4
0
 public function testResourceNotFoundError()
 {
     setApiKey();
     try {
         $charge = Conekta_Charge::find('1');
     } catch (Exception $e) {
         $this->assertTrue(strpos(get_class($e), 'Conekta_ResourceNotFoundError') !== false);
     }
 }
Esempio n. 5
0
 public function charges($params = null)
 {
     if (!$params) {
         $params = array();
     }
     $params['customer'] = $this->id;
     $charges = Conekta_Charge::all($params, $this->_apiKey);
     return $charges;
 }
Esempio n. 6
0
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
     }
 }
Esempio n. 10
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
     }
 }
Esempio n. 11
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');
     }
 }
Esempio n. 12
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
    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);
    }
}
Esempio n. 13
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');
//}
?>

Esempio n. 14
0
 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);
 }
Esempio n. 16
0
<?php

header('Content-Type: text/html; charset=utf-8');
/* Panel de control antifraude */
// Incluir la libreria de Conekta
require_once "../vendor/conekta-php/lib/Conekta.php";
// Configurar Conekta
Conekta::setApiVersion("1.0.0");
Conekta::setApiKey('key_HizotERe7EkwAj4TAQnryw');
// Pedir los cargos
try {
    $charges = Conekta_Charge::where(array('failure_code' => 'suspected_fraud'));
    $charges = json_decode($charges, true);
} catch (Conekta_Error $e) {
    // La consulta no pudo ser procesada
    echo $e->getMessage();
}
// Mostrar la razón de las transacciones fraudulentas
?>

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- The above 3 meta tags *must* come first in the head; any other head content must come *after* these tags -->
    <title>Transacciones de PinkRevolver</title>

    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet">
Esempio n. 17
0
 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);
 }
Esempio n. 18
0
 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');
 }
Esempio n. 19
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;
Esempio n. 20
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";
}
Esempio n. 21
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>';
 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;
     }
 }
Esempio n. 23
0
 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
         }
     }
 }
Esempio n. 24
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
         }
     }
 }
Esempio n. 25
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);
    }
}
Esempio n. 26
-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;
 }
Esempio n. 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_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;
 }
Esempio n. 28
-1
 public function consultas()
 {
     require_once "lib/Conekta.php";
     Conekta::setApiKey("key_uexJEsPgPzz55V4HzYugow");
     // Llave Privada Conekta
     $charges = Conekta_Charge::where(array('status.ne' => 'paid', 'sort' => 'created_at.desc'));
     echo $charges;
 }
Esempio n. 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));
 }