public function testSetEmailNull() { $customer = new Customer('*****@*****.**'); try { $customer->setEmail(null); $this->fail(); } catch (\InvalidArgumentException $expected) { } }
public static function fromJson($json) { $r = new Customer(); $r->setEmail($json->email); $r->setExternalId(isset($json->external_id) ? $json->external_id : null); $r->setCountry($json->country); $r->setLanguage($json->language); return $r; }
protected function runPage() { if (WebRequest::wasPosted()) { if (!WebRequest::postInt("calroom")) { $this->showCal(); return; } $startdate = new DateTime(WebRequest::post("qbCheckin")); $enddate = new DateTime(WebRequest::post("qbCheckout")); $room = Room::getById(WebRequest::postInt("calroom")); for ($date = $startdate; $date < $enddate; $date->modify("+1 day")) { if (!$room->isAvailable($date)) { $this->error("room-not-available"); $this->showCal(); return; } } // search for customer if (!($customer = Customer::getByEmail(WebRequest::post("qbEmail")))) { $customer = new Customer(); $suTitle = WebRequest::post("qbTitle"); $suFirstname = WebRequest::post("qbFirstname"); $suLastname = WebRequest::post("qbLastname"); $suAddress = WebRequest::post("qbAddress"); $suCity = WebRequest::post("qbCity"); $suPostcode = WebRequest::post("qbPostcode"); $suCountry = WebRequest::post("qbCountry"); $suEmail = WebRequest::post("qbEmail"); $customer->setPassword($suEmail); // set values $customer->setTitle($suTitle); $customer->setFirstname($suFirstname); $customer->setSurname($suLastname); $address = new Address(); $address->setLine1($suAddress); $address->setCity($suCity); $address->setPostCode($suPostcode); $address->setCountry($suCountry); $address->save(); $customer->setAddress($address); $customer->setEmail($suEmail); // save it $customer->save(); $customer->sendMailConfirm(); // save it again $customer->save(); } $booking = new Booking(); $booking->setStartDate(WebRequest::post("qbCheckin")); $booking->setEndDate(WebRequest::post("qbCheckout")); $booking->setAdults(WebRequest::post("qbAdults")); $booking->setChildren(WebRequest::post("qbChildren")); $booking->setPromocode(WebRequest::post("qbPromoCode")); $booking->setRoom($room->getId()); $booking->setCustomer($customer->getId()); $booking->save(); $msg = Message::getMessage("booking-confirmation"); $msg = str_replace("\$1", $booking->getStartDate(), $msg); $msg = str_replace("\$2", $booking->getEndDate(), $msg); $msg = str_replace("\$3", $booking->getAdults(), $msg); $msg = str_replace("\$4", $booking->getChildren(), $msg); $msg = str_replace("\$5", $booking->getRoom()->getName(), $msg); Mail::send($customer->getEmail(), Message::getMessage("booking-confimation-subject"), $msg); $this->mSmarty->assign("content", $msg); return; } throw new YouShouldntBeDoingThatException(); }
private function getCustomer() { $customer = new Customer(); $dateTime = new DateTime(); $customer->setCustomerCode("avatax4jCust" . date_format($dateTime, "dmyGis")); $customer->setCountry("US"); $customer->setCity("BainbridgeIsland"); $customer->setZip("98110"); $customer->setEmail("*****@*****.**"); $customer->setState("WA"); $customer->setBusinessName("Test"); $customer->setType("Bill_To"); return $customer; }
public function getAllCustomers() { $customerList = array(); $result = $this->db->query('SELECT * FROM Customer'); foreach ($result as $row) { $custDetails = new Customer(); $custDetails->setId($row['id']); $custDetails->setCustomerName($row['customerName']); $custDetails->setEmail($row['email']); $custDetails->setPhoneNumber($row['phoneNumber']); $custDetails->setAddress($row['address']); $custDetails->setPassword($row['password']); $custDetails->setLastUpdate($row['lastUpdate']); $customerList[$custDetails->getId()] = $custDetails; } return $customerList; }
public function testSetEmailWorks() { $customer = new Customer(); $customer->setEmail('*****@*****.**'); $this->assertEquals('*****@*****.**', $customer->getEmail()); }
/** * Verifica se uma notificação IPN é válida, fazendo a autenticação * da mensagem segundo o protocolo de segurança do serviço. * * @param array $message Um array contendo a notificação recebida. * @return boolean TRUE se a notificação for autência, ou FALSE se não for. * */ function handleIpn(array $message) { $curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $this->endpoint); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_SSLVERSION, 6); //curl_setopt($curl, CURLOPT_SSLVERSION, CURL_SSLVERSION_TLSv1); //curl_setopt($curl, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_1); curl_setopt($curl, CURLOPT_POSTFIELDS, http_build_query($message)); $response = curl_exec($curl); $error = curl_error($curl); $errno = curl_errno($curl); curl_close($curl); if (!empty($error) || $errno > 0 || $response != 'VERIFIED') { return array('error' => 'Not verified', 'errors' => $error); } if ($_POST['receiver_email'] != $this->getReceiverEmail()) { return array('error' => 'Receiver mail is different', 'errors' => array('expected' => $this->receiverEmail, 'returned' => $_POST['receiver_email'])); } $arr = array_merge(array('txn_id' => null, 'txn_type' => null, 'payment_status' => null, 'pending_reason' => null, 'reason_code' => null, 'custom' => null, 'invoice' => null, 'address_country' => null, 'address_city' => null, 'address_country_code' => null, 'address_name' => null, 'address_state' => null, 'address_status' => null, 'address_street' => null, 'address_zip' => null, 'contact_phone' => null, 'first_name' => null, 'last_name' => null, 'business_name' => null, 'payer_email' => null, 'payer_id' => null, 'mc_currency' => null, 'mc_gross' => null, 'mc_fee' => null, 'mc_handling' => null, 'mc_shipping' => null, 'tax' => null), $message); //$this->ipnLog("...."); //$this->ipnLog(json_encode($arr)); $notification = new Notification(); $notification->setTxnId($arr['txn_id']); $notification->setTxnType($arr['txn_type']); $notification->setReceiverEmail($arr['receiver_email']); $notification->setPaymentStatus($arr['payment_status']); $notification->setPendingReason($arr['pending_reason']); $notification->setReasonCode($arr['reason_code']); $notification->setCustom($arr['custom']); $notification->setInvoice($arr['invoice']); $customer = new Customer(); $customer->setAddressCountry($arr['address_country']); $customer->setAddressCity($arr['address_city']); $customer->setAddressCountryCode($arr['address_country_code']); $customer->setAddressName($arr['address_name']); $customer->setAddressState($arr['address_state']); $customer->setAddressStatus($arr['address_status']); $customer->setAddressStreet($arr['address_street']); $customer->setAddressZip($arr['address_zip']); $customer->setContactPhone($arr['contact_phone']); $customer->setFirstName($arr['first_name']); $customer->setLastName($arr['last_name']); $customer->setBusinessName($arr['business_name']); $customer->setEmail($arr['payer_email']); $customer->setPaypalId($arr['payer_id']); $transaction = new Transaction(); $transaction->setId(null); $transaction->setTxnId($arr['txn_id']); $transaction->setTxnType($arr['txn_type']); $transaction->setPaymentStatus($arr['payment_status']); $transaction->setPendingReason($arr['pending_reason']); $transaction->setReasonCode($arr['reason_code']); $transaction->setCustom($arr['custom']); $transaction->setInvoice($arr['invoice']); $transaction->setPayerId($arr['payer_id']); $transaction->setCurrency($arr['mc_currency']); $transaction->setGross($arr['mc_gross']); $transaction->setFee($arr['mc_fee']); $transaction->setHandling($arr['mc_handling']); $transaction->setShipping($arr['mc_shipping']); $transaction->setTax($arr['tax']); return array('notification' => $notification, 'customer' => $customer, 'transaction' => $transaction); }
public function castToCustomer($obj) { $c = new Customer(); if (isset($obj->customerID)) { $c->setCustomerID($obj->customerID); } if (isset($obj->email)) { $c->setEmail($obj->email); } if (isset($obj->name)) { $c->setName($obj->name); } if (isset($obj->key)) { $c->setKey($obj->key); } if (isset($obj->website)) { $c->setWebsite($obj->website); } return $c; }
function sanitizeTransaction($response) { $receiver = new Receiver(); $receiver->setId($response['RECEIVERID']); $receiver->setEmail($response['RECEIVEREMAIL']); $receiver->setBusiness($response['RECEIVERBUSINESS']); $customer = new Customer(); $customer->setFirstName($response['FIRSTNAME']); $customer->setLastName($response['LASTNAME']); $customer->setEmail($response['EMAIL']); $customer->setPaypalId($response['PAYERID']); $customer->setStatus($response['PAYERSTATUS']); $customer->setAddressCountryCode($response['COUNTRYCODE']); $customer->setAddressCountry($response['SHIPTOCOUNTRYNAME']); $customer->setAddressStreet($response['SHIPTOSTREET']); $customer->setAddressCity($response['SHIPTOCITY']); $customer->setAddressState($response['SHIPTOSTATE']); $customer->setAddressZip($response['SHIPTOZIP']); $customer->setAddressStatus($response['ADDRESSSTATUS']); $transaction = new Transaction(); $transaction->setSubject($response['SUBJECT']); $transaction->setTxnId($response['TRANSACTIONID']); $transaction->setTxnType($response['PAYMENTTYPE']); $transaction->setPaymentDate($response['ORDERTIME']); $transaction->setGross($response['AMT']); $transaction->setFee($response['FEEAMT']); $transaction->setCurrencyCode($response['CURRENCYCODE']); $transaction->setPaymentStatus($response['PAYMENTSTATUS']); $transaction->setPendingReason($response['PENDINGREASON']); $transaction->setReasonCode($response['REASONCODE']); $transaction->setReasonCode($response['REASONCODE']); $transaction->setReceiver($receiver); $transaction->setCustomer($customer); return $transaction; }
private function showCreateCustomerPage() { if (WebRequest::wasPosted()) { try { // get variables $suTitle = WebRequest::post("suTitle"); $suFirstname = WebRequest::post("suFirstname"); $suLastname = WebRequest::post("suLastname"); $suAddress = WebRequest::post("suAddress"); $suCity = WebRequest::post("suCity"); $suPostcode = WebRequest::post("suPostcode"); $suCountry = WebRequest::post("suCountry"); $suEmail = WebRequest::post("suEmail"); $suPassword = WebRequest::post("suPassword"); $suConfirm = WebRequest::post("suConfirm"); // data validation if ($suTitle == "") { throw new CreateCustomerException("suTitle not specified"); } if ($suFirstname == "") { throw new CreateCustomerException("suFirstname not specified"); } if ($suLastname == "") { throw new CreateCustomerException("suLastname not specified"); } if ($suAddress == "") { throw new CreateCustomerException("suAddress not specified"); } if ($suCity == "") { throw new CreateCustomerException("suCity not specified"); } if ($suPostcode == "") { throw new CreateCustomerException("suPostcode not specified"); } if ($suCountry == "") { throw new CreateCustomerException("suCountry not specified"); } if ($suEmail == "") { throw new CreateCustomerException("suEmail not specified"); } if ($suPassword == "") { throw new CreateCustomerException("suPassword not specified"); } if ($suConfirm == "") { throw new CreateCustomerException("suConfirm not specified"); } if ($suPassword != $suConfirm) { throw new CreateCustomerException("Password mismatch"); } $customer = new Customer(); // set values $customer->setTitle($suTitle); $customer->setFirstname($suFirstname); $customer->setSurname($suLastname); $address = new Address(); $address->setLine1($suAddress); $address->setCity($suCity); $address->setPostcode($suPostcode); $address->setCountry($suCountry); $address->save(); $customer->setAddress($address); $customer->setEmail($suEmail); $customer->setPassword($suPassword); $customer->sendMailConfirm(); // save it $customer->save(); global $cScriptPath; $this->mHeaders[] = "Location: {$cScriptPath}/Customers"; } catch (CreateCustomerException $ex) { $this->mBasePage = "mgmt/custCreate.tpl"; $this->error($ex->getMessage()); } } else { $this->mBasePage = "mgmt/custCreate.tpl"; } }
/** * @Route("/importK2", name="import") * @Template() */ public function importAction() { $converter = $this->getContainer()->get('import.csvtoarray'); $em = $this->getDoctrine()->getManager(); //Import collaborator $fileName = 'web/uploads/csv/Charles_users.csv'; $data = $converter->convert($fileName, ';'); //Import customer $fileNameCustomer = 'web/uploads/csv/Charles_users.csv'; $dataCustomer = $converter->convert($fileNameCustomer, ';'); $user_repository = $em->getRepository("CharlestownCollaboratorBundle:Collaborator"); $collaborators = $user_repository->findAE(); //Disable all AE collaborators if (!empty($collaborators)) { foreach ($collaborators as $collaborator) { if (!$collaborator->hasRole('ROLE_ADMIN')) { $collaborator->setEnabled(false); $em->persist($collaborator); } } } //Flush them $em->flush(); //Update all AE working for Charlestown ATM if (!empty($data)) { foreach ($data as $row) { if ($row['users_login']) { $user = $user_repository->findOneBy(array('username' => $row['users_login'])); if ($user instanceof Collaborator) { $birthDate = \DateTime::createFromFormat('d/m/Y', $row['Date_Naissance']); $agency = $em->getRepository('CharlestownAgencyBundle:Agency')->find($row['group_name']); //Update is infos if ($row['users_email'] != $user->getEmail()) { $user->setEmail($row['users_email']); } $user->setLastName($row['users_surname']); $user->setFirstName($row['users_name']); $user->setEnabled($row['active']); $user->setAgency($agency); $user->setAddress($row['adresse']); $user->setPc($row['code_postal']); $user->setTown($row['ville']); $user->setPortPhoneNumber($row['portable']); $user->setPhoneNumber($row['telephone']); $user->setBirthDate($birthDate); $user->setEnabled(true); } else { $user = new Collaborator(); $birthDate = \DateTime::createFromFormat('d/m/Y', $row['Date_Naissance']); $agency = $em->getRepository('CharlestownAgencyBundle:Agency')->find($row['group_name']); //Update is infos $user->setUsername($row['users_login']); $user->setPlainPassword($row['password']); $user->setEmail($row['users_email']); $user->setLastName($row['users_surname']); $user->setFirstName($row['users_name']); $user->setEnabled($row['active']); $user->setAgency($agency); $user->setAddress($row['adresse']); $user->setPc($row['code_postal']); $user->setTown($row['ville']); $user->setPortPhoneNumber($row['portable']); $user->setPhoneNumber($row['telephone']); $user->setBirthDate($birthDate); $this->getContainer()->get('charlestown.mailer')->sendCollaboratorId($row['users_login'], $row['password'], $row['users_email'], $row['users_name'], $row['users_surname']); } $em->persist($user); $em->flush(); $em->clear(); } $birthDate = $birthDate->format('d-m'); $today = new \DateTime('today'); $today = $today->format('d-m'); if ($birthDate == $today) { $this->getContainer()->get('charlestown.mailer')->sendCollaboratorBirthdayCard($row['users_email'], $row['users_name']); } } } //Update all Customer of Charlestown if (!empty($dataCustomer)) { foreach ($dataCustomer as $row) { if ($row['client_matricule']) { $customer = $em->getRepository("CharlestownCustomerBundle:Customer")->findBy(array('email' => $row['email_contact'])); $customerBis = $em->getRepository("CharlestownCustomerBundle:Customer")->findBy(array('username' => $row['client_matricule'])); if ($customer == null && $customerBis == null) { $customer = new Customer(); $agency = $em->getRepository('CharlestownAgencyBundle:Agency')->find($row['numero_agence']); $pw = "charlestown"; $customer->setAgency($agency); $customer->setEmail($row['email_contact']); $customer->setUsername($row['client_matricule']); $customer->setPlainPassword($pw); $customer->setCompanyName($row['raison_sociale']); $customer->addRole('ROLE_CUSTOMER'); $em->persist($customer); $this->getContainer()->get('charlestown.mailer')->sendCustomerId($row['client_matricule'], $pw, $row['email_contact'], $row['raison_sociale'], $agency, false); } $em->flush(); } } } return array(); }
protected function runPage() { $showError = ""; $error = ""; global $cWebPath; $this->mBasePage = "signup.tpl"; if (Session::isCustomerLoggedIn()) { // why do you want another account? // redirect to main page $this->mHeaders[] = "HTTP/1.1 303 See Other"; $this->mHeaders[] = "Location: " . $cWebPath . "/index.php"; } if (WebRequest::wasPosted()) { try { $suTitle = WebRequest::post("suTitle"); $suFirstname = WebRequest::post("suFirstname"); $suLastname = WebRequest::post("suLastname"); $suAddress = WebRequest::post("suAddress"); $suCity = WebRequest::post("suCity"); $suPostcode = WebRequest::post("suPostcode"); $suCountry = WebRequest::post("suCountry"); $suEmail = WebRequest::post("suEmail"); $suPassword = WebRequest::post("suPassword"); $suConfirm = WebRequest::post("suConfirm"); // data validation if ($suTitle == "") { throw new CreateCustomerException("Title not specified"); } if ($suFirstname == "") { throw new CreateCustomerException("Firstname not specified"); } if ($suLastname == "") { throw new CreateCustomerException("Lastname not specified"); } if ($suAddress == "") { throw new CreateCustomerException("Address not specified"); } if ($suCity == "") { throw new CreateCustomerException("City not specified"); } if ($suPostcode == "") { throw new CreateCustomerException("Postcode not specified"); } if ($suCountry == "") { throw new CreateCustomerException("Country not specified"); } if ($suEmail == "") { throw new CreateCustomerException("Email not specified"); } if ($suPassword == "") { throw new CreateCustomerException("Password not specified"); } if ($suConfirm == "") { throw new CreateCustomerException("Confirmed password not specified"); } if ($suPassword != $suConfirm) { throw new CreateCustomerException("Password mismatch"); } $customer = new Customer(); if ($suPassword != "" && $suPassword == $suConfirm) { $customer->setPassword($suPassword); } // set values $customer->setTitle($suTitle); $customer->setFirstname($suFirstname); $customer->setSurname($suLastname); $address = new Address(); $address->setLine1($suAddress); $address->setCity($suCity); $address->setPostCode($suPostcode); $address->setCountry($suCountry); $address->save(); $customer->setAddress($address); $customer->setEmail($suEmail); // save it $customer->save(); $customer->sendMailConfirm(); global $cScriptPath; $this->mHeaders[] = "Location: {$cScriptPath}"; } catch (CreateCustomerException $ex) { $this->mBasePage = "signup.tpl"; $this->error($ex->getMessage()); } } else { $this->mBasePage = "signup.tpl"; } }