/**
     * Given array to rest post
     * 
     * @param void
     * @return array:
     */
    protected function getXmlData()
    {
        $xml = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>
		<globkurier>
			<login>' . GlobKurierTools::gkDecryptString($this->getLogin()) . '</login>
			<password>' . GlobKurierTools::gkDecryptString($this->getPassword()) . '</password>
			<apikey>' . GlobKurierTools::gkDecryptString($this->getApiKey()) . '</apikey>
			<order_method>' . self::PS_METHOD . '</order_method>
			<order_source>' . self::PS_SOURCE . '</order_source>
			<orders>
				<order>
					<id_cart>' . $this->getIntIdCart() . '</id_cart>
					<id_customer>' . $this->getIntIdCustomer() . '</id_customer>
					<shop_key>' . $this->getStrShopKey() . '</shop_key>
					<secure_key>' . $this->getStrSecureKey() . '</secure_key>
					<reference>' . $this->getStrReference() . '</reference>
					<order_number>' . $this->getStrOrderNumber() . '</order_number>
					<sent_date>' . $this->getStrDate() . '</sent_date>
					<receiver>
						<name>' . $this->getStrRecipientName() . '</name>
						<street>' . $this->getStrRecipientAddress1() . '</street>
						<house_number>' . $this->getStrRecipientAddress2() . '</house_number>
						<postal_code>' . $this->getStrRecipientZipCode() . '</postal_code>
						<city>' . $this->getStrRecipientCity() . '</city>
						<country>0</country>
						<contact_person>' . $this->getStrRecipientName() . '</contact_person>
						<phone>' . $this->getStrRecipientPhone() . '</phone>
						<email>' . $this->getStrRecipientMail() . '</email>
					</receiver>
				</order>
			</orders>
			<token>' . $this->getStrToken() . '</token>
		</globkurier>';
        return $xml;
    }
Ejemplo n.º 2
0
 /**
  * ActionValidateOrder
  * 
  * @param array $params
  * @return void
  */
 public function hookActionValidateOrder($params)
 {
     $order_number = GlobKurierTools::getOrderNumber();
     $obj_globkurier_order = new GlobKurierOrder();
     $obj_globkurier_order->id_order = (int) $params['order']->id;
     $obj_globkurier_order->id_cart = (int) $params['cart']->id;
     $obj_globkurier_order->id_customer = (int) $params['cart']->id_customer;
     $obj_globkurier_order->order_number = (string) $order_number;
     $obj_globkurier_order->flag = GlobKurierOrder::PS_ORDER_NOT_SYNC;
     $obj_globkurier = new GlobKurierLogin($this->login, $this->password, $this->apikey);
     $obj_json_login = Tools::jsonDecode($obj_globkurier->sendData());
     if ($obj_json_login->status == true) {
         $obj_delivery_address = new Address($params['cart']->id_address_delivery);
         $obj_globkurier_insert_order = new GlobKurierInsertOrder($this->login, $this->password, $this->apikey);
         $obj_globkurier_insert_order->setIntIdCart((int) $params['cart']->id);
         $obj_globkurier_insert_order->setStrReference((string) $params['order']->reference);
         $obj_globkurier_insert_order->setStrOrderNumber((string) $order_number);
         $obj_globkurier_insert_order->setIntIdCustomer((int) $params['cart']->id_customer);
         $obj_globkurier_insert_order->setStrSecureKey((string) $params['cart']->secure_key);
         $obj_globkurier_insert_order->setStrShopKey(Configuration::get('GLOBKURIER_SHOP_KEY'));
         $obj_globkurier_insert_order->setStrDate((string) $params['cart']->date_upd);
         $obj_globkurier_insert_order->setStrRecipientName((string) $obj_delivery_address->company . ' ' . $obj_delivery_address->lastname . ' ' . $obj_delivery_address->firstname);
         $obj_globkurier_insert_order->setStrRecipientAddress1((string) $obj_delivery_address->address1);
         $obj_globkurier_insert_order->setStrRecipientAddress2((string) $obj_delivery_address->address2);
         $obj_globkurier_insert_order->setStrRecipientZipCode((string) $obj_delivery_address->postcode);
         $obj_globkurier_insert_order->setStrRecipientCity((string) $obj_delivery_address->city);
         $obj_globkurier_insert_order->setStrRecipientPhone((string) $obj_delivery_address->phone_mobile);
         $obj_globkurier_insert_order->setStrRecipientMail((string) $params['customer']->email);
         $obj_globkurier_insert_order->setStrToken((string) sha1($obj_delivery_address->company . ' ' . $obj_delivery_address->lastname . ' ' . $obj_delivery_address->firstname . $obj_delivery_address->address1 . $obj_delivery_address->address2 . $obj_delivery_address->postcode . $obj_delivery_address->city . $obj_delivery_address->phone_mobile . GlobKurierTools::gkDecryptString($this->login) . GlobKurierTools::gkDecryptString($this->apikey)));
         $obj_json_insert_order = Tools::jsonDecode($obj_globkurier_insert_order->sendData());
         if ($obj_json_insert_order->status == true) {
             $obj_globkurier_order->flag = GlobKurierOrder::PS_ORDER_SYNC;
         }
     }
     $obj_globkurier_order->save();
 }
    /**
     * Given array to rest post
     * 
     * @param void
     * @return array:
     */
    protected function getXmlData()
    {
        $xml = '<?xml version = "1.0" encoding = "UTF-8" standalone = "no"?>
				<globkurier>
				<login>' . GlobKurierTools::gkDecryptString($this->getStrLogin()) . '</login>
				<password>' . GlobKurierTools::gkDecryptString($this->getStrPasswd()) . '</password>
				<apikey>' . GlobKurierTools::gkDecryptString($this->getStrApiKey()) . '</apikey>
				<order_method>' . self::PS_METHOD . '</order_method>
				<order_source>' . self::PS_SOURCE . '</order_source>
				<orders>
					<order>
						<id_cart>' . $this->getIntIdCart() . '</id_cart>
						<id_customer>' . $this->getIntIdCustomer() . '</id_customer>
						<shop_key>' . $this->getStrShopKey() . '</shop_key>
						<secure_key>' . $this->getStrSecureKey() . '</secure_key>
						<reference>' . $this->getStrReference() . '</reference>
						<order_number>' . $this->getStrOrderNumber() . '</order_number>
						<sent_date>' . $this->getStrPickupDate() . '</sent_date>
						<time_from>' . $this->getStrPickupTimeFrom() . '</time_from>
						<time_to>' . $this->getStrPickupTimeTo() . '</time_to>
						<base_service>' . $this->getStrBaseService() . '</base_service>
						<additional_services>';
        if (is_array($this->getArrAddons())) {
            foreach ($this->getArrAddons() as $a) {
                $xml .= '<additional_service>' . $a . '</additional_service>';
            }
        }
        $xml .= '</additional_services>
						<cod_amount>' . $this->getFloCodAmount() . '</cod_amount>
						<cod_account>' . $this->getStrCodAccount() . '</cod_account>
						<insurance_amount>' . $this->getFloInsuranceAmount() . '</insurance_amount>
						<declared_value>' . $this->getFloDeclaredValue() . '</declared_value>
						<payment_type>' . $this->getStrPaymentType() . '</payment_type>
						<content>' . $this->getStrContent() . '</content>
						<length>' . $this->getFloLength() . '</length>
						<width>' . $this->getFloWidth() . '</width>
						<height>' . $this->getFloHeight() . '</height>
						<weight>' . $this->getFloWeight() . '</weight>
						<number_of_parcels>' . $this->getIntParcels() . '</number_of_parcels>
						<comments>' . $this->getStrComments() . '</comments>
						<sender>
							<name>' . $this->getStrSenderName() . '</name>
							<street>' . $this->getStrSenderAddress1() . '</street>
							<house_number>' . $this->getStrSenderAddress2() . '</house_number>
							<apartment_number></apartment_number>
							<postal_code>' . $this->getStrSenderZipCode() . '</postal_code>
							<city>' . $this->getStrSenderCity() . '</city>
							<country>' . $this->getStrSenderCountry() . '</country>
							<contact_person>' . $this->getStrSenderName() . '</contact_person>
							<phone>' . $this->getStrSenderPhone() . '</phone>
							<email>' . $this->getStrSenderMail() . '</email>
						</sender>
						<receiver>
							<name>' . $this->getStrRecipientName() . '</name>
							<street>' . $this->getStrRecipientAddress1() . '</street>
							<house_number>' . $this->getStrRecipientAddress2() . '</house_number>
							<apartment_number></apartment_number>
							<postal_code>' . $this->getStrRecipientZipCode() . '</postal_code>
							<city>' . $this->getStrRecipientCity() . '</city>
							<country>' . $this->getStrRecipientCountry() . '</country>
							<contact_person>' . $this->getStrRecipientName() . '</contact_person>
							<phone>' . $this->getStrRecipientPhone() . '</phone>
							<email>' . $this->getStrRecipientMail() . '</email>
						</receiver>
					</order>
				</orders>
				<token>' . $this->getStrToken() . '</token>
			</globkurier>';
        return (string) $xml;
    }