public function testInvalidCredentials() { Conekta::setApiKey('invalid'); try { Conekta_Customer::create(); } catch (Conekta_AuthenticationError $e) { $this->assertEqual(401, $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 function testNoConnectionError() { $apiUrl = Conekta::$apiBase; Conekta::$apiBase = 'http://localhost:3001'; try { $customer = Conekta_Customer::create(array('cards' => array('tok_test_visa_4242'))); } catch (Exception $e) { $this->assertTrue(strpos(get_class($e), 'Conekta_NoConnectionError') !== false); } Conekta::$apiBase = $apiUrl; }
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 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 } }
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) { 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."); } Conekta::setApiKey(Mage::getStoreConfig('payment/webhook/privatekey')); Conekta::setApiVersion("1.0.0"); Conekta::setLocale(Mage::app()->getLocale()->getLocaleCode()); $url = new Varien_Data_Form_Element_Text(); $data = array('name' => $element->getName(), 'html_id' => $element->getId()); $url->setData($data); $webhook_url = Mage::getBaseUrl() . "index.php/webhook/ajax/listener"; if (!empty($element->getValue())) { $url_string = $element->getValue(); } else { $url_string = $webhook_url; } $url->setValue($url_string); $events = array("events" => array("charge.created", "charge.paid", "charge.under_fraud_review", "charge.fraudulent", "charge.refunded", "charge.created", "customer.created", "customer.updated", "customer.deleted", "webhook.created", "webhook.updated", "webhook.deleted", "charge.chargeback.created", "charge.chargeback.updated", "charge.chargeback.under_review", "charge.chargeback.lost", "charge.chargeback.won", "payout.created", "payout.retrying", "payout.paid_out", "payout.failed", "plan.created", "plan.updated", "plan.deleted", "subscription.created", "subscription.paused", "subscription.resumed", "subscription.canceled", "subscription.expired", "subscription.updated", "subscription.paid", "subscription.payment_failed", "payee.created", "payee.updated", "payee.deleted", "payee.payout_method.created", "payee.payout_method.updated", "payee.payout_method.deleted")); $error = false; $error_message = null; try { $different = true; $webhooks = Conekta_Webhook::where(); foreach ($webhooks as $webhook) { if (strpos($webhook->webhook_url, $url_string) !== false) { $different = false; } } if ($different) { $webhook = Conekta_Webhook::create(array_merge(array("url" => $url_string), $events)); } } catch (Exception $e) { $error = true; $error_message = $e->getMessage(); } $url->setForm($element->getForm()); $html = $url->getElementHtml(); $javaScript = "\n <script type=\"text/javascript\">\n Event.observe(window, 'load', function() {\n alert('" . $error_message . "');\n });\n </script>"; if ($error) { $html .= $javaScript; } return $html; }
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 } } }
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'); } }
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); }
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); } }
public static function setVerifySslCerts($verify) { self::$verifySslCerts = $verify; }
<?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'); //} ?>
function conektapt() { Conekta::setApiKey("key_YYhQPyu53UTGdCSWor5LYw"); }
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; } }
public static function setLocale($locale) { self::$locale = $locale; }
<?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;
public static function setApiVersion($version) { self::$apiVersion = $version; }
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; } }
$id = addslashes($_POST['id_send']); $nombre = $_POST['nombre']; $ap = $_POST['ap']; $am = $_POST['am']; $tel = $_POST['tel']; $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>';
function unsetApiKey() { if (isset($env) == false) { $env = Conekta::setApiKey(''); } }
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 } } }
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); } }
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 . " desde Woocommerce v" . $this->version, "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 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; }
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; }
function authorizeFromEnv() { $apiKey = getenv('CONEKTA_API_KEY'); if (!$apiKey) { $apiKey = "qso7o4nDGnWNMESzLxq4"; } Conekta::setApiKey($apiKey); }
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; }
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)); }
public function set_locale_options() { if (function_exists("get_locale") && get_locale() !== "") { $current_lang = explode("_", get_locale()); $this->lang = $current_lang[0]; $this->lang_messages = (require_once "lang/" . $this->lang . ".php"); Conekta::setLocale($this->lang); } return $this; }