public function testapi()
 {
     $o_bcpc = new BaseCommerceClient(RENTSQUARE_MERCH_USER, RENTSQUARE_MERCH_PASS, RENTSQUARE_MERCH_KEY);
     $o_bcpc->setSandbox(BC_SANDBOXVALUE);
     $o_address = new Address();
     $o_address->setName(Address::$XS_ADDRESS_NAME_BILLING);
     $o_address->setLine1("123 Some Address");
     $o_address->setCity("Tempe");
     $o_address->setState("AZ");
     $o_address->setZipcode("12345");
     $o_bc = new BankCard();
     $o_bc->setBillingAddress($o_address);
     $o_bc->setExpirationMonth("02");
     $o_bc->setExpirationYear("2015");
     $o_bc->setName("Nick 2");
     $o_bc->setNumber("4111111111111111");
     $o_bc->setToken("myToken12asdfas3");
     $o_bc = $o_bcpc->addBankCard($o_bc);
     if ($o_bc->isStatus(BankCard::$XS_BC_STATUS_FAILED)) {
         //the add Failed, look at messages array for reason(s) why
         //var_dump( $o_bc->getMessages() );
         $this->set('message', $o_bc->getMessages());
     } else {
         if ($o_bc->isStatus(BankCard::$XS_BC_STATUS_ACTIVE)) {
             //Card added successfully
             //var_dump( $o_bc->getToken() );
             $this->set('message', $o_bc->getToken());
         }
     }
 }
 function testLatLongValidation()
 {
     $address = new Address();
     $address->setLine1("900 Winslow Way");
     $address->setLine2("Ste 130");
     $address->setCity("Bainbridge Island");
     $address->setRegion("WA");
     $address->setPostalCode("98110");
     $address->setLongitude("-122.510359");
     $address->setLatitude("47.624972");
     $validateRequest = new ValidateRequest();
     $validateRequest->setAddress($address);
     $validateRequest->setTextCase(TextCase::$Upper);
     //added for 4.13 changes
     $validateRequest->setCoordinates(true);
     //Sets Profile name from Configuration File to "Jaas"
     //this will force it to Jaas (PostLocate)
     $this->client = new AddressServiceSoap("JaasDevelopement");
     //validate the Request
     $result = $this->client->validate($validateRequest);
     //Re-Assigning to the original Profile
     $this->client = new AddressServiceSoap("Development");
     $this->assertEqual($result->getResultCode(), SeverityLevel::$Success);
     $validAddresses = $result->getValidAddresses();
     $this->assertEqual(1, count($validAddresses));
     $validAddresses = $result->getValidAddresses();
     if (count($validAddresses) != 1) {
         echo "Unexpected number of addresses returned.  Expected one address.";
     } else {
         $validAddress = $validAddresses[0];
         $this->assertEqual(strtoupper($address->getLine1()) . " E " . strtoupper($address->getLine2()), $validAddress->getLine1());
         $this->assertEqual("", $validAddress->getLine2());
         $this->assertEqual(strtoupper($address->getCity()), $validAddress->getCity());
         $this->assertEqual(strtoupper($address->getRegion()), $validAddress->getRegion());
         $this->assertEqual($address->getPostalCode() . "-2450", $validAddress->getPostalCode());
         $this->assertEqual("H", $validAddress->getAddressType());
         $this->assertEqual("C051", $validAddress->getCarrierRoute());
         //Ticket 21203: Modified Fips Code value for jaas enabled account.
         //$this->assertEqual("5303500000", $validAddress->getFipsCode());
         $this->assertEqual("5303503736", $validAddress->getFipsCode());
         $this->assertEqual("KITSAP", $validAddress->getCounty());
         $this->assertEqual(strtoupper($address->getCity()) . " " . strtoupper($address->getRegion()) . " " . $address->getPostalCode() . "-2450", $validAddress->getLine4());
         $this->assertEqual("981102450307", $validAddress->getPostNet());
         // Added 4.13 changes for the Lat Long
         // Update to check for ZIP+4 precision
         // Zip+4 precision coordinates
         if (strlen($validAddress->getLatitude()) > 7) {
             echo "ZIP+4 precision coordinates received";
             $this->assertEqual($address->getLatitude(), $validAddress->getLatitude());
             $this->assertEqual($address->getLongitude(), $validAddress->getLongitude());
         } else {
             echo "ZIP5 precision coordinates received";
             $this->assertEqual(substr($validAddress->getLatitude(), 0, 4), substr($address->getLatitude(), 0, 4), "Expected Latitude to start with '47.64'");
             $this->assertEqual(substr($validAddress->getLongitude(), 0, 6), substr($address->getLongitude(), 0, 6), "Expected Longitude to start with '-122.53'");
         }
     }
 }
示例#3
0
 /**
  * Sets attributes from the Mage address on the AvaTax Request address.
  *
  * @return $this
  */
 protected function _convertRequestAddress()
 {
     if (!$this->_requestAddress) {
         $this->_requestAddress = new Address();
     }
     $this->_requestAddress->setLine1($this->_mageAddress->getStreet(1));
     $this->_requestAddress->setLine2($this->_mageAddress->getStreet(2));
     $this->_requestAddress->setCity($this->_mageAddress->getCity());
     $this->_requestAddress->setRegion($this->_mageAddress->getRegionCode());
     $this->_requestAddress->setCountry($this->_mageAddress->getCountry());
     $this->_requestAddress->setPostalCode($this->_mageAddress->getPostcode());
     return $this;
 }
 public function buildMerchants($xml)
 {
     $merchants = new Merchants();
     $merchants->setPageOffset((string) $xml->PageOffset);
     $merchants->setTotalCount((string) $xml->TotalCount);
     // merchant
     $merchantArray = array();
     foreach ($xml->Merchant as $merchant) {
         $tmpMerchant = new Merchant();
         $tmpMerchant->setId((string) $merchant->Id);
         $tmpMerchant->setName((string) $merchant->Name);
         $tmpMerchant->setWebsiteUrl((string) $merchant->WebsiteUrl);
         $tmpMerchant->setPhoneNumber((string) $merchant->PhoneNumber);
         $tmpMerchant->setCategory((string) $merchant->Category);
         $tmpLocation = new Location();
         $location = $merchant->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         // ACCEPTANCE FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
         //$tmpAcceptance = new Acceptance();
         //$acceptance = $merchant->Acceptance;
         // FEATURES FRAMEWORK NEEDS LOOKED AT <RETURN XML AND DOC DOES NOT HAVE ALL VALUES>
         //$tmpFeatures = new Features();
         //$features =  $merchant->Features;
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpMerchant->setLocation($tmpLocation);
         array_push($merchantArray, $tmpMerchant);
     }
     $merchants->setMerchant($merchantArray);
     return $merchants;
 }
 public function buildAtms($xml)
 {
     $atms = new Atms();
     $atms->setPageOffset($xml->PageOffset);
     $atms->setTotalCount($xml->TotalCount);
     $atmArray = array();
     foreach ($xml->Atm as $atm) {
         $tmpAtm = new Atm();
         $tmpAtm->setHandicapAccessible((string) $atm->HandicapAccessible);
         $tmpAtm->setCamera((string) $atm->Camera);
         $tmpAtm->setAvailability((string) $atm->Availability);
         $tmpAtm->setAccessFees((string) $atm->AccessFees);
         $tmpAtm->setOwner((string) $atm->Owner);
         $tmpAtm->setSharedDeposit((string) $atm->SharedDeposit);
         $tmpAtm->setSurchargeFreeAlliance((string) $atm->SurchargeFreeAlliance);
         $tmpAtm->setSponsor((string) $atm->Sponsor);
         $tmpAtm->setSupportEMV((string) $atm->SupportEMV);
         $tmpAtm->setSurchargeFreeAllianceNetwork((string) $atm->SurchargeFreeAllianceNetwork);
         $tmpLocation = new Location();
         $location = $atm->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpAtm->setLocation($tmpLocation);
         array_push($atmArray, $tmpAtm);
     }
     $atms->setAtm($atmArray);
     return $atms;
 }
 public function buildAtms($xml)
 {
     $pageOffset = (string) $xml->PageOffset;
     $totalCount = (string) $xml->TotalCount;
     $restaurantArray = array();
     foreach ($xml->Restaurant as $restaurant) {
         $tmpRestaurant = new Restaurant();
         $tmpRestaurant->setId((string) $restaurant->Id);
         $tmpRestaurant->setName((string) $restaurant->Name);
         $tmpRestaurant->setWebsiteUrl((string) $restaurant->WebsiteUrl);
         $tmpRestaurant->setPhoneNumber((string) $restaurant->PhoneNumber);
         $tmpRestaurant->setCategory((string) $restaurant->Category);
         $tmpRestaurant->setLocalFavoriteInd((string) $restaurant->LocalFavoriteInd);
         $tmpRestaurant->setHiddenGemInd((string) $restaurant->HiddenGemInd);
         $tmpLocation = new Location();
         $location = $restaurant->Location;
         $tmpLocation->setName((string) $location->Name);
         $tmpLocation->setDistance((string) $location->Distance);
         $tmpLocation->setDistanceUnit((string) $location->DistanceUnit);
         $tmpAddress = new Address();
         $address = $location->Address;
         $tmpAddress->setLine1((string) $address->Line1);
         $tmpAddress->setLine2((string) $address->Line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setPostalCode((string) $address->PostCode);
         $tmpCountry = new Country();
         $tmpCountry->setName((string) $address->Country->Name);
         $tmpCountry->setCode((string) $address->Country->Code);
         $tmpCountrySubdivision = new CountrySubdivision();
         $tmpCountrySubdivision->setName((string) $address->CountrySubdivision->Name);
         $tmpCountrySubdivision->setCode((string) $address->CountrySubdivision->Code);
         $tmpAddress->setCountry($tmpCountry);
         $tmpAddress->setCountrySubdivision($tmpCountrySubdivision);
         $tmpPoint = new Point();
         $point = $location->Point;
         $tmpPoint->setLatitude((string) $point->Latitude);
         $tmpPoint->setLongitude((string) $point->Longitude);
         $tmpLocation->setPoint($tmpPoint);
         $tmpLocation->setAddress($tmpAddress);
         $tmpRestaurant->setLocation($tmpLocation);
         array_push($restaurantArray, $tmpRestaurant);
     }
     $restaurants = new Restaurants($pageOffset, $totalCount, $restaurantArray);
     return $restaurants;
 }
 public function buildMerchantIds($xml)
 {
     $merchantArray = array();
     foreach ($xml->ReturnedMerchants->Merchant as $merchant) {
         $xmlAddress = $merchant->Address;
         $xmlCountrySubdivision = $merchant->Address->CountrySubdivision;
         $xmlCountry = $merchant->Address->Country;
         $xmlMerchant = $merchant;
         $address = new Address();
         $address->setLine1((string) $xmlAddress->Line1);
         $address->setLine2((string) $xmlAddress->Line2);
         $address->setCity((string) $xmlAddress->City);
         $address->setPostalCode((string) $xmlAddress->PostalCode);
         $countrySubdivision = new CountrySubdivision();
         $countrySubdivision->setCode((string) $xmlCountrySubdivision->Code);
         $countrySubdivision->setName((string) $xmlCountrySubdivision->Name);
         $country = new Country();
         $country->setCode((string) $xmlCountry->Code);
         $country->setName((string) $xmlCountry->Name);
         $address->setCountrySubdivision($countrySubdivision);
         $address->setCountry($country);
         $tmpMerchant = new Merchant();
         $tmpMerchant->setAddress($address);
         $tmpMerchant->setPhoneNumber((string) $xmlMerchant->PhoneNumber);
         $tmpMerchant->setBrandName((string) $xmlMerchant->BrandName);
         $tmpMerchant->setMerchantCategory((string) $xmlMerchant->MerchantCategory);
         $tmpMerchant->setMerchantDbaName((string) $xmlMerchant->MerchantDbaName);
         $tmpMerchant->setDescriptorText((string) $xmlMerchant->DescriptorText);
         $tmpMerchant->setLegalCorporateName((string) $xmlMerchant->LegalCorporateName);
         $tmpMerchant->setBrickCount((string) $xmlMerchant->BrickCount);
         $tmpMerchant->setComment((string) $xmlMerchant->Comment);
         $tmpMerchant->setLocationId((string) $xmlMerchant->LocationId);
         $tmpMerchant->setOnlineCount((string) $xmlMerchant->OnlineCount);
         $tmpMerchant->setOtherCount((string) $xmlMerchant->OtherCount);
         $tmpMerchant->setSoleProprietorName((string) $xmlMerchant->SoleProprietorName);
         array_push($merchantArray, $tmpMerchant);
     }
     $returnedMerchants = new ReturnedMerchants();
     $returnedMerchants->setMerchant($merchantArray);
     $merchantIds = new MerchantIds();
     $merchantIds->setReturnedMerchants($returnedMerchants);
     $merchantIds->setMessage($xml->Message);
     return $merchantIds;
 }
示例#8
0
 /**
  * 
  * Builds and Returns an Address object based off of the JSON input.
  * 
  * @param vo_json   JSON representation of an address
  * @return  the Address
  * @throws JSONException  if the json is not properly formatted
  */
 static function buildFromJSON($o_data)
 {
     $o_instance = new Address();
     if ($o_data != NULL) {
         if (array_key_exists("address_name", $o_data)) {
             $o_instance->setName($o_data['address_name']);
         }
         if (array_key_exists("address_line1", $o_data)) {
             $o_instance->setLine1($o_data['address_line1']);
         }
         if (array_key_exists("address_line2", $o_data)) {
             $o_instance->setLine2($o_data['address_line2']);
         }
         if (array_key_exists("address_city", $o_data)) {
             $o_instance->setCity($o_data['address_city']);
         }
         if (array_key_exists("address_state", $o_data)) {
             $o_instance->setState($o_data['address_state']);
         }
         if (array_key_exists("address_zipcode", $o_data)) {
             $o_instance->setZipcode($o_data['address_zipcode']);
         }
         if (array_key_exists("address_country", $o_data)) {
             $o_instance->setCountry($o_data['address_country']);
         }
     }
     return $o_instance;
 }
<?php

require '../../AvaTax4PHP/AvaTax.php';
// include in all Avalara Scripts
require '../Credentials.php';
// where service URL, account, license key are set
$client = new AddressServiceSoap('Development');
$STDIN = fopen('php://stdin', 'r');
try {
    $address = new Address();
    // Get The address from the user via keyboard input
    echo "Address Line 1: ";
    $input = rtrim(fgets($STDIN));
    $address->setLine1($input);
    echo "Address Line 2: ";
    $input = rtrim(fgets($STDIN));
    $address->setLine2($input);
    echo "Address Line 3: ";
    $input = rtrim(fgets($STDIN));
    $address->setLine3($input);
    echo "City: ";
    $input = rtrim(fgets($STDIN));
    $address->setCity($input);
    echo "State/Province: ";
    $input = rtrim(fgets($STDIN));
    $address->setRegion($input);
    echo "Postal Code: ";
    $input = rtrim(fgets($STDIN));
    $address->setPostalCode($input);
    $textCase = TextCase::$Mixed;
    $coordinates = 1;
 private function CreateTaxRequestForBINo($bino)
 {
     $request = new GetTaxRequest();
     //Set origin Address
     $origin = new Address();
     $origin->setLine1("Avalara");
     $origin->setLine2("900 winslow way");
     $origin->setLine3("Suite 100");
     $origin->setCity("Bainbridge Island");
     $origin->setRegion("WA");
     $origin->setPostalCode("98110-1896");
     $origin->setCountry("USA");
     $request->setOriginAddress($origin);
     //Set destination address
     $destination = new Address();
     $destination->setLine1("3130 Elliott");
     $destination->setCity("Seattle");
     $destination->setRegion("WA");
     $destination->setPostalCode("98121");
     $destination->setCountry("USA");
     $request->setDestinationAddress($destination);
     //Set line
     $line = new Line();
     $line->setNo("1");
     //string  // line Number of invoice
     $line->setBusinessIdentificationNo("LL123");
     $line->setItemCode("Item123");
     //string
     $line->setQty(1.0);
     //decimal
     $line->setAmount(1010.0);
     $request->setLines(array($line));
     $request->setCompanyCode('DEFAULT');
     // Your Company Code From the Dashboard
     $request->setDocCode("DocTypeTest");
     $request->setBusinessIdentificationNo($bino);
     $request->setDocDate(date_format(new DateTime(), "Y-m-d"));
     $request->setCustomerCode("TaxSvcTest");
     //string Required
     $request->setSalespersonCode("");
     // string Optional
     $request->setDetailLevel(DetailLevel::$Tax);
     //Summary or Document or Line or Tax or Diagnostic
     return $request;
 }
require '../Credentials.php';
// where service URL, account, license key are set
$client = new TaxServiceSoap('Development');
$request = new GetTaxRequest();
//Add Origin Address
$origin = new Address();
$origin->setLine1("435 Ericksen Ave NE");
$origin->setLine2("Suite 200");
$origin->setCity("Bainbridge Island");
$origin->setRegion("WA");
$origin->setPostalCode("98110-1896");
$request->setOriginAddress($origin);
//Address
//Add Destination address
$destination = new Address();
$destination->setLine1("900 Winslow Way");
$destination->setLine2("Suite 200");
$destination->setCity("Bainbridge Island");
$destination->setRegion("WA");
$destination->setPostalCode("98110");
$request->setDestinationAddress($destination);
//Address
$request->setCompanyCode('DEFAULT');
// Your Company Code From the Dashboard
$request->setDocType(DocumentType::$SalesInvoice);
// Only supported types are SalesInvoice or SalesOrder
$dateTime = new DateTime();
$docCode = "PHPSample" . date_format($dateTime, "dmyGis");
$request->setDocCode($docCode);
//    invoice number
$request->setDocDate(date_format($dateTime, "Y-m-d"));
 function wc_autoship_taxnow_add_tax_rates($tax_rates, $schedule_id)
 {
     include_once WP_PLUGIN_DIR . '/taxnow_woo/taxnow-woo.class.php';
     include_once WP_PLUGIN_DIR . '/woocommerce-autoship/classes/wc-autoship-schedule.php';
     if (class_exists('class_taxNOW_woo') && class_exists('WC_Autoship_Schedule')) {
         // Create TaxNOW instance
         $taxnow_woo = new class_taxNOW_woo();
         // Get autoship schedule
         $schedule = new WC_Autoship_Schedule($schedule_id);
         // Get autoship customer
         $customer = $schedule->get_customer();
         // Create service
         $service = $taxnow_woo->create_service('TaxServiceSoap', false);
         $request = new GetTaxRequest();
         $request->setDocDate(date('Y-m-d', current_time('timestamp')));
         $request->setDocCode('');
         $request->setCustomerCode($customer->get_email());
         $request->setCompanyCode(get_option('tnwoo_company_code'));
         $request->setDocType(DocumentType::$SalesOrder);
         $request->setDetailLevel(DetailLevel::$Tax);
         $request->setCurrencyCode(get_option('woocommerce_currency'));
         $request->setBusinessIdentificationNo(get_option('tnwoo_business_vat_id'));
         // Origin address
         $origin = new Address();
         $origin->setLine1(get_option('tnwoo_origin_street'));
         $origin->setCity(get_option('tnwoo_origin_city'));
         $origin->setRegion(get_option('tnwoo_origin_state'));
         $origin->setPostalCode(get_option('tnwoo_origin_zip'));
         $origin->setCountry(get_option('tnwoo_origin_country'));
         $request->setOriginAddress($origin);
         // Destination address
         $destination = new Address();
         $destination->setLine1($customer->get('shipping_address_1'));
         $destination->setCity($customer->get('shipping_city'));
         $destination->setRegion($customer->get('shipping_state'));
         $destination->setPostalCode($customer->get('shipping_postcode'));
         $destination->setCountry($customer->get('shipping_country'));
         $request->setDestinationAddress($destination);
         // Lines items
         $items = $schedule->get_items();
         $lines = array();
         $global_tax_code = get_option('tnwoo_default_tax_code');
         foreach ($items as $i => $item) {
             // Get WooCommerce product ID
             $product_id = $item->get_product_id();
             // Create line item
             $line = new Line();
             $line->setItemCode($product_id);
             $line->setDescription($product_id);
             $tax_code = get_post_meta($product_id, '_taxnow_taxcode', true);
             $line->setTaxCode(!empty($tax_code) ? $tax_code : $global_tax_code);
             $line->setQty((int) $item->get_quantity());
             $line->setAmount((double) $item->get_autoship_price());
             $line->setNo($i + 1);
             $line->setDiscounted(0);
             $lines[] = $line;
         }
         $request->setLines($lines);
         // Pretax discount
         $discount_pretax = 0.0;
         // Send request
         $taxnow_woo->log_add_entry('calculate_tax', 'request', $request);
         try {
             $response = $service->getTax($request);
             $taxnow_woo->log_add_entry('calculate_tax', 'response', $response);
             if ($response->getResultCode() == SeverityLevel::$Success) {
                 foreach ($response->GetTaxLines() as $l => $TaxLine) {
                     foreach ($TaxLine->getTaxDetails() as $d => $TaxDetail) {
                         // Create WooCommerce tax rate
                         $tax_rate = array('rate' => 100.0 * $TaxDetail->getRate(), 'label' => $TaxDetail->getTaxName(), 'shipping' => 'no', 'compound' => 'no');
                         $tax_rates["wc_autoship_taxnow_{$l}_{$d}"] = $tax_rate;
                     }
                 }
             }
         } catch (Exception $e) {
             $taxnow_woo->log_add_entry('calculate_tax', 'exception', $e->getMessage());
         }
     }
     // Return tax rates
     return $tax_rates;
 }
 public function merchant_application($data)
 {
     $errors = array();
     $results = array();
     $i = 0;
     // Instantiate State Model
     $States = new State();
     // Newest modification for Merchant Application submission
     foreach ($data['Property'] as $property) {
         // Create client
         $o_bcpc = new BaseCommerceClient(RENTSQUARE_PARTNER_USER, RENTSQUARE_PARTNER_PASS, RENTSQUARE_PARTNER_KEY);
         $o_bcpc->setSandbox(BC_SANDBOXVALUE);
         $o_merch_app = new MerchantApplication();
         $o_account = new Account();
         // Account & Address infno
         //$o_account->setAccountName( $property['legal_name'] );
         $o_account->setAccountName("RentSquare LLC");
         $o_account->setAcceptACH(true);
         $o_account->setAcceptBC(true);
         // Legal Address
         $legal_state = $States->findById($property['legal_state_id']);
         $legal_state = $legal_state['State']['abbr'];
         $state_inc = $States->findById($property['state_inc']);
         $state_inc = $state_inc['State']['abbr'];
         $home_state = $States->findById($data['User']['state_id']);
         $home_state = $home_state['State']['abbr'];
         switch ($property['ownership_type']) {
             case 0:
                 $ownership_type = 'Corporation';
                 break;
             case 1:
                 $ownership_type = 'LLC';
                 break;
             case 2:
                 $ownership_type = 'Partnership';
                 $state_inc = 'N/A';
                 break;
             case 3:
                 $ownership_type = 'Sole Proprietor';
                 $property['legal_ein'] = $data['User']['ssn'];
                 $state_inc = 'N/A';
                 break;
         }
         $o_legal_address = new Address(Address::$XS_ADDRESS_NAME_LEGAL);
         //$o_legal_address->setLine1( $property['legal_street'] );
         //$o_legal_address->setCity( $property['legal_city'] );
         //$o_legal_address->setState( $legal_state );
         //$o_legal_address->setZipcode( $property['legal_zip'] );
         $o_legal_address->setLine1("218 S. Formosa Ave");
         $o_legal_address->setCity("Los Angeles");
         $o_legal_address->setState("CA");
         $o_legal_address->setZipcode("90036");
         $o_legal_address->setCountry("USA");
         $o_account->setLegalAddress($o_legal_address);
         //$o_account->setAccountPhoneNumber( $property['legal_phone'] );
         //$o_account->setCustomerServicePhoneNumber( $data['User']['phone'] );
         //$o_account->setEIN( $property['legal_ein'] );
         $o_account->setAccountPhoneNumber("303-809-6116");
         $o_account->setReferralPartnerID("a0Fi0000005jNJ3");
         //*** Hardcoded at BC
         $o_account->setCongaTemplateId("a0d310000006iKoi");
         //*** Hardcoded at BC
         $o_account->setCustomerServicePhoneNumber("303-809-6116");
         $o_account->setDBA($property['legal_dba']);
         $o_account->setEntityType(Account::$XS_ENTITY_TYPE_CORP);
         $o_account->setAssociationNumber("268000");
         $o_account->setEIN("452501975");
         $o_account->setIpAddressOfAppSubmission("192.168.0.1");
         //*** Hardcoded at BC
         $o_account->setWebsite('http://rentsquare.com');
         // Settlement Account Bank Info
         $o_account->setSettlementAccountBankName($property['bank_name']);
         $o_account->setSettlementAccountBankPhone('');
         //** TODO  Required I think - need to add to form?
         $o_account->setSettlementAccountName($property['legal_name']);
         $o_account->setSettlementAccountNumber($property['bank_account_num']);
         $o_account->setSettlementAccountRoutingNumber($property['routing_number']);
         $o_account->setSettlementSameAsFeeAccount(true);
         $o_merch_app->setAccount($o_account);
         $o_dba_address = new Address(Address::$XS_ADDRESS_NAME_DBA);
         $o_dba_address->setLine1($property['legal_street']);
         $o_dba_address->setCity($property['legal_city']);
         $o_dba_address->setState($state_inc);
         //** Should this be legal state??
         $o_dba_address->setZipcode($property['legal_zip']);
         $o_dba_address->setCountry("USA");
         $o_location = new Location();
         $o_location->setContactSameAsOwner(true);
         $o_location->setDescriptionOfProductsAndServices("Property Management Services");
         $o_location->setDBAAddress($o_dba_address);
         //$o_location->setDescription( Location::$XS_DESCRIPTION_CONSULTING );	// Dont see in Angela's document
         //$o_cal = Calendar->getInstance();						//*** Hardcoded at BC
         //$o_cal->add( Calendar->YEAR, -2 );						//*** Hardcoded at BC
         //$o_year = $o_cal->getTime();						//*** Hardcoded at BC
         //$o_location->setEntityStartDate( $o_year );					//*** Hardcoded at BC
         $o_location->setEntityState($legal_state);
         //** Should this be legal state??
         $o_location->setSalesAgentName('Sean Perlmutter');
         $o_location->setProgramPricing('RentSquare');
         $o_location->setProgramDetails('Fees Billed to Partner');
         $o_contact = new PrincipalContact();
         $o_contact->setLastName($data['User']['last_name']);
         $o_contact->setFirstName($data['User']['first_name']);
         $o_mailing = new Address(Address::$XS_ADDRESS_NAME_MAILING);
         $o_mailing->setLine1($data['User']['street']);
         $o_mailing->setCity($data['User']['city']);
         $o_mailing->setState($home_state);
         $o_mailing->setZipcode($data['User']['zip']);
         $o_mailing->setCountry("USA");
         $o_contact->setMailingAddress($o_mailing);
         $o_contact->setPhoneNumber($data['User']['phone']);
         $o_contact->setMobilePhoneNumber($data['User']['phone']);
         $o_contact->setEmail($data['User']['email']);
         $o_contact->setTitle("Property Manager");
         //  This 'new' call is not valid - causing fatal error - passing in DOB from applicaiton instead
         //$o_cal = new Calendar();
         //$o_cal->getInstance();
         //$o_cal->add( Calendar.YEAR, -60 );
         //$o_bday = $o_cal->getTime();
         $o_bday = $data['User']['dob'] . " 00:00:00";
         $o_contact->setBirthdate($o_bday);
         $o_contact->setAuthorizedUser(true);
         $o_contact->setAccountSigner(true);
         $o_contact->setOwnershipPercentage(100);
         $o_contact->setSSN($data['User']['ssn']);
         $o_contact->setIsPrimary(true);
         $o_location->addPrincipalContact($o_contact);
         $o_ach_details = new ACHDetails();
         $o_ach_details->setTransactionFee('3.95');
         $o_ach_details->setAverageTicketAmount($property['average_rent']);
         $o_ach_details->setMaxSingleTransactionAmount($property['average_rent'] * 3);
         $o_ach_details->setAverageMonthlyAmount($property['num_units'] * floatval($property['average_rent']));
         $o_ach_details->setMaxDailyAmount($property['num_units'] * floatval($property['average_rent']) * 3);
         $o_ach_details->setAuthMethodOnlinePercentage('100');
         $o_ach_details->setCompanyNameDescriptor('Same_As_legal');
         $o_ach_details->setDescriptor('RentSquare');
         $o_ach_details->addSubmissionMethod('Online');
         $o_ach_details->addPaymentToFrom('');
         $o_ach_details->setMerchantReports('true');
         $o_ach_details->setPaymentUrl('http://rentsquare.com');
         $o_ach_details->setIssueCredits('true');
         $o_ach_details->setIssueDebits('true');
         $o_location->setACHDetails($o_ach_details);
         $o_bc_details = new BankCardDetails();
         $o_bc_details->setAcceptAmex(false);
         $o_bc_details->addDebitBrandsRequested("Visa,MasterCard,Discover Network,Credit,Debit");
         $o_bc_details->setFeeOther("ie Annual Fee collected in month 3");
         //** Not Sure If this is RIGHT
         $o_bc_details->setAverageMonthlyVolume(urlencode(floatval($property['num_units']) * floatval($property['average_rent'])));
         $o_bc_details->setMaxTicket(150);
         $o_bc_details->setMaxMonthlyVolume(4000);
         $o_bc_details->setPaymentUrl("https://www.url.com/payment");
         $o_bc_details->setRecurring(true);
         $o_bc_details->setRetrievalFee(7.5);
         $o_bc_details->setWirelessFee(5);
         $o_bc_details->setCardholderCharged(BankCardDetails::$XS_CARDHOLDER_CHARGED_PURCHASE);
         $o_bc_details->setCardholderDataStoredLocally(false);
         $o_bc_details->setPreviouslyTerminatedAsVisaMastercardMerchant(false);
         $o_bc_details->setVisaMastercardSignage(true);
         $o_bc_details->set3rdPartyAccessToCardholderData(false);
         $o_bc_details->setMailOrderPercentage(0);
         $o_bc_details->setTelephoneOrderPercentage(0);
         $o_bc_details->setDuplicates(false);
         $o_bc_details->setUnpaidItemFee(30);
         $o_bc_details->setAuthorizationFee(0.25);
         $o_location->setBankCardDetails($o_bc_details);
         $o_merch_app->addLocation($o_location);
         $o_bc = $o_bcpc->submitApplication($o_merch_app);
         try {
             foreach ($o_bc as $merchAppObj) {
                 $status = $merchAppObj->getResponseCode();
                 $messages = $merchAppObj->getResponseMessages();
                 if ($status != "200") {
                     return array($status, $messages);
                 }
             }
         } catch (Exeption $e) {
             $status = 0;
             $messages = $e->getMessage();
             return array($status, $messages);
         }
     }
     // end foreach
     return array(1, '');
 }
示例#14
0
 function getTax($calculationHelper, $calc, $price, $sale = false, $committ = false)
 {
     if ($calc->activated == 0) {
         return false;
     }
     $shopperData = $this->getShopperData();
     if (!$shopperData) {
         return false;
     }
     //if(self::$stop) return self::$stop;
     if (!class_exists('TaxServiceSoap')) {
         require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
     }
     if (!class_exists('DocumentType')) {
         require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
     }
     if (!class_exists('DetailLevel')) {
         require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('ServiceMode')) {
         require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('GetTaxRequest')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
     }
     if (!class_exists('GetTaxResult')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
     }
     $client = new TaxServiceSoap('Development');
     $request = new GetTaxRequest();
     $origin = new Address();
     //$destination = $this->fillValidateAvalaraAddress($calc);
     //In Virtuemart we have not differenct warehouses, but we have a shipment address
     //So when the vendor has a shipment address, we assume that it is his warehouse
     //Later we can combine products with shipment addresses for different warehouse (yehye, future music)
     //But for now we just use the BT address
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $userId = VirtueMartModelVendor::getUserIdByVendorId($calc->virtuemart_vendor_id);
     $userModel = VmModel::getModel('user');
     $virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
     // this is needed to set the correct user id for the vendor when the user is logged
     $userModel->getVendor($calc->virtuemart_vendor_id);
     $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
     $vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
     //vmdebug('my vendor fields',$vendorFields);
     $origin->setLine1($vendorFields['fields']['address_1']['value']);
     $origin->setLine2($vendorFields['fields']['address_2']['value']);
     $origin->setCity($vendorFields['fields']['city']['value']);
     $origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
     $origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
     $origin->setPostalCode($vendorFields['fields']['zip']['value']);
     $request->setOriginAddress($origin);
     //Address
     if (isset($this->addresses[0])) {
         $destination = $this->addresses[0];
     } else {
         return FALSE;
     }
     $request->setDestinationAddress($destination);
     //Address
     //vmdebug('The date',$origin,$destination);
     $request->setCompanyCode($calc->company_code);
     // Your Company Code From the Dashboard
     if ($calc->committ and $sale) {
         $request->setDocType(DocumentType::$SalesInvoice);
         // Only supported types are SalesInvoice or SalesOrder
         $request->setCommit(true);
         //invoice number, problem is that the invoice number is at this time not known, but the order_number may reachable
         $request->setDocCode($committ);
         vmdebug('Request as SalesInvoice with invoiceNumber ' . $committ);
     } else {
         $request->setDocType(DocumentType::$SalesOrder);
         $request->setCommit(false);
         //invoice number, problem is that the invoice number is at this time not known, neither the order_number
         $request->setDocCode('VM2.0.16_order_request');
         vmdebug('Request as SalesOrder');
     }
     $request->setDocDate(date('Y-m-d'));
     //date
     //$request->setSalespersonCode("");             // string Optional
     $request->setCustomerCode($shopperData['customer_id']);
     //string Required
     if (isset($shopperData['tax_usage_type'])) {
         $request->setCustomerUsageType($shopperData['tax_usage_type']);
         //string   Entity Usage
     }
     $cartPrices = $calculationHelper->getCartPrices();
     //vmdebug('$cartPrices',$cartPrices);
     $request->setDiscount($cartPrices['discountAmount']);
     //decimal
     //$request->setDiscount(0.0);
     //	$request->setPurchaseOrderNo("");     //string Optional
     //If I understand correctly, we need to add for this an userfield, for example with the name
     //exemption_no, then user could enter their number.
     if (isset($shopperData['tax_exemption_number'])) {
         $request->setExemptionNo($shopperData['tax_exemption_number']);
         //string   if not using ECMS which keys on customer code
     }
     $request->setDetailLevel('Tax');
     //Summary or Document or Line or Tax or Diagnostic
     //	$request->setReferenceCode1("");       //string Optional
     //	$request->setReferenceCode2("");       //string Optional
     //	$request->setLocationCode("");        //string Optional - aka outlet id for tax forms
     /////////////////////////////////////////
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $products = array();
     if ($calculationHelper->inCart) {
         $products = $cart->products;
         $prices = $calculationHelper->getCartPrices();
         foreach ($products as $k => $product) {
             if (!empty($prices[$k]['discountedPriceWithoutTax'])) {
                 $price = $prices[$k]['discountedPriceWithoutTax'];
             } else {
                 if (!empty($prices[$k]['basePriceVariant'])) {
                     $price = $prices[$k]['basePriceVariant'];
                 } else {
                     vmdebug('There is no price in getTax for product ' . $k . ' ', $prices);
                     $price = 0.0;
                 }
             }
             $product->price = $price;
             if (!empty($price[$k]['discountAmount'])) {
                 $product->discount = $price[$k]['discountAmount'];
             } else {
                 $product->discount = FALSE;
             }
         }
     } else {
         $calculationHelper->_product->price = $price;
         $products[0] = $calculationHelper->_product;
         if (!isset($products[0]->amount)) {
             $products[0]->amount = 1;
         }
         if (isset($calculationHelper->productPrices['discountAmount'])) {
             $products[0]->discount = $calculationHelper->productPrices['discountAmount'];
         } else {
             $products[0]->discount = FALSE;
         }
     }
     $lines = array();
     $n = 0;
     $lineNumbersToCartProductId = array();
     foreach ($products as $k => $product) {
         $n++;
         $lineNumbersToCartProductId[$n] = $k;
         $line = new Line();
         $line->setNo($n);
         //string  // line Number of invoice
         $line->setItemCode($product->product_sku);
         //string
         $line->setDescription($product->product_name);
         //product description, like in cart, atm only the name, todo add customfields
         //$line->setTaxCode("");             //string
         $line->setQty($product->amount);
         //decimal
         $line->setAmount($product->price * $product->amount);
         //decimal // TotalAmmount
         $line->setDiscounted($product->discount * $product->amount);
         //boolean
         $line->setRevAcct("");
         //string
         $line->setRef1("");
         //string
         $line->setRef2("");
         //string
         if (isset($shopperData['tax_exemption_number'])) {
             $line->setExemptionNo($shopperData['tax_exemption_number']);
             //string
         }
         if (isset($shopperData['tax_usage_type'])) {
             $line->setCustomerUsageType($shopperData['tax_usage_type']);
             //string
         }
         $lines[] = $line;
     }
     $line = new Line();
     $line->setNo(++$n);
     //$lineNumbersToCartProductId[$n] = count($products)+1;
     $line->setItemCode($cart->virtuemart_shipmentmethod_id);
     $line->setDescription('Shipment');
     $line->setQty(1);
     //$line->setTaxCode();
     $cartPrices = $calculationHelper->getCartPrices();
     //vmdebug('$calculationHelper $cartPrices',$cartPrices);
     $line->setAmount($cartPrices['shipmentValue']);
     if (isset($shopperData['tax_exemption_number'])) {
         $line->setExemptionNo($shopperData['tax_exemption_number']);
         //string
     }
     if (isset($shopperData['tax_usage_type'])) {
         $line->setCustomerUsageType($shopperData['tax_usage_type']);
         //string
     }
     $lines[] = $line;
     //vmdebug('avalaragetTax setLines',$lines);
     $request->setLines($lines);
     //vmdebug('My request',$request);
     $totalTax = 0.0;
     try {
         if (!class_exists('TaxLine')) {
             require VMAVALARA_CLASS_PATH . DS . 'TaxLine.class.php';
         }
         if (!class_exists('TaxDetail')) {
             require VMAVALARA_CLASS_PATH . DS . 'TaxDetail.class.php';
         }
         vmSetStartTime('avagetTax');
         $getTaxResult = $client->getTax($request);
         vmTime('Avalara getTax', 'avagetTax');
         /*
         * [0] => getDocCode
             [1] => getAdjustmentDescription
             [2] => getAdjustmentReason
             [3] => getDocDate
             [4] => getTaxDate
             [5] => getDocType
             [6] => getDocStatus
             [7] => getIsReconciled
             [8] => getLocked
             [9] => getTimestamp
             [10] => getTotalAmount
             [11] => getTotalDiscount
             [12] => getTotalExemption
             [13] => getTotalTaxable
             [14] => getTotalTax
             [15] => getHashCode
             [16] => getVersion
             [17] => getTaxLines
             [18] => getTotalTaxCalculated
             [19] => getTaxSummary
             [20] => getTaxLine
             [21] => getTransactionId
             [22] => getResultCode
             [23] => getMessages
         */
         //vmdebug( 'GetTax is: '. $getTaxResult->getResultCode(),$getTaxResult);
         if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
             //vmdebug("DocCode: ".$request->getDocCode() );
             //vmdebug("DocId: ".$getTaxResult->getDocId()."\n");
             vmdebug("TotalAmount: " . $getTaxResult->getTotalAmount());
             $totalTax = $getTaxResult->getTotalTax();
             vmdebug("TotalTax: " . $totalTax);
             foreach ($getTaxResult->getTaxLines() as $ctl) {
                 if ($calculationHelper->inCart) {
                     $nr = $ctl->getNo();
                     if (isset($lineNumbersToCartProductId[$nr])) {
                         $quantity = $products[$lineNumbersToCartProductId[$nr]]->amount;
                         //on the long hand, the taxAmount must be replaced by taxAmountQuantity to avoid rounding errors
                         $prices[$lineNumbersToCartProductId[$ctl->getNo()]]['taxAmount'] = $ctl->getTax() / $quantity;
                         $prices[$lineNumbersToCartProductId[$ctl->getNo()]]['taxAmountQuantity'] = $ctl->getTax();
                     } else {
                         //$this->_cartPrices['shipmentValue'] = 0; //could be automatically set to a default set in the globalconfig
                         //$this->_cartPrices['shipmentTax'] = 0;
                         //$this->_cartPrices['shipmentTotal'] = 0;
                         //$prices = array('shipmentValue'=>$cartPrices['shipmentValue'],'shipmentTax'=> $ctl->getTax(), 'shipmentTotal' =>($cartPrices['shipmentValue'] +$ctl->getTax() ));
                         //vmdebug('my $cartPrices',$cartPrices);
                         $prices['shipmentTax'] = $ctl->getTax();
                         $prices['salesPriceShipment'] = $prices['shipmentValue'] + $ctl->getTax();
                         //$cartPrices = array_merge($prices,$cartPrices);
                         //$calculationHelper->setCartPrices( $cartPrices );
                         $totalTax = $totalTax - $ctl->getTax();
                         //vmdebug('my $cartPrices danach',$cartPrices);
                     }
                 }
                 //vmdebug('my lines ',$ctl);
                 //vmdebug( "     Line: ".$ctl->getNo()." Tax: ".$ctl->getTax()." TaxCode: ".$ctl->getTaxCode());
                 foreach ($ctl->getTaxDetails() as $ctd) {
                     //vmdebug( "          Juris Type: ".$ctd->getJurisType()."; Juris Name: ".$ctd->getJurisName()."; Rate: ".$ctd->getRate()."; Amt: ".$ctd->getTax() );
                 }
             }
             if ($calculationHelper->inCart) {
                 $calculationHelper->setCartPrices($prices);
             }
         } else {
             foreach ($getTaxResult->getMessages() as $msg) {
                 vmError($msg->getName() . ": " . $msg->getSummary());
             }
         }
     } catch (SoapFault $exception) {
         $msg = "Exception: ";
         if ($exception) {
             $msg .= $exception->faultstring;
         }
         vmdebug($msg . '<br />' . $client->__getLastRequest() . '<br />' . $client->__getLastResponse());
     }
     //self::$stop = $totalTax;
     return $totalTax;
 }
示例#15
0
 public function getAddressesByRayon($address, $rayon)
 {
     $list = [];
     try {
         if (!parent::getBdd()->inTransaction()) {
             parent::getBdd()->beginTransaction();
         }
         $query = "SELECT *, ( 6371 * acos( cos( radians(:latitude) ) * cos( radians( latitude ) ) * cos( radians( longitude ) - radians(:longitude) )\n              + sin( radians(:latitude) ) * sin( radians( latitude ) ) ) ) AS distance FROM address HAVING distance < :rayon ORDER BY distance LIMIT 0 , 150;";
         $request = parent::getBdd()->prepare($query);
         $request->bindParam(':latitude', $address->getLatitude());
         $request->bindParam(':longitude', $address->getLongitude());
         $request->bindParam(':rayon', $rayon);
         $request->execute();
         while ($data = $request->fetch()) {
             $address = new Address();
             $address->setId($data['id']);
             $address->setLine1($data['line1']);
             $address->setLine2($data['line2']);
             $address->setZipCode($data['zipcode']);
             $address->setCity($data['city']);
             $address->setLatitude($data['latitude']);
             $address->setLongitude($data['longitude']);
             array_push($list, $address);
         }
         if ($list == []) {
             return null;
         }
         return $list;
     } catch (Exception $e) {
         error_log($e->getMessage());
     }
     return null;
 }
示例#16
0
 /**
  * Generic address maker
  *
  * @param string $line1
  * @param string $line2
  * @param string $city
  * @param string $state
  * @param string $zip
  * @param string $country
  * @return Address
  */
 protected function _newAddress($line1, $line2, $city, $state, $zip, $country = 'USA')
 {
     // force string type because hash key generation uses serialize() in Estimate.php
     $address = new Address();
     $address->setLine1((string) $line1);
     $address->setLine2((string) $line2);
     $address->setCity((string) $city);
     $address->setRegion((string) $state);
     $address->setPostalCode((string) $zip);
     $address->setCountry((string) $country);
     return $address;
 }
 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();
 }
function CalcTax($taxSvcSoapClient, $companyCode)
{
    $request = new GetTaxRequest();
    $origin = new Address();
    $destination = new Address();
    $line1 = new Line();
    $origin->setLine1("435 Ericksen Ave NE");
    $origin->setLine2("Suite 200");
    $origin->setCity("Bainbridge Island");
    $origin->setRegion("WA");
    $origin->setPostalCode("98110-1896");
    $destination->setLine1("900 Winslow Way");
    $destination->setLine2("Suite 200");
    $destination->setCity("Bainbridge Island");
    $destination->setRegion("WA");
    $destination->setPostalCode("98110");
    $request->setOriginAddress($origin);
    //Address
    $request->setDestinationAddress($destination);
    //Address
    $request->setCompanyCode($companyCode);
    // Your Company Code From the Dashboard
    $request->setDocType(DocumentType::$SalesInvoice);
    // Only supported types are SalesInvoice or SalesOrder
    $dateTime = new DateTime();
    $docCode = "PHPSample" . date_format($dateTime, "dmyGis");
    $request->setDocCode($docCode);
    //    invoice number
    $request->setDocDate(date_format($dateTime, "Y-m-d"));
    //date
    $request->setSalespersonCode("");
    // string Optional
    $request->setCustomerCode("Cust123");
    //string Required
    $request->setCustomerUsageType("");
    //string   Entity Usage
    $request->setDiscount(0.0);
    //decimal
    $request->setPurchaseOrderNo("");
    //string Optional
    $request->setExemptionNo("");
    //string   if not using ECMS which keys on customer code
    $request->setDetailLevel(DetailLevel::$Document);
    $request->setCommit("true");
    // commit upon tax calc
    $request->setReferenceCode("");
    //string Optional
    $request->setLocationCode("");
    //string Optional - aka outlet id for tax forms
    $line1->setNo("1");
    //string  // line Number of invoice
    $line1->setItemCode("SKU123");
    //string
    $line1->setDescription("Invoice Calculated From PHP SDK");
    //string
    $line1->setTaxCode("");
    //string
    $line1->setQty(1.0);
    //decimal
    $line1->setAmount(1000.0);
    //decimal // TotalAmmount
    $line1->setDiscounted(false);
    //boolean
    $line1->setRevAcct("");
    //string
    $line1->setRef1("");
    //string
    $line1->setRef2("");
    //string
    $line1->setExemptionNo("");
    //string
    $line1->setCustomerUsageType("");
    //string
    $request->setLines(array($line1));
    //array
    try {
        $getTaxResult = $taxSvcSoapClient->getTax($request);
        echo 'GetTax Result: ' . $getTaxResult->getResultCode() . "\n";
        if ($getTaxResult->getResultCode() == SeverityLevel::$Success) {
            echo "DocCode: " . $request->getDocCode() . "\n";
            echo "TotalAmount: " . $getTaxResult->getTotalAmount() . "\n";
            echo "TotalTax: " . $getTaxResult->getTotalTax() . "\n";
        } else {
            foreach ($getTaxResult->getMessages() as $msg) {
                echo $msg->getName() . ": " . $msg->getSummary() . "\n";
            }
        }
    } catch (SoapFault $exception) {
        $msg = "Exception: ";
        if ($exception) {
            $msg .= $exception->faultstring;
        }
        echo $msg . "\n";
        echo $taxSvcSoapClient->__getLastRequest() . "\n";
        echo $taxSvcSoapClient->__getLastResponse() . "\n";
    }
    return $request->getDocCode();
}
 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";
     }
 }
示例#20
0
 /**
  * Used to get all the contacts from Exchange
  * @return array of contact
  */
 public function getAllContacts()
 {
     try {
         $contactList = [];
         $request = new EWSType_FindItemType();
         $request->ItemShape = new EWSType_ItemResponseShapeType();
         $request->ItemShape->BaseShape = EWSType_DefaultShapeNamesType::ALL_PROPERTIES;
         $request->ContactsView = new EWSType_ContactsViewType();
         $request->ParentFolderIds = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
         $request->ParentFolderIds->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
         $request->ParentFolderIds->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CONTACTS;
         $request->Traversal = EWSType_ItemQueryTraversalType::SHALLOW;
         $response = parent::getEws()->FindItem($request);
         if (isset($response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Contact)) {
             $stdContacts = $response->ResponseMessages->FindItemResponseMessage->RootFolder->Items->Contact;
         } else {
             return null;
         }
         foreach ($stdContacts as $c) {
             $contact = new Contact();
             if (isset($c->ItemId->Id)) {
                 $contact->setExchangeId($c->ItemId->Id);
             }
             if (isset($c->CompleteName)) {
                 if (isset($c->CompleteName->FirstName)) {
                     $contact->setFirstName($c->CompleteName->FirstName);
                 }
                 if (isset($c->CompleteName->LastName)) {
                     if (strpos($c->CompleteName->LastName, '--') !== false) {
                         $nameAndType = $this->getTypeFromName($c->CompleteName->LastName);
                         if (sizeof($nameAndType) == 2) {
                             $contact->setName($nameAndType[0]);
                             $typeService = new TypeService();
                             $type = $typeService->getType($nameAndType[1]);
                             if ($type != null) {
                                 $contact->setType($type);
                             } else {
                                 $contact->setType(null);
                             }
                         } else {
                             $contact->setName($c->CompleteName->LastName);
                         }
                     } else {
                         $contact->setName($c->CompleteName->LastName);
                     }
                 }
             }
             if (isset($c->PhoneNumbers->Entry)) {
                 if (is_array($c->PhoneNumbers->Entry)) {
                     $contact->setPhone($c->PhoneNumbers->Entry[0]->_);
                     if (sizeof($c->PhoneNumbers->Entry) > 1) {
                         if (isset($c->PhoneNumbers->Entry[1])) {
                             $contact->setPhone2($c->PhoneNumbers->Entry[1]->_);
                         }
                     }
                     if (sizeof($c->PhoneNumbers->Entry) > 2) {
                         if (isset($c->PhoneNumbers->Entry[2])) {
                             $contact->setPhone3($c->PhoneNumbers->Entry[2]->_);
                         }
                     }
                 } else {
                     $contact->setPhone($c->PhoneNumbers->Entry->_);
                 }
             }
             if (isset($c->EmailAddresses->Entry)) {
                 if (is_array($c->EmailAddresses->Entry)) {
                     $contact->setMail($c->EmailAddresses->Entry[0]->_);
                 } else {
                     $contact->setMail($c->EmailAddresses->Entry->_);
                 }
             }
             if (isset($c->CompanyName)) {
                 $contact->setCompany($c->CompanyName);
             }
             if (isset($c->PhysicalAddresses->Entry)) {
                 $address = new Address();
                 $stdAddress = $c->PhysicalAddresses->Entry;
                 if (is_array($stdAddress)) {
                     $address->setLine1($stdAddress[0]->Street);
                     $address->setZipCode($stdAddress[0]->PostalCode);
                     $address->setCity($stdAddress[0]->City);
                 } else {
                     if (isset($stdAddress->Street)) {
                         $address->setLine1($stdAddress->Street);
                     }
                     if (isset($stdAddress->PostalCode)) {
                         $address->setZipCode($stdAddress->PostalCode);
                     }
                     if (isset($stdAddress->City)) {
                         $address->setCity($stdAddress->City);
                     }
                 }
                 $contact->setAddress($address);
             }
             array_push($contactList, $contact);
         }
         if ($contactList == []) {
             $contactList = null;
         }
         return $contactList;
     } catch (Exception $e) {
         error_log($e->getMessage());
     }
     return null;
 }
 private function buildInquireMapping($xml)
 {
     $inquireMapping = new InquireMapping();
     $inquireMapping->setRequestId((string) $xml->RequestId);
     $mappings = new Mappings();
     $mappingArray = array();
     foreach ($xml->Mappings->Mapping as $mapping) {
         $tmpMapping = new Mapping();
         $tmpMapping->setMappingId((string) $mapping->MappingId);
         $tmpMapping->setSubscriberId((string) $mapping->SubscriberId);
         $tmpMapping->setAccountUsage((string) $mapping->AccountUsage);
         $tmpMapping->setDefaultIndicator((string) $mapping->DefaultIndicator);
         $tmpMapping->setAlias((string) $mapping->Alias);
         $tmpMapping->setICA((string) $mapping->ICA);
         $tmpMapping->setAccountNumber((string) $mapping->AccountNumber);
         $tmpCardholderFullName = new CardholderFullName();
         $cardholderFullName = $mapping->CardholderFullName;
         $tmpCardholderFullName->setCardholderFirstName((string) $cardholderFullName->CardholderFirstName);
         $tmpCardholderFullName->setCardholderMiddleName((string) $cardholderFullName->CardholderMiddleName);
         $tmpCardholderFullName->setCardholderLastName((string) $cardholderFullName->CardholderLastName);
         $tmpAddress = new Address();
         $address = $mapping->Address;
         $tmpAddress->setLine1((string) $address->line1);
         $tmpAddress->setLine2((string) $address->line2);
         $tmpAddress->setCity((string) $address->City);
         $tmpAddress->setCountrySubdivision((string) $address->CountrySubdivision);
         $tmpAddress->setPostalCode((string) $address->PostalCode);
         $tmpAddress->setCountry((string) $address->Country);
         $tmpReceivingEligibility = new ReceivingEligibility();
         $receivingEligibility = $mapping->ReceivingEligibility;
         $tmpReceivingEligibility->setEligible((string) $receivingEligibility->Eligible);
         $tmpCurrency = new Currency();
         $currency = $receivingEligibility->Currency;
         $tmpCurrency->setAlphaCurrencyCode((string) $currency->AlphaCurrencyCode);
         $tmpCurrency->setNumericCurrencyCode((string) $currency->NumericCurrencyCode);
         $tmpCountry = new Country();
         $country = $receivingEligibility->Country;
         $tmpCountry->setAlphaCountryCode((string) $country->AlphaCountryCode);
         $tmpCountry->setAlphaCountryCode((string) $country->NumericCountryCode);
         $tmpBrand = new Brand();
         $brand = $receivingEligibility->Brand;
         $tmpBrand->setAcceptanceBrandCode((string) $brand->AcceptanceBrandCode);
         $tmpBrand->setProductBrandCode((string) $brand->ProductBrandCode);
         $tmpMapping->setExpiryDate((string) $mapping->ExpiryDate);
         $tmpReceivingEligibility->setCurrency($tmpCurrency);
         $tmpReceivingEligibility->setCountry($tmpCountry);
         $tmpReceivingEligibility->setBrand($tmpBrand);
         $tmpMapping->setCardholderFullName($tmpCardholderFullName);
         $tmpMapping->setAddress($tmpAddress);
         $tmpMapping->setReceivingEligibility($tmpReceivingEligibility);
         array_push($mappingArray, $tmpMapping);
     }
     $mappings->setMapping($mappingArray);
     $inquireMapping->setMappings($mappings);
     return $inquireMapping;
 }
示例#22
0
 function createStandardRequest($calc, $products, $sign = 1)
 {
     if (!class_exists('TaxServiceSoap')) {
         require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
     }
     if (!class_exists('DocumentType')) {
         require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
     }
     if (!class_exists('DetailLevel')) {
         require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('ServiceMode')) {
         require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('GetTaxRequest')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxRequest.class.php';
     }
     if (!class_exists('GetTaxResult')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
     }
     if (!class_exists('Address')) {
         require VMAVALARA_CLASS_PATH . DS . 'Address.class.php';
     }
     if (is_object($calc)) {
         $calc = get_object_vars($calc);
     }
     $request = new GetTaxRequest();
     $origin = new Address();
     //In Virtuemart we have not differenct warehouses, but we have a shipment address
     //So when the vendor has a shipment address, we assume that it is his warehouse
     //Later we can combine products with shipment addresses for different warehouse (yehye, future music)
     //But for now we just use the BT address
     if (!class_exists('VirtueMartModelVendor')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'vendor.php';
     }
     $userId = VirtueMartModelVendor::getUserIdByVendorId($calc['virtuemart_vendor_id']);
     $userModel = VmModel::getModel('user');
     $virtuemart_userinfo_id = $userModel->getBTuserinfo_id($userId);
     // this is needed to set the correct user id for the vendor when the user is logged
     $userModel->getVendor($calc['virtuemart_vendor_id']);
     $vendorFieldsArray = $userModel->getUserInfoInUserFields('mail', 'BT', $virtuemart_userinfo_id, FALSE, TRUE);
     $vendorFields = $vendorFieldsArray[$virtuemart_userinfo_id];
     $origin->setLine1($vendorFields['fields']['address_1']['value']);
     $origin->setLine2($vendorFields['fields']['address_2']['value']);
     $origin->setCity($vendorFields['fields']['city']['value']);
     $origin->setCountry($vendorFields['fields']['virtuemart_country_id']['country_2_code']);
     $origin->setRegion($vendorFields['fields']['virtuemart_state_id']['state_2_code']);
     $origin->setPostalCode($vendorFields['fields']['zip']['value']);
     $request->setOriginAddress($origin);
     //Address
     if (isset($this->addresses[0])) {
         $destination = $this->addresses[0];
     } else {
         return FALSE;
     }
     if (!class_exists('calculationHelper')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'calculationh.php';
     }
     $calculator = calculationHelper::getInstance();
     $request->setCurrencyCode($calculator->_currencyDisplay->_vendorCurrency_code_3);
     //CurrencyCode
     $request->setDestinationAddress($destination);
     //Address
     $request->setCompanyCode($calc['company_code']);
     // Your Company Code From the Dashboard
     $request->setDocDate(date('Y-m-d'));
     //date, checked
     $request->setCustomerCode(self::$vmadd['customer_number']);
     //string Required
     if (isset(self::$vmadd['tax_usage_type'])) {
         $request->setCustomerUsageType(self::$vmadd['tax_usage_type']);
         //string   Entity Usage
     }
     if (isset(self::$vmadd['tax_exemption_number'])) {
         $request->setExemptionNo(self::$vmadd['tax_exemption_number']);
         //string   if not using ECMS which keys on customer code
     }
     if (isset(self::$vmadd['taxOverride'])) {
         $request->setTaxOverride(self::$vmadd['taxOverride']);
         avadebug('I set tax override ', self::$vmadd['taxOverride']);
     }
     $setAllDiscounted = false;
     if (isset($products['discountAmount'])) {
         if (!empty($products['discountAmount'])) {
             //$request->setDiscount($sign * $products['discountAmount'] * (-1));            //decimal
             $request->setDiscount($sign * $products['discountAmount']);
             //decimal
             vmdebug('We sent as discount ' . $request->getDiscount());
             $setAllDiscounted = true;
         }
         unset($products['discountAmount']);
     }
     $request->setDetailLevel('Tax');
     //Summary or Document or Line or Tax or Diagnostic
     $lines = array();
     $n = 0;
     $this->_lineNumbersToCartProductId = array();
     foreach ($products as $k => $product) {
         $n++;
         $this->_lineNumbersToCartProductId[$n] = $k;
         $line = new Line();
         $line->setNo($n);
         //string  // line Number of invoice
         $line->setItemCode($product['product_sku']);
         //string
         $line->setDescription($product['product_name']);
         //product description, like in cart, atm only the name, todo add customfields
         if (!empty($product['categories'])) {
             //avadebug('AvaTax setTaxCode Product has categories !',$catNames);
             if (!class_exists('TableCategories')) {
                 require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'categories.php';
             }
             $db = JFactory::getDbo();
             $catTable = new TableCategories($db);
             foreach ($product['categories'] as $cat) {
                 $catTable->load($cat);
                 $catslug = $catTable->slug;
                 if (strpos($catslug, 'avatax-') !== FALSE) {
                     $taxCode = substr($catslug, 7);
                     if (!empty($taxCode)) {
                         $line->setTaxCode($taxCode);
                     } else {
                         vmError('AvaTax setTaxCode, category could not be parsed ' . $catslug);
                     }
                     break;
                 }
             }
         }
         //$line->setTaxCode("");             //string
         $line->setQty($product['amount']);
         //decimal
         $line->setAmount($sign * $product['price'] * $product['amount']);
         //decimal // TotalAmmount
         if ($setAllDiscounted or !empty($product['discount'])) {
             $line->setDiscounted(1);
         } else {
             $line->setDiscounted(0);
         }
         $line->setRevAcct("");
         //string
         $line->setRef1("");
         //string
         $line->setRef2("");
         //string
         if (isset(self::$vmadd['tax_usage_type'])) {
             $line->setCustomerUsageType(self::$vmadd['tax_usage_type']);
             //string   Entity Usage
         }
         if (isset(self::$vmadd['tax_exemption_number'])) {
             $line->setExemptionNo(self::$vmadd['tax_exemption_number']);
             //string   if not using ECMS which keys on customer code
         }
         if (isset(self::$vmadd['taxOverride'])) {
             //create new TaxOverride Object set
             //$line->setTaxOverride(self::$vmadd['taxOverride']);
         }
         $lines[] = $line;
     }
     $this->newATConfig($calc);
     $request->setLines($lines);
     return $request;
 }
示例#23
0
function contactParser($data)
{
    $contact = new Contact();
    if (isset($data['id'])) {
        $contact->setId($data['id']);
    }
    if (isset($data['firstName'])) {
        $contact->setFirstName($data['firstName']);
    }
    if (isset($data['name'])) {
        $contact->setName($data['name']);
    }
    if (isset($data['mail'])) {
        $contact->setMail($data['mail']);
    }
    if (isset($data['phone'])) {
        $contact->setPhone($data['phone']);
    }
    if (isset($data['phone2'])) {
        $contact->setPhone2($data['phone2']);
    }
    if (isset($data['phone3'])) {
        $contact->setPhone3($data['phone3']);
    }
    if (isset($data['company'])) {
        $contact->setCompany($data['company']);
    }
    if (isset($data['address'])) {
        $dataAddress = $data['address'];
        $address = new Address();
        if (isset($dataAddress['id'])) {
            $address->setId($dataAddress['id']);
        }
        if (isset($dataAddress['line1'])) {
            $address->setLine1($dataAddress['line1']);
        }
        if (isset($dataAddress['line2'])) {
            $address->setLine2($dataAddress['line2']);
        }
        if (isset($dataAddress['zipCode'])) {
            $address->setZipCode($dataAddress['zipCode']);
        }
        if (isset($dataAddress['city'])) {
            $address->setCity($dataAddress['city']);
        }
        if (isset($dataAddress['latitude']) && isset($dataAddress['longitude'])) {
            $address->setLatitude($dataAddress['latitude']);
            $address->setLongitude($dataAddress['longitude']);
        } else {
            $mapService = new GoogleMapService();
            $latlng = $mapService->getLatLong($address);
            if ($latlng != [] && sizeof($latlng) == 2) {
                $address->setLatitude($latlng[0]);
                $address->setLongitude($latlng[1]);
            }
        }
        $contact->setAddress($address);
    }
    if (isset($data['type'])) {
        if (isset($data['type']['id']) && isset($data['type']['name'])) {
            $type = new Type($data['type']['id'], $data['type']['name']);
        } elseif (isset($data['type']['name'])) {
            $type = new Type(null, $data['type']['name']);
        } else {
            $type = null;
        }
        $contact->setType($type);
    }
    if (isset($data['exchangeId'])) {
        $contact->setExchangeId($data['exchangeId']);
    }
    return $contact;
}
示例#24
0
 /**
  * Generic address maker
  *
  * @param string $line1
  * @param string $line2
  * @param string $city
  * @param string $state
  * @param string $zip
  * @param string $country
  * @return Address
  */
 protected function _newAddress($line1, $line2, $city, $state, $zip, $country = 'USA')
 {
     $address = new Address();
     $address->setLine1($line1);
     $address->setLine2($line2);
     $address->setCity($city);
     $address->setRegion($state);
     $address->setPostalCode($zip);
     $address->setCountry($country);
     return $address;
 }
 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";
     }
 }