function authorizepayment($REQUEST) { if (!checkCreditCard($REQUEST['x_card_num'], $REQUEST['card_type'], $ccerror, $ccerrortext)) { $_SESSION['donate_msg'] = 'Please enter a valid credit card number.'; return false; } else { $transaction = new AuthorizeNetAIM(); $transaction->setSandbox(AUTHORIZENET_SANDBOX); $transaction->setFields(array('amount' => $REQUEST['amount'], 'card_num' => $REQUEST['x_card_num'], 'exp_date' => $REQUEST['exp_month'] . '/' . $REQUEST['exp_year'], 'first_name' => $REQUEST['first_name'], 'last_name' => $REQUEST['last_name'], 'address' => $REQUEST['address'], 'city' => $REQUEST['city'], 'state' => $REQUEST['state'], 'country' => $REQUEST['country'], 'zip' => $REQUEST['zip'], 'email' => $REQUEST['email'])); $transaction->setCustomField("Donation Form", $REQUEST["form_id"]); $transaction->setCustomField("Donation Type", $REQUEST["donation_type"]); $transaction->addLineItem("Donation", "Donation to '" . get_bloginfo("name") . "'", "Donation to '" . get_bloginfo("name") . "' using the form: " . $REQUEST["form_id"], 1, $REQUEST['amount'], false); $response = $transaction->authorizeAndCapture(); if ($response->approved) { $_SESSION['donate_msg'] = $response->response_reason_text; return true; } else { $_SESSION['donate_msg'] = $response->response_reason_text; return false; } } }
function SSL_COMPRA_PROCESAR() { global $variedad; if (isset($_POST['btn_cancelar'])) { if (isset($_POST['variedad'])) { $c = 'SELECT titulo, descripcion FROM flores_producto_contenedor LEFT JOIN flores_producto_variedad USING (codigo_producto) WHERE codigo_variedad="' . db_codex($_POST['variedad']) . '"'; $r = mysql_fetch_assoc(db_consultar($c)); $location = PROY_URL . 'arreglos-florales-floristerias-en-el-salvador-' . SEO($f['titulo'] . '-' . $f['codigo_producto']); } else { $location = PROY_URL; } header("Location: " . $location); ob_end_clean; exit; } if (!isset($_POST['btn_comprar']) || !isset($_POST['variedad'])) { return false; } // Revisamos si ya envió la compra, no vaya a ser doble compra. if (db_contar(db_prefijo . 'SSL_compra_contenedor', 'transaccion="' . db_codex($_POST['transaccion']) . '"')) { header("Location: " . PROY_URL); exit; } // Verificamos que todos los datos sean válidos $ERRORES = array(); require_once 'PHP/ssl.vericard.php'; $_POST['txt_numero_t_credito'] = preg_replace('/[^\\d]/', '', $_POST['txt_numero_t_credito']); if (!checkCreditCard($_POST['txt_numero_t_credito'], $_POST['cmb_tipo_t_credito'], $ccerror, $ccerrortext)) { $ERRORES[] = $ccerrortext; } // Tratamos de ver si la direccion de entrega es valida if (strlen(preg_replace('[^\\w]', '', $_POST['txt_direccion_entrega'])) < 10) { $ERRORES[] = 'Por favor revise que la dirección de entrega sea correcta y suficimientemente detallada.'; } // Tratamos de ver si la direccion de entrega es valida if (!preg_match('/^\\d{4}-\\d{2}-\\d{2}$/', $_POST['txt_fecha_entrega'])) { $ERRORES[] = 'Por favor revise que la fecha de entrega sea en este formato: año-mes-dia.'; } if (!preg_match('/^\\d{2}\\/\\d{2}$/', $_POST['txt_fecha_expiracion'])) { $ERRORES[] = 'Por favor revise que la fecha de expiración de la tarjeta de crédito sea en el formato MES/AÑO incluyendo la pleca (/).'; } if (!preg_match('/^\\d{3,4}$/', $_POST['txt_ccv'])) { $ERRORES[] = 'Por favor revise que el número de verificación de la tarjeta de crédito sean tres (3) números. Sirvase de las instrucciones para encontrar este número en su tarjeta de crédito.'; } if (strlen($_POST['txt_nombre_t_credito']) < 10) { $ERRORES[] = 'El nombre del acreedor de la tarjeta de crédito parece inválido'; } /* if (!validcorreo($_POST['txt_correo_contacto'])) { $ERRORES[] = 'El correo ingresado no parece valido, por favor compruebelo.'; } */ if (count($ERRORES) > 0) { echo '<h1>Lo sentimos, hay errores en los datos ingresados</h1>'; echo '<p>Hemos detectado los siguientes errores en los datos introducidos y no podremos procesar su compra a menos que sean corregidos:</p>'; echo '<p class="error">' . join('</p><p class="error">', $ERRORES) . '</p>'; return; } // Encriptamos la tarjeta de credito $t_credito = db_codex(preg_replace('/[^\\d]/', '', trim($_POST['txt_numero_t_credito']))); $c = sprintf('SELECT AES_ENCRYPT("%s","%s") AS t_credito_AES', $t_credito, db__key_str); $r = db_consultar($c); $f = mysql_fetch_assoc($r); $DATOS['codigo_compra'] = '0'; $DATOS['codigo_usuario'] = '0'; $DATOS['estado'] = 'nuevo'; $DATOS['fecha'] = mysql_datetime(); $DATOS['codigo_variedad'] = @$variedad['codigo_variedad']; $DATOS['precio_grabado'] = @$variedad['precio']; $DATOS['n_credito'] = @$f['t_credito_AES']; $DATOS['tipo_t_credito'] = @$_POST['cmb_tipo_t_credito']; $DATOS['telefono_destinatario'] = @$_POST['txt_telefono_destinatario']; $DATOS['telefono_remitente'] = @$_POST['txt_telefono_remitente']; $DATOS['fecha_exp_t_credito'] = @$_POST['txt_fecha_expiracion']; $DATOS['nombre_t_credito'] = @$_POST['txt_nombre_t_credito']; $DATOS['pin_4_reverso_t_credito'] = @$_POST['txt_ccv']; $DATOS['direccion_entrega'] = @$_POST['txt_direccion_entrega']; $DATOS['fecha_entrega'] = @$_POST['txt_fecha_entrega']; $DATOS['tarjeta_de'] = @$_POST['txt_tarjeta_de']; $DATOS['tarjeta_para'] = @$_POST['txt_tarjeta_para']; $DATOS['tarjeta_cuerpo'] = @$_POST['txt_tarjeta_cuerpo']; $DATOS['usuario_notas'] = @$_POST['txt_usuario_notas']; $DATOS['correo_contacto'] = @$_POST['txt_correo_contacto']; $DATOS['transaccion'] = @$_POST['transaccion']; $DATOS['precio_envio'] = @(double) $_POST['destino']; if ($_POST['txt_numero_t_credito'] == str_repeat('1', 16)) { return '<p>ERROR</p>'; } return db_agregar_datos(db_prefijo . 'SSL_compra_contenedor', $DATOS); }
private function _card($noCardData = false) { //echp '<br>Card: '.$this->session->userdata('token').'<br>'.$this->input->post('token'); // needed for progress steps $viewData['progressSteps'] = $this->_progressSteps(); $viewData['paypalURL'] = $this->config->item('app_base') . 'user/pay/paypal'; $viewData['cardURL'] = $this->config->item('app_base') . 'user/pay/card'; $headData['ssl'] = TRUE; $extraScripts = array('jquery.validate', 'jquery.validate.creditcard2', 'card', 'pay'); $headData['js'] = $extraScripts; // don't need to validate, as we just want to display the form and return if ($noCardData) { $token = $this->_token(); $viewData['token'] = $token; $this->_cardForm($viewData, $headData); return; } //////echp 'got card data'; /* * Set up validation */ $this->load->library('validation'); $this->load->helper('validation'); $this->load->helper('phpcreditcard'); $fields['expDateMM'] = 'Expiration date month invalid'; $fields['expDateYYYY'] = 'Expiration date year invalid'; $fields['type'] = 'Card type'; $fields['cardnum'] = 'Card number'; $fields['secCode'] = 'Security code'; $fields['name'] = 'Cardholder\'s name'; $fields['issueStartDate'] = 'Issue number / Start date'; $fields['expDate'] = 'Expiration date'; $fields['addressName'] = 'Full name'; $fields['address1'] = 'Adress line one'; $fields['address2'] = 'Adress line two'; $fields['town'] = 'Town, city, hamlet'; $fields['county'] = 'County'; $fields['postcode'] = 'Postcode'; $fields['country'] = 'Country'; $fields['phoneNum'] = 'Phone number'; $this->validation->set_fields($fields); // don't bother validating if token is invalid - it's not from the right form so ignore it if (!$this->_checkToken()) { $this->validation->run(); $token = $this->_token(); ////echp 'TOKEN NOW '.$token; $viewData['token'] = $token; $viewData['errors']['declined'] = 'There was a problem with your card details. Please check to confirm your details were correct'; $this->_cardForm($viewData, $headData); return; } ////echp 'token checked out'; // token check done, can reset $token = $this->_token(); $viewData['token'] = $token; $cardNum = $this->input->post('cardnum'); $cardType = $this->input->post('type'); // custom validate card if (validCardType($cardType)) { $errorNum; $errorText; // validate card $cardValid = checkCreditCard($cardNum, $cardType, $errorNum, $errorText); } ////echp 'valid card'; // can't pass params to call back, so this work around requires we // call a forced fail callback with a custom error message set below if (!@$cardValid) { $rules['cardnum'] = 'callback_invalidCard'; } else { $rules['cardnum'] = 'required'; } // check - do we need to require the issue/start date field? if ($this->_requiresIssueOrStart($this->input->post('type'))) { $rules['issueStartDate'] = 'required|callback_issueNotStartDateMMYY'; } $rules['name'] = 'trim|required|callback_alphaAndWhiteSpace|max_length[128]|callback_validCardNameFormat'; $rules['type'] = 'trim|callback_validCardType|required'; $rules['secCode'] = 'trim|required|numeric|min_length[3]|max_length[4]'; $rules['expDateMM'] = 'required|numeric|exact_length[2]'; $rules['expDateYYYY'] = 'required|numeric|exact_length[4]'; $rules['address1'] = 'trim|required|callback_address|max_length[255]'; $rules['address2'] = 'trim|callback_address|max_length[255]'; $rules['town'] = 'trim|required|callback_alphaAndWhiteSpace|max_length[128|min_length[3]]'; $rules['county'] = 'trim|required|callback_alphaAndWhiteSpace|max_length[128]|min_length[3]'; $rules['postcode'] = 'trim|required|callback_alphaNumAndWhiteSpace|max_length[12]|min_length[4]'; $rules['country'] = 'trim|required|callback_alphaAndWhiteSpace|max_length[128]'; $rules['phoneNum'] = 'trim|required|callback_validPhone|max_length[24]|min_length[3]'; // custom error messages $this->validation->set_message('validCardNameFormat', 'Your name was in an invalid format: Please enter it as it appears on the card, with salutation (eg. Ms, Mr)'); $this->validation->set_message('invalidCard', 'Your card number is invalid: please check you have entered the correct card number and type'); $this->validation->set_message('alphaAndWhiteSpace', '%s contains invalid characters. Please enter only letters and spaces'); $this->validation->set_message('address', '%s contains invalid characters. Please enter only letters, numbers and spaces'); $this->validation->set_message('alphaNumAndWhiteSpace', '%s contains invalid characters. Please enter only letters, numbers and spaces'); $this->validation->set_message('issueNotStartDateMMYY', 'Please enter the issue number of your Switch or Maestro card. If not present, please enter the valid from date in MMYY format'); $this->validation->set_message('validPhone', 'Please enter a valid full phone number'); $this->validation->set_rules($rules); /* * Go - process validation and redirect on success - remeber */ if ($this->validation->run() == FALSE) { $this->_cardForm($viewData, $headData); return; } ////echp 'validation checked out'; /* * Process paypal */ $this->load->library('paypal'); $debug = false; /** pay pal vars **/ $ipAddress = $_SERVER['REMOTE_ADDR']; $currencyCode = Pay::CURR; /** STEP ONE - Test authorisation for CV2 and AVS **/ $method = 'DoDirectPayment'; $paymentAction = 'Authorization'; $amount = '1.00'; $authString = $this->_ppSaleString($method, $paymentAction, $ipAddress, $currencyCode, $amount); $results = $this->paypal->hashCall($authString); $responseArray = $results['response']; $ack = strtoupper($responseArray["ACK"]); if ($debug) { print_r($responseArray); } if ($ack != "SUCCESS" && $ack != "SUCCESSWITHWARNING") { $viewData['errors']['declined'] = 'Sorry, there seems to be some problem with your card details. Please check to confirm your details were correct and retry.'; $this->_cardForm($viewData, $headData); return; } $cardDetailsWrong = false; // AVS/CVV2 response codes type one - letters Visa, MasterCard, VisaElectron if (in_array($cardType, array('Visa,MasterCard,VisaElectron'))) { // the codes that mean AVS has failed for the above cards $failVisaMasterAVS = array('C', 'E', 'N'); // cvv2 N means the match has failed if ($responseArray['CVV2MATCH'] == 'N' || in_array($responseArray['AVSCODE'], $failVisaMasterAVS)) { $cardDetailsWrong = true; } } // AVS/CVV2 response codes type two - numbers, for Maestro and Solo if (in_array($cardType, array('Maestro', 'Solo'))) { $allowedMaeSoloCVV2 = array(0, 2, 3, 4); // if AVS has failed $failMaeSoloAVS = 1; if (!in_array($responseArray['AVSCODE'], $allowedMaeSoloCodes || $responseArray['AVSCODE'] === $failMaeSoloAVS)) { $cardDetailsWrong = true; } } if ($cardDetailsWrong) { $viewData['errors']['declined'] = 'Sorry, there seems to be some problem with your card details. Please check to confirm your details were correct and retry.'; $this->_cardForm($viewData, $headData); return; } $authorisationID = $responseArray['TRANSACTIONID']; /** STEP TWO - Void test authorisation **/ $voidString = $this->_ppVoidString($authorisationID, $amount); $results = $this->paypal->hashCall($voidString); $responseArray = $results['response']; $ack = strtoupper($responseArray["ACK"]); if ($debug) { print_r($responseArray); } if ($responseArray['AUTHORIZATIONID'] !== $authorisationID) { $viewData['errors']['declined'] = 'Sorry, there seems to be some problem with your card details. Please check to confirm your details were correct and retry.'; $this->_cardForm($viewData, $headData); return; } /** STEP THREE - Actual sale **/ $amount = $this->_getCartTotal(); $method = 'DoDirectPayment'; $paymentAction = 'Sale'; $saleString = $this->_ppSaleString($method, $paymentAction, $ipAddress, $currencyCode, $amount); $results = $this->paypal->hashCall($saleString); $responseArray = $results['response']; $ack = strtoupper($responseArray["ACK"]); $transactionID = $responseArray['TRANSACTIONID']; $time = $responseArray['TIMESTAMP']; if ($debug) { print_r($responseArray); } if ($ack != "SUCCESS" && $ack != "SUCCESSWITHWARNING") { $viewData['errors']['declined'] = 'Sorry, there seems to be some problem with your card details. Please check to confirm your details were correct and retry.'; $this->_cardForm($viewData, $headData); return; } /* * STEP FOUR - Successful payment! Store transaction */ // store payment $this->load->model('payment'); $payment = new Payment(); $userEmail = $this->session->userdata($this->_sessionAuthVar); // set scripts to paid $this->scriptToPay->paid(); $this->scriptToPay->update(); $payment->paid($userEmail, $this->scriptToPay->getKey(), Payment::DIRECT, $amount, $transactionID); // send receipt $this->_emailReceipt($userEmail); $this->session->set_flashdata('newOrder', 'Thanks for your order, your payment was successful. You will receive a receipt in your email shortly. Our tutors can now see your essay.'); redirect("/user/feedback"); }
public function insertBookNormal() { $validator = Validator::make(Input::all(), $this->rules); $getNum = Input::get('ccnum'); $getType = Input::get('CardType'); if ($validator->fails()) { return Redirect::action('normalBook', [Input::get('roomID')])->withErrors($validator, 'guest')->withInput(); } else { if (!checkCreditCard($getNum, $getType, $errornumber, $errortext)) { $errortext = "This Card Has Invalid Number"; return Redirect::action('normalBook', [Input::get('roomID')])->with('ccError', $errortext)->withInput(); } else { $characters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'; $temp; $bookCode = ""; for ($i = 1; $i <= 10; $i++) { if ($i % 2 == 1) { $temp = floor(rand(0, 9)); } else { $temp = $characters[rand(0, strlen($characters) - 1)]; } $bookCode = $bookCode . $temp; } $inputAll = Input::all(); $guest = new Guest(); $booking = new Book(); $payment = new Payment(); $extra = new Extra(); $detailBook = new DetailBooking(); $detailAdditional = new DetailAdditional(); $countAdd = Additional::where('Status', '=', 'Active')->count(); $countBook = Book::orderby('ID_Booking', 'DESC')->first(); $countGuest = Guest::orderby('ID_Guest', 'DESC')->first(); $countExtra = Extra::orderby('ID_Extra', 'DESC')->first(); $countPayment = Payment::orderby('ID_Payment', 'DESC')->first(); $tampIDBook = $countBook->ID_Booking; $tampIDGuest = $countGuest->ID_Guest; $tampIDExtra = $countExtra->ID_Extra; $tampIDPayment = $countPayment->ID_Payment; $checkYearBook = substr(strval($tampIDBook), 3, -5); $checkYearGuest = substr(strval($tampIDGuest), 3, -5); $checkYearExtra = substr(strval($tampIDExtra), 3, -5); $checkYearPayment = substr(strval($tampIDPayment), 3, -5); $incrementIDBook = substr($tampIDBook, 3) + 1; $incrementIDGuest = substr($tampIDGuest, 3) + 1; $incrementIDExtra = substr($tampIDExtra, 3) + 1; $incrementIDPayment = substr($tampIDPayment, 3) + 1; $joinBook = "BOK" . $incrementIDBook; $joinGuest = "GUE" . $incrementIDGuest; $joinExtra = "EXT" . $incrementIDExtra; $joinPayment = "PAY" . $incrementIDPayment; $occupancy = Input::get('adult') . ' Adult | ' . Input::get('child') . ' Child'; $ccexpiry = Input::get('ccmonth') . '/' . Input::get('ccyear'); $arrive = date("Y-m-d", strtotime(Input::get('from'))); //arrive date $depart = date("Y-m-d", strtotime(Input::get('to'))); //depart if ($checkYearBook == strval(date("y"))) { //1. insert to book $booking->ID_Booking = $joinBook; $booking->Booking_code = $bookCode; $booking->Arrive = $arrive; $booking->Depart = $depart; $booking->Number_nights = Input::get('total_d'); $booking->Occupancy = $occupancy; $booking->Booking_Status = "Booked"; //2. insert to guest if ($checkYearGuest == strval(date("y"))) { $guest->ID_Guest = $joinGuest; $guest->ID_Booking = $joinBook; $guest->First_Name = Input::get('fname'); $guest->Last_Name = Input::get('lname'); $guest->No_Identity = Input::get('identity'); $guest->Email = Input::get('email'); $guest->Telephone = Input::get('phone'); $guest->Address = Input::get('address'); $guest->Country = Input::get('country'); $guest->City = Input::get('city'); $guest->State = Input::get('city'); $guest->Post_code = Input::get('state'); } else { $guest->ID_Guest = "GUE" . date('y') . "00001"; $guest->ID_Booking = $joinBook; $guest->First_Name = Input::get('fname'); $guest->Last_Name = Input::get('lname'); $guest->No_Identity = Input::get('identity'); $guest->Email = Input::get('email'); $guest->Telephone = Input::get('phone'); $guest->Address = Input::get('address'); $guest->Country = Input::get('country'); $guest->City = Input::get('city'); $guest->State = Input::get('city'); $guest->Post_code = Input::get('state'); } //3. insert to payment if ($checkYearPayment == strval(date("y"))) { $payment->ID_Payment = $joinPayment; $payment->ID_Booking = $joinBook; $payment->Credit_Type = Input::get('CardType'); $payment->Credit_Holder = Input::get('ccname'); $payment->Credit_Number = Input::get('ccnum'); $payment->Credit_Expiry = $ccexpiry; } else { $payment->ID_Payment = "PAY" . date('y') . "00001"; $payment->ID_Booking = $joinBook; $payment->Credit_Type = Input::get('CardType'); $payment->Credit_Holder = Input::get('ccname'); $payment->Credit_Number = Input::get('ccnum'); $payment->Credit_Expiry = $ccexpiry; } //4. insert to extra if ($checkYearExtra == strval(date("y"))) { $extra->ID_Extra = $joinExtra; $extra->ID_Booking = $joinBook; $extra->Arrival_time = Input::get('darrive'); $extra->Flight_detail = Input::get('fdetail'); $extra->Comment = Input::get('comment'); } else { $extra->ID_Extra = "EXT" . date('y') . "00001"; $extra->ID_Booking = $joinBook; $extra->Arrival_Time = Input::get('darrive'); $extra->Flight_Detail = Input::get('fdetail'); $extra->Comment = Input::get('comment'); } //5. insert to detail Book $detailBook->ID_Booking = $joinBook; $detailBook->ID_RoomType = Input::get('roomID'); $detailBook->Quantity = Input::get('quantity'); $detailBook->Price = Input::get('roomPR'); for ($i = 0; $i < $countAdd; $i++) { $data = array(array('ID_Booking' => $joinBook, 'ID_Additional' => Input::get("id_add_{$i}"), 'Price' => Input::get("price_add_{$i}"), 'Quantity' => Input::get("add_{$i}"))); DetailAdditional::insert($data); } $booking->save(); $guest->save(); $payment->save(); $extra->save(); $detailBook->save(); return Redirect::action('showBook', $bookCode); } else { //1. insert to book $booking->ID_Booking = "BOK" . date('y') . "00001"; $booking->Booking_code = $bookCode; $booking->Arrive = $arrive; $booking->Depart = $depart; $booking->Number_nights = Input::get('total_d'); $booking->Occupancy = $occupancy; $booking->Booking_Status = "Booked"; //2. insert to guest if ($checkYearGuest == strval(date("y"))) { $guest->ID_Guest = $joinGuest; $guest->ID_Booking = "BOK" . date('y') . "00001"; $guest->First_Name = Input::get('fname'); $guest->Last_Name = Input::get('lname'); $guest->No_Identity = Input::get('identity'); $guest->Email = Input::get('email'); $guest->Telephone = Input::get('phone'); $guest->Address = Input::get('address'); $guest->Country = Input::get('country'); $guest->City = Input::get('city'); $guest->State = Input::get('city'); $guest->Post_code = Input::get('state'); } else { $guest->ID_Guest = "GUE" . date('y') . "00001"; $guest->ID_Booking = "BOK" . date('y') . "00001"; $guest->First_Name = Input::get('fname'); $guest->Last_Name = Input::get('lname'); $guest->No_Identity = Input::get('identity'); $guest->Email = Input::get('email'); $guest->Telephone = Input::get('phone'); $guest->Address = Input::get('address'); $guest->Country = Input::get('country'); $guest->City = Input::get('city'); $guest->State = Input::get('city'); $guest->Post_code = Input::get('state'); } //3. insert to payment if ($checkYearPayment == strval(date("y"))) { $payment->ID_Payment = $joinPayment; $payment->ID_Booking = "BOK" . date('y') . "00001"; $payment->Credit_Type = Input::get('CardType'); $payment->Credit_Holder = Input::get('ccname'); $payment->Credit_Number = Input::get('ccnum'); $payment->Credit_Expiry = $ccexpiry; } else { $payment->ID_Payment = "PAY" . date('y') . "00001"; $payment->ID_Booking = "BOK" . date('y') . "00001"; $payment->Credit_Type = Input::get('CardType'); $payment->Credit_Holder = Input::get('ccname'); $payment->Credit_Number = Input::get('ccnum'); $payment->Credit_Expiry = $ccexpiry; } //4. insert to extra if ($checkYearExtra == strval(date("y"))) { $extra->ID_Extra = $joinExtra; $extra->ID_Booking = "BOK" . date('y') . "00001"; $extra->Arrival_Time = Input::get('darrive'); $extra->Flight_Detail = Input::get('fdetail'); $extra->Comment = Input::get('comment'); } else { $extra->ID_Extra = "EXT" . date('y') . "00001"; $extra->ID_Booking = "BOK" . date('y') . "00001"; $extra->Arrival_Time = Input::get('darrive'); $extra->Flight_Detail = Input::get('fdetail'); $extra->Comment = Input::get('comment'); } //5. insert to detail Book $detailBook->ID_Booking = "BOK" . date('y') . "00001"; $detailBook->ID_RoomType = Input::get('roomID'); $detailBook->Quantity = Input::get('quantity'); $detailBook->Price = Input::get('roomPR'); //6. insert to detail additional for ($i = 0; $i < $countAdd; $i++) { $data = array(array('ID_Booking' => "BOK" . date('y') . "00001", 'ID_Additional' => Input::get("id_add_{$i}"), 'Price' => Input::get("price_add_{$i}"), 'Quantity' => Input::get("add_{$i}"))); DetailAdditional::insert($data); } $booking->save(); $guest->save(); $payment->save(); $extra->save(); $detailBook->save(); return Redirect::action('showInvoice', $bookCode); //return Redirect::to('/rooms')->with('message','Success'); } } } }
/** * * @ WHMCS FULL DECODED & NULLED * * @ Version : 5.2.15 * @ Author : MTIMER * @ Release on : 2013-12-24 * @ Website : http://www.mtimer.cn * **/ function updateCCDetails($userid, $cardtype, $cardnum, $cardcvv, $cardexp, $cardstart, $cardissue, $noremotestore = "", $fullclear = "") { global $CONFIG; global $_LANG; global $cc_encryption_hash; $gatewayid = get_query_val("tblclients", "gatewayid", array("id" => $userid)); if ($fullclear) { update_query("tblclients", array("cardtype" => "", "cardlastfour" => "", "cardnum" => "", "expdate" => "", "startdate" => "", "issuenumber" => "", "gatewayid" => ""), array("id" => $userid)); } $cardnum = ccFormatNumbers($cardnum); $cardexp = ccFormatNumbers($cardexp); $cardstart = ccFormatNumbers($cardstart); $cardissue = ccFormatNumbers($cardissue); $cardexp = ccFormatDate($cardexp); ccFormatDate($cardstart); $cardcvv = ccFormatNumbers($cardcvv); if ($cardtype) { $errormessage = checkCreditCard($cardnum, $cardtype); if (!$cardexp || strlen($cardexp) != 4) { $errormessage .= "<li>" . $_LANG['creditcardenterexpirydate']; } else { if (substr($cardexp, 0, 2) < date("m") && "20" . substr($cardexp, 2) <= date("Y")) { $errormessage .= "<li>" . $_LANG['creditcardexpirydateinvalid']; } } } if ($errormessage) { return $errormessage; } if (!$userid) { return ""; } if ($noremotestore) { return ""; } if ($CONFIG['CCNeverStore']) { return ""; } $remotestored = false; $result = select_query("tblpaymentgateways", "gateway,(SELECT id FROM tblinvoices WHERE paymentmethod=gateway AND userid='" . (int) $userid . "' ORDER BY id DESC LIMIT 0,1) AS invoiceid", "setting='type' AND (value='CC' OR value='OfflineCC')"); while ($data = mysql_fetch_array($result)) { $gateway = $data['gateway']; $invoiceid = $data['invoiceid']; if ($invoiceid) { if (!isValidforPath($gateway)) { exit("Invalid Gateway Module Name"); } require_once ROOTDIR . ("/modules/gateways/" . $gateway . ".php"); if (function_exists($gateway . "_storeremote")) { $rparams = getCCVariables($invoiceid); $rparams['cardtype'] = $cardtype; $rparams['cardnum'] = $cardnum; $rparams['cardcvv'] = $cardcvv; $rparams['cardexp'] = $cardexp; $rparams['cardstart'] = $cardstart; $rparams['cardissuenum'] = $cardissue; $rparams['gatewayid'] = $gatewayid; $action = "create"; if ($rparams['gatewayid']) { if ($rparams['cardnum']) { $action = "update"; } else { $action = "delete"; } } $rparams['action'] = $action; $captureresult = call_user_func($gateway . "_storeremote", $rparams); $result = select_query("tblpaymentgateways", "value", array("gateway" => $rparams['paymentmethod'], "setting" => "name")); $data = mysql_fetch_array($result); $gatewayname = $data['value'] . " Remote Storage"; $debugdata = is_array($captureresult['rawdata']) ? array_merge(array("UserID" => $rparams['clientdetails']['userid']), $captureresult['rawdata']) : "UserID => " . $rparams['clientdetails']['userid'] . "\r\n" . $captureresult['rawdata']; if ($captureresult['status'] == "success") { if (isset($captureresult['gatewayid'])) { update_query("tblclients", array("gatewayid" => $captureresult['gatewayid']), array("id" => $userid)); } if ($action == "delete") { update_query("tblclients", array("cardtype" => "", "cardlastfour" => "", "cardnum" => "", "expdate" => "", "startdate" => "", "issuenumber" => "", "gatewayid" => ""), array("id" => $userid)); } logTransaction($gatewayname, $debugdata, "Success"); } else { logTransaction($gatewayname, $debugdata, ucfirst($captureresult['status'])); return "<li>Remote Transaction Failure. Please Contact Support."; } $remotestored = true; } } } $cchash = md5($cc_encryption_hash . $userid); $cardstart = ""; $cardlastfour = substr($cardnum, 0 - 4); if ($remotestored) { $cardnum = ""; } update_query("tblclients", array("cardtype" => $cardtype, "cardlastfour" => $cardlastfour, "cardnum" => array("type" => "AES_ENCRYPT", "text" => $cardnum, "hashkey" => $cchash), "expdate" => array("type" => "AES_ENCRYPT", "text" => $cardexp, "hashkey" => $cchash), "startdate" => array("type" => "AES_ENCRYPT", "text" => $cardstart, "hashkey" => $cchash), "issuenumber" => array("type" => "AES_ENCRYPT", "text" => $cardissue, "hashkey" => $cchash)), array("id" => $userid)); logActivity("Updated Stored Credit Card Details - User ID: " . $userid, $userid); run_hook("CCUpdate", array("userid" => $userid, "cardtype" => $cardtype, "cardnum" => $cardnum, "cardcvv" => $cardcvv, "expdate" => $cardexp, "cardstart" => $cardstart, "issuenumber" => $cardissue)); }
/** * Validation and filtering * * @return boolean True is satisfactory */ function check() { // Validate user information if (trim($this->_ccName) == '') { $this->setError('Please enter your name as it appears on your credit card.'); return false; } if (!checkCreditCard($this->_ccNum, $this->_ccType)) { global $errortext; $this->setError($errortext); return false; } $now =& FiveFactory::getDate(); if ($now->isAfter($this->_ccExpYY . '-' . $this->_ccExpMM . '-28')) { $this->setError("Your credit card has expired."); return false; } if ($this->date_transaction == null) { // Set the registration timestamp $now =& FiveFactory::getDate(); $this->date_transaction = strtotime($now->toMySQL()); } return true; }
$errornumber = 4; $errortext = $ccErrors[$errornumber]; return false; } // The credit card is in the required format. return true; } // ________________ // ________ EXECUTION ________ $errorNumber = ''; $errorText = ''; if (isset($_POST['cardNumber'])) { $cardNumber = $_POST['cardNumber']; if (isset($_POST['cardName'])) { $cardName = $_POST['cardName']; if (isset($errorNumber)) { if (isset($errorText)) { $check = checkCreditCard($cardNumber, $cardName, $errorNumber, $errorText); if ($check == true) { $_SESSION['success'] = 'Parfait, numéro de carte valide, rends-nous riches !'; } else { $errors[] = $errorText; } } } } } // ________________ } // ________________ }
/** * New Customer Registration Form:Step4 and it's final step * *@access public *@return Confirmation or Error Message */ function added_customer_step4($start = 0) { $to_date = date("Y-m-d H:i:s"); $this->load->library('form_validation'); $data_organization['organization_data'] = $this->input->post("organization_data"); $data_admin_user['admin_user_data'] = $this->input->post("admin_user_data"); $data['category_name'] = $this->input->post("data_category"); if (sizeof($data_organization['organization_data']) <= 1 || sizeof($data_admin_user['admin_user_data']) <= 1) { redirect("main/add_customer"); } $card_info['credit_card_no'] = $this->input->post("credit_card_no"); $card_info['credit_card_type'] = $this->input->post("credit_card_type"); $card_info['credit_card_verification_code'] = $this->input->post("credit_card_verification_code"); $card_info['card_expire_date_month'] = $this->input->post("card_expire_date_month"); $card_info['card_expire_date_year'] = $this->input->post("card_expire_date_year"); $billing_data = $this->input->post("admin_user_data"); $form_data_billing = array('billing_terms_condition' => "", 'bill_first_name' => $billing_data["first_name"], 'bill_last_name' => $billing_data["last_name"], 'bill_phone_no' => $billing_data["phone_no"], 'bill_email' => $billing_data["email"], 'bill_primary_address' => $billing_data["primary_address"], 'bill_optional_address' => $billing_data["optional_address"], 'bill_zip' => $billing_data["zip"], 'bill_city' => $billing_data["city"], 'bill_country' => $billing_data["country"], 'bill_state' => $billing_data["state"], 'add_date' => $to_date); $this->lang->load('customer', $this->session->userdata('lang_file')); $this->data['mainTab'] = 'customer'; $this->data['activeTab'] = 'customer'; $form_data_step4 = array('payment_method' => $this->input->post("payment_method"), 'bill_first_name' => $this->input->post("bill_first_name"), 'bill_last_name' => $this->input->post("bill_last_name"), 'bill_phone_no' => $this->input->post("bill_phone_no"), 'bill_email' => $this->input->post("bill_email"), 'bill_primary_address' => $this->input->post("bill_primary_address"), 'bill_optional_address' => $this->input->post("bill_optional_address"), 'bill_zip' => $this->input->post("bill_zip"), 'bill_city' => $this->input->post("bill_city"), 'bill_country' => $this->input->post("bill_country"), 'bill_state' => $this->input->post("bill_state"), 'billing_terms_condition' => $this->input->post("billing_terms_condition"), 'credit_card_no' => $this->input->post("credit_card_no"), 'credit_card_type' => $this->input->post("credit_card_type"), 'credit_card_verification_code' => $this->input->post("credit_card_verification_code"), 'credit_card_expire_month' => $this->input->post("card_expire_date_month"), 'credit_card_expire_year' => $this->input->post("card_expire_date_year"), 'name_on_credit_card' => $this->input->post("name_on_credit_card"), 'add_date' => $to_date); //Start Validate Credit Card Info $cardErrorNo = -1; //NO card error, card is valid $payment_method = $this->input->post("payment_method"); if ($payment_method == "creditcard") { $this->form_validation->set_rules('name_on_credit_card', $this->lang->line('label_name_on_card'), 'trim|required'); if (checkCreditCard($card_info, $errornumber, $errortext)) { //$errortext = 'This card has a valid format'; //echo 'card OK'; } else { $cardErrorNo = $errornumber; } } //End Validate Credit Card Info $data_billing_address['billing_address_data'] = $form_data_step4; $this->load->vars($form_data_step4); $this->load->vars($data_admin_user); $this->load->vars($data_organization); $this->form_validation->set_rules('bill_first_name', $this->lang->line('label_first_name'), 'trim|required'); $this->form_validation->set_rules('bill_last_name', $this->lang->line('label_last_name'), 'trim|required'); $this->form_validation->set_rules('bill_phone_no', $this->lang->line('label_phone'), 'trim|required'); $this->form_validation->set_rules('bill_email', $this->lang->line('label_email'), 'trim|required|valid_email|xss_clean|callback_email_check'); $this->form_validation->set_rules('bill_primary_address', $this->lang->line('label_address_line_one'), 'trim|required|xss_clean'); $this->form_validation->set_rules('bill_zip', $this->lang->line('label_zip'), 'trim|required|xss_clean'); $this->form_validation->set_rules('bill_city', $this->lang->line('label_city'), 'trim|required|xss_clean'); $this->form_validation->set_rules('bill_country', $this->lang->line('label_country'), 'trim|required|xss_clean'); $this->form_validation->set_rules('bill_state', $this->lang->line('label_state'), 'trim|required|xss_clean'); //$this->form_validation->set_message('required', $this->lang->line('label_billing_terms_condition')); $this->form_validation->set_rules('billing_terms_condition', $this->lang->line('label_billing_terms_condition'), 'trim|xss_clean|callback_billing_terms_condition_check'); if ($this->form_validation->run() == FALSE || $cardErrorNo != -1) { $error_credit_card = array(); $error_credit_card['credit_card_type_unknown_error'] = ""; $error_credit_card['credit_card_no_error'] = ""; $error_credit_card['credit_card_cvv2_wrong_error'] = ""; $error_credit_card['credit_card_expired_error'] = ""; switch ($cardErrorNo) { case 0: $error_credit_card['credit_card_type_unknown_error'] = $this->lang->line('credit_card_type_unknown_error'); break; case 1: $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_empty_error'); break; case 2: $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_format_invalid_error'); break; case 3: $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_invalid_error'); break; case 4: $error_credit_card['credit_card_no_error'] = $this->lang->line('credit_card_no_length_wrong_error'); break; case 5: $error_credit_card['credit_card_cvv2_wrong_error'] = $this->lang->line('credit_card_cvv2_wrong_error'); break; case 6: $error_credit_card['credit_card_expired_error'] = $this->lang->line('credit_card_expired_error'); break; } $this->data['payment_method'] = $payment_method; $this->load->vars($data); $this->load->vars($error_credit_card); $this->load->vars($form_data_billing); $this->data['dynamicView'] = 'pages/member/new_customer/entry_step3'; $this->_commonPageLayout('frontend_viewer'); } else { ///Organization Registration Final Step $first_name = $data_admin_user['admin_user_data']['first_name']; $rand_no = mt_rand(1000000000, 2000000000); $first_name = substr($first_name, 0, 2); $password = $first_name . $rand_no; $password2 = $this->encrypt($password, 'vaccitvassit'); $data_admin_user['admin_user_data']['password'] = $password2; $data_admin_user['admin_user_data']['admin_user'] = 1; //$rand_pass = base64_encode($c); $data_global_settings['global_settings_data'] = $this->info_model->get_global_settings(); // print_r($data['global_settings_data']); if ($data_global_settings['global_settings_data']) { foreach ($data_global_settings['global_settings_data'] as $rows) { $data_organization['organization_data']['org_allowed_sms_per_month'] = $rows->allowed_sms_per_month; $data_organization['organization_data']['org_allowed_letter_per_month'] = $rows->allowed_letter_per_month; $per_invoice_cost = $rows->per_invoice_cost; } } if ($data['category_name'] != "") { $data_val['category_name'] = $data['category_name']; $cat_id = $this->info_model->org_category_insert($data_val); $data_organization['organization_data']['org_category'] = $cat_id; } $last_insert_ids = $this->info_model->register_organisation($data_organization['organization_data'], $data_admin_user['admin_user_data'], $form_data_step4); //$this->load->vars($form_data_step3); if (sizeof($last_insert_ids) > 0) { $package_id = $data_organization['organization_data']['package_name']; $data['package_info'] = $this->info_model->get_package($package_id); if ($data['package_info']) { foreach ($data['package_info'] as $rows) { $currency_info = $this->info_model->get_currency($rows->currency_id); } $package_name = $rows->package_name; $no_of_member = $rows->no_of_member; $amount = $rows->amount; $duration = $rows->duration; $sms_cost = $rows->sms_cost; $letter_cost = $rows->letter_cost; if ($currency_info) { foreach ($currency_info as $currency) { $currency_name = $currency->currency_name; } $package_details = "Package: " . $package_name . "_" . $package_id; } } ////////////////// Payment Method: Start //////////// if ($payment_method == "creditcard") { //$token = urlencode("token_from_setExpressCheckout"); $TOTALBILLINGCYCLES = urlencode($duration); if ($duration > 12) { $TOTALBILLINGCYCLES = urlencode("12"); } // combination of this and billingPeriod must be at most a year $bill_start_date_mins = date("i"); $bill_start_date = date("Y-m-d") . "T" . date("H") . ":" . $bill_start_date_mins . ":" . date("s"); $payment_per_cycle = $amount; $paymentAmount = urlencode($payment_per_cycle); $currencyID = urlencode($currency_name); // or other currency code ('GBP', 'EUR', 'JPY', 'CAD', 'AUD') $startDate = str_replace("%3A", ":", urlencode($bill_start_date)); $billingPeriod = urlencode("Month"); // or "Day", "Week", "SemiMonth", "Year" $billingFreq = urlencode("1"); // combination of this and billingPeriod must be at most a year //$TOTALBILLINGCYCLES = urlencode($duration); // combination of this and billingPeriod must be at most a year //$TOTALBILLINGCYCLES = urlencode("12"); // combination of this and billingPeriod must be at most a year $DESC = urlencode($package_details); $creditCardType = urlencode($card_info['credit_card_type']); $creditCardAccount = urlencode(str_replace(' ', '', $card_info['credit_card_no'])); //$creditCardAccount = urlencode("4779297617944965"); $cardExpireDate = urlencode($card_info['card_expire_date_month'] . $card_info['card_expire_date_year']); $cardCvv2 = urlencode($card_info['credit_card_verification_code']); $PAYERSTATUS = urlencode("verified"); $STREET = urlencode($form_data_step4['bill_primary_address']); $CITY = urlencode($form_data_step4['bill_city']); $STATE = urlencode($form_data_step4['bill_state']); $COUNTRYCODE = urlencode($form_data_step4['bill_country']); $ZIP = urlencode($form_data_step4['bill_zip']); $FIRSTNAME = urlencode($form_data_step4['bill_first_name']); $LASTNAME = urlencode($form_data_step4['bill_last_name']); $EMAIL = urlencode($form_data_step4['bill_email']); $INITAMT = urlencode("0.00"); $FAILEDINITAMTACTION = urlencode("ContinueOnFailure"); $MAXFAILEDPAYMENTS = urlencode("10"); $ITEMCATEGORY0 = urlencode("Digital"); $ITEMNAME0 = urlencode($package_details); $ITEMAMT0 = urlencode($amount); $ITEMQTY0 = urlencode("1"); $AUTOBILLOUTAMT = urlencode("AddToNextBilling"); $TAXAMT = $amount * (25 / 100); /// Tax_rate = 25% $EMAIL = $form_data_step4['bill_email']; $nvpStr = "&AMT={$paymentAmount}&CURRENCYCODE={$currencyID}&PROFILESTARTDATE={$startDate}"; $nvpStr .= "&BILLINGPERIOD={$billingPeriod}&BILLINGFREQUENCY={$billingFreq}&TOTALBILLINGCYCLES={$TOTALBILLINGCYCLES}&DESC={$DESC}&CREDITCARDTYPE={$creditCardType}&ACCT={$creditCardAccount}&EXPDATE={$cardExpireDate}&CVV2={$cardCvv2}&PAYERSTATUS={$PAYERSTATUS}&STREET={$STREET}\n &CITY={$CITY}&COUNTRYCODE={$COUNTRYCODE}&ZIP={$ZIP}&FIRSTNAME={$FIRSTNAME}&LASTNAME={$LASTNAME}&EMAIL={$EMAIL}\n &INITAMT={$INITAMT}&TAXAMT={$TAXAMT}&FAILEDINITAMTACTION={$FAILEDINITAMTACTION}&MAXFAILEDPAYMENTS={$MAXFAILEDPAYMENTS}\n &L_PAYMENTREQUEST_0_ITEMCATEGORY0={$ITEMCATEGORY0}&L_PAYMENTREQUEST_0_NAME0={$ITEMNAME0}\n &L_PAYMENTREQUEST_0_AMT0={$ITEMAMT0}&L_PAYMENTREQUEST_0_QTY0={$ITEMQTY0}&AUTOBILLOUTAMT={$AUTOBILLOUTAMT}"; $httpParsedResponseAr = PPHttpPost('CreateRecurringPaymentsProfile', $nvpStr); if ("SUCCESS" == strtoupper($httpParsedResponseAr["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($httpParsedResponseAr["ACK"])) { //$data_payment_success['org_id'] = $last_insert_ids['org_id']; //$data_payment_success['org_billing_info_id'] = $last_insert_ids['org_billing_info_id']; $data_payment_success['profileid'] = str_replace('%2d', '-', $httpParsedResponseAr['PROFILEID']); $data_payment_success['profilestatus'] = $httpParsedResponseAr['PROFILESTATUS']; //$data_payment_success['transactionid'] = $httpParsedResponseAr['TRANSACTIONID']; $data_payment_success['timestamp'] = str_replace('%2d', '-', $httpParsedResponseAr['TIMESTAMP']); $data_payment_success['timestamp'] = str_replace('%3a', ':', $data_payment_success['timestamp']); $data_payment_success['correlationid'] = $httpParsedResponseAr['CORRELATIONID']; $data_payment_success['ack'] = $httpParsedResponseAr['ACK']; $data_payment_success['total_billing_cycle'] = $TOTALBILLINGCYCLES; $data_payment_success['add_date'] = $to_date; //Start : Update Organization Info Based on Successful Payment $nvpStr = "&PROFILEID=" . $data_payment_success['profileid']; $recurringPaymentProfileDetails = getRecurringPaymentProfileDetails('GetRecurringPaymentsProfileDetails', $nvpStr); if ("SUCCESS" == strtoupper($recurringPaymentProfileDetails["ACK"]) || "SUCCESSWITHWARNING" == strtoupper($recurringPaymentProfileDetails["ACK"])) { $org_billing_success_insert_id = $this->info_model->org_billing_success_insert($data_payment_success); if ($org_billing_success_insert_id) { $data_org_billing_info['bill_profileid'] = $data_payment_success['profileid']; $payment_method = "creditcard"; $org_id = $last_insert_ids['org_id']; $success = $this->info_model->update_org_billing_info($data_org_billing_info, $payment_method, $org_id); } if ($recurringPaymentProfileDetails['NUMCYCLESCOMPLETED'] > 0) { $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['NEXTBILLINGDATE']); $data_org_billing_success['next_scheduled_billing_date'] = str_replace('%3a', ':', $data_org_billing_success['next_scheduled_billing_date']); $data_org_billing_success['no_of_billing_cycle_completed'] = 1; $data_org_billing_success['no_of_billing_cycle_remaining'] = $TOTALBILLINGCYCLES - 1; $data_org_billing_success['current_outstanding_balance'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['OUTSTANDINGBALANCE']); $data_org_billing_success['amount_of_last_successful_payment'] = str_replace('%2e', '.', $recurringPaymentProfileDetails['LASTPAYMENTAMT']); $data_org_billing_success['total_paid_amount'] = "total_paid_amount+" . $data_org_billing_success['amount_of_last_successful_payment']; $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%2d', '-', $recurringPaymentProfileDetails['LASTPAYMENTDATE']); $data_org_billing_success['date_of_last_successful_payment'] = str_replace('%3a', ':', $data_org_billing_success['date_of_last_successful_payment']); $success = $this->info_model->update_org_billing_success($data_org_billing_success, $org_billing_success_insert_id); $total_days = $duration * 30; $expire_date = time() + $total_days * 24 * 60 * 60; $data_update = array('approval_status' => 1, 'payment_status' => 1, 'activation_date' => time(), 'expire_date' => $expire_date); $success = $this->info_model->update_org_approve($data_update, $last_insert_ids['org_id']); if ($success) { $data['first_name'] = $data_admin_user['admin_user_data']['first_name']; $data['username'] = $data_admin_user['admin_user_data']['username']; $data['email'] = $data_admin_user['admin_user_data']['email']; $data['org_number'] = $data_organization['organization_data']['org_number']; $data['org_name'] = $data_organization['organization_data']['org_name']; $data['org_phone'] = $data_organization['organization_data']['org_phone']; $data['password'] = $password; if ($data_admin_user['admin_user_data']['password_receive_by_email']) { $this->send_password_by_email($data); } if ($data_admin_user['admin_user_data']['password_receive_by_sms']) { $this->send_password_by_sms($data); } } /////// } else { $data_org_billing_success['no_of_billing_cycle_remaining'] = $TOTALBILLINGCYCLES; $success = $this->info_model->update_org_billing_success($data_org_billing_success, $org_billing_success_insert_id); } //exit('GetTransactionDetails Completed Successfully: '.print_r($recurringPaymentProfileDetails, true)); } else { //exit('GetTransactionDetails failed: ' . print_r($recurringPaymentProfileDetails, true)); } //End : Update Organization Info Based on Successful Payment //exit('CreateRecurringPaymentsProfile Completed Successfully: '.print_r($httpParsedResponseAr, true)); } else { $data_payment_failure['org_id'] = $last_insert_ids['org_id']; $data_payment_failure['org_billing_info_id'] = $last_insert_ids['org_billing_info_id']; $data_payment_failure['l_errodcode0'] = $httpParsedResponseAr['L_ERRORCODE0']; $data_payment_failure['l_shortmessage0'] = str_replace('%20', ' ', $httpParsedResponseAr['L_SHORTMESSAGE0']); $data_payment_failure['l_longmessage0'] = str_replace('%20', ' ', $httpParsedResponseAr['L_LONGMESSAGE0']); $data_payment_failure['l_severitycode0'] = $httpParsedResponseAr['L_SEVERITYCODE0']; $data_payment_failure['timestamp'] = str_replace('%2d', '-', $httpParsedResponseAr['TIMESTAMP']); $data_payment_failure['timestamp'] = str_replace('%3a', ':', $data_payment_failure['timestamp']); $data_payment_failure['correlationid'] = $httpParsedResponseAr['CORRELATIONID']; $data_payment_failure['ack'] = $httpParsedResponseAr['ACK']; $data_payment_failure['add_date'] = $to_date; $success = $this->info_model->org_billing_failure_insert($data_payment_failure); //exit('CreateRecurringPaymentsProfile failed: ' . print_r($httpParsedResponseAr, true)); } } elseif ($payment_method == "invoice") { //$fak_expire_date = time() + ($total_days * 24 * 60 * 60); $data_faktura['bill_country'] = $form_data_step4['bill_country']; if ($data_faktura['bill_country'] == "DEU") { $data_faktura['bill_country'] = "GERMAN"; } if ($data_faktura['bill_country'] == "NOR") { $data_faktura['bill_country'] = "NORWAY"; } if ($data_faktura['bill_country'] == "DNK") { $data_faktura['bill_country'] = "DENMARK"; } if ($data_faktura['bill_country'] == "FIN") { $data_faktura['bill_country'] = "FINLAND"; } if ($data_faktura['bill_country'] == "GBR") { $data_faktura['bill_country'] = "UK"; } if ($data_faktura['bill_country'] == "SWE") { $data_faktura['bill_country'] = "SWEDEN"; } $data_faktura['org_id'] = $last_insert_ids['org_id']; $data_faktura['package_id'] = $package_id; $data_faktura['fak_active_date'] = time(); $data_faktura['fak_expire_date'] = time() + 10 * 24 * 60 * 60; $data_faktura['org_name'] = $data_organization['organization_data']['org_name']; $data_faktura['org_number'] = $data_organization['organization_data']['org_number']; $data_faktura['bill_primary_address'] = $form_data_step4['bill_primary_address']; $data_faktura['bill_zip'] = $form_data_step4['bill_zip']; $data_faktura['bill_city'] = $form_data_step4['bill_city']; $data_faktura['bill_state'] = $form_data_step4['bill_state']; $data_faktura['bill_phone'] = $form_data_step4['bill_phone_no']; $data_faktura['fak_reference_name'] = $data_admin_user['admin_user_data']['first_name'] . " " . $data_admin_user['admin_user_data']['last_name']; $data_faktura['fak_description'] = $package_details; $data_faktura['fak_quantity'] = 1; $data_faktura['fak_unit_price'] = $amount; $data_faktura['fak_invoice_cost'] = $per_invoice_cost; $data_faktura['fak_invoice_cost_applied'] = 0.0; $data_faktura['sms_unit_price'] = $sms_cost; $data_faktura['letter_unit_price'] = $letter_cost; $data_faktura['fak_price_exclusive_vat'] = $data_faktura['fak_quantity'] * $data_faktura['fak_unit_price']; $data_faktura['fak_vat_rate'] = 25; //////// Calculating Total Cost of this faktura ////// $pris_exclusive_vat_one = $data_faktura['fak_price_exclusive_vat']; $pris_exclusive_vat_two = $data_faktura['fak_invoice_cost_applied']; $price_total_exclusive_vat = $pris_exclusive_vat_one + $pris_exclusive_vat_two; $data_faktura['fak_vat_price'] = $data_faktura['fak_vat_rate'] / 100 * $price_total_exclusive_vat; $fak_total_price = $price_total_exclusive_vat + $data_faktura['fak_vat_price']; //////// Calculating Total Cost of this faktura ////// //$fak_total_price =$data_faktura['fak_price_exclusive_vat']+$data_faktura['fak_vat_price']; $data_faktura['fak_total_price'] = round($fak_total_price); $data_faktura['fak_rounding_price'] = $data_faktura['fak_total_price'] - $fak_total_price; $data_faktura['fak_currency'] = $currency_name; $data_faktura['add_date'] = $to_date; $fak_insert_id = $this->info_model->bill_faktura_insert($data_faktura); $data_faktura['price_total_exclusive_vat'] = $price_total_exclusive_vat; if ($fak_insert_id) { $data['first_name'] = $data_admin_user['admin_user_data']['first_name']; $data['username'] = $data_admin_user['admin_user_data']['username']; $data['email'] = $data_admin_user['admin_user_data']['email']; $data['org_number'] = $data_organization['organization_data']['org_number']; $data['org_name'] = $data_organization['organization_data']['org_name']; $data['org_phone'] = $data_organization['organization_data']['org_phone']; $data['password'] = $password; $this->make_invoice_pdf($data_faktura, $fak_insert_id, $data); } } //////////////// Payment Method: End ///// $this->session->set_flashdata('message', '<div id="message1">' . $this->lang->line('org_registration_member_success') . '</div>'); redirect('main/org_registration_success'); //$this->data['dynamicView'] = 'pages/admin/new_customer/org_registration_success'; } else { $this->data['dynamicView'] = 'pages/member/new_customer/entry_step3'; } $this->_commonPageLayout('frontend_viewer'); } }