Example #1
0
 public function generate_xend_waybill_no($ordernumber)
 {
     error_reporting(E_ALL);
     //require_once('lib/nusoap.php');
     // declare variables
     $exceptionFlag = false;
     // initialize SOAP clients
     $wsdl = 'https://www.xend.com.ph/api/ShipmentService.asmx?wsdl';
     $client = new SoapClient($wsdl, array());
     $funcs = $client->__getFunctions();
     // initialize SOAP header
     /*$headerbody = array('UserToken' => '92c14d24-bebb-49a8-a7b5-8a8358fb137e');*/
     //test waybill
     //http://www.xend.com.ph/GetWaybill.aspx?no=736345530
     $headerbody = array('UserToken' => '92c14d24-bebb-49a8-a7b5-8a8358fb137e');
     $header = new SoapHeader('https://www.xend.com.ph/api/', 'AuthHeader', $headerbody);
     $client->__setSoapHeaders($header);
     // prepare parameters
     // all orders
     $this->load->model('xend_model');
     //print_r($this->xend_model->get_orders_by_number($ordernumber));
     foreach ($this->xend_model->get_orders_by_number($ordernumber) as $order) {
         //			if($order->ship_zone=="Metro Manila"){
         //				$shipping_fee=79;
         //			} else {
         //				$shipping_fee=150;
         //			}
         $shipping_fee = $order->shipping;
         $param = array('ServiceTypeValue' => 'MetroManilaExpress', 'ShipmentTypeValue' => 'Parcel', 'Weight' => 0.5, 'DimensionL' => 0.0, 'DimensionW' => 0.0, 'DimensionH' => 0.0, 'DeclaredValue' => $order->total, 'RecipientName' => $order->ship_firstname . ' ' . $order->ship_lastname, 'RecipientCompanyName' => $order->ship_company, 'RecipientAddress1' => $order->ship_address1, 'RecipientAddress2' => $order->ship_address2, 'RecipientCity' => $order->ship_city, 'RecipientProvince' => $order->ship_zone, 'RecipientCountry' => $order->ship_country, 'IsInsured' => 0, 'SpecialInstructions' => 'Fragile', 'Description' => 'DESCRIPTION', 'ClientReference' => $order->order_number, 'PurposeOfExportValue' => 'None', 'DateCreated' => date('Y-m-d\\TH\\:i\\:s\\.u', time()), 'DatePrinted' => date('Y-m-d\\TH\\:i\\:s\\.u', time()), 'ShippingFee' => $shipping_fee, 'InsuranceFee' => 0);
     }
     // execute SOAP method
     try {
         $result = $client->Create(array('shipment' => $param));
         //$result = $client->__soapCall("Create", array("shipment" => $param));
     } catch (SoapFault $soapfault) {
         $exceptionFlag = true;
         $exception = $soapfault->getMessage();
         preg_match_all('/: (.*?). at/s', $exception, $error, PREG_SET_ORDER);
         echo "<b> Error : </b> " . $error[0][1];
         //echo $soapfault->faultcode;
     }
     if (!$exceptionFlag) {
         return $result->CreateResult;
     }
 }
Example #2
0
 /**
  * Creates a new shipment and returns the waybill number
  *
  * return array
  */
 public function getResponse()
 {
     // initialize SOAP client
     $client = new SoapClient($this->_url, array());
     $funcs = $client->__getFunctions();
     // initialize SOAP header
     $headerbody = array(self::USER_TOKEN => $this->_userToken);
     $header = new SoapHeader($this->_header, self::AUTH_HEADER, $headerbody);
     $client->__setSoapHeaders($header);
     // prepare parameters
     $query = array(self::SERVICE_TYPE => $this->_serviceType, self::SHIPMENT_TYPE => $this->_shipmentType, self::PURPOSE => $this->_purpose, self::WEIGHT => $this->_weight, self::LENGTH => $this->_length, self::WIDTH => $this->_width, self::HEIGHT => $this->_height, self::VALUE => $this->_declaredValue, self::NAME => $this->_name, self::COMPANY => $this->_company, self::ADDRESS1 => $this->_address1, self::ADDRESS2 => $this->_address2, self::CITY => $this->_city, self::PROVINCE => $this->_provice, self::COUNTRY => $this->_country, self::INSURED => TRUE, self::INSTRUCTION => $this->_specialInstruction, self::DESCRIPTION => $this->_description, self::CLIENT => '', self::MANUFACTURED => '', self::POSTAL_CODE => $this->_postalCode, self::PHONE_NUMBER => $this->_phoneNumber, self::EMAIL => $this->_email, self::DATE_CREATED => time(), self::DATE_PRINTED => time(), self::SHIPPING_FEE => $this->_fee, self::INSURANCE_FEE => '1');
     // execute SOAP method
     try {
         //create a Shipment method
         $result = $client->Create(array(self::SHIPMENT => $query));
     } catch (SoapFault $soapfault) {
         $this->_exceptionFlag = true;
         $exception = $soapfault->getMessage();
         preg_match_all('/: (.*?). at/s', $exception, $error, PREG_SET_ORDER);
         //Print error
         return $error[0][1];
     }
     //fetch way bill number
     $this->_wayBill = $result->CreateResult;
     return $this->getDetail();
 }