/**
  * query all warehouse addresses
  * @params $resultFormat string objectList or arrayList
  * @return array
  */
 public static function queryAll($resultFormat = 'objectList')
 {
     $curl = PilipayCurl::instance();
     $result = $curl->get(PilipayConfig::getWarehouseAddressListUrl());
     if (empty($result)) {
         return array();
     }
     $json = json_decode($result, true);
     if (empty($json)) {
         return false;
     }
     if ($resultFormat !== 'objectList') {
         return $json;
     }
     $addressList = array();
     foreach ($json as $item) {
         $addressList[] = new PilipayWarehouseAddress($item);
     }
     return $addressList;
 }
示例#2
0
 /**
  * query all available currencies from pilibaba
  * @param string $resultFormat objectList | stringList
  * @return array
  */
 public static function queryAll($resultFormat = 'objectList')
 {
     $curl = PilipayCurl::instance();
     $result = $curl->get(PilipayConfig::getWarehouseAddressListUrl());
     if (empty($result)) {
         return array();
     }
     $json = json_decode($result, true);
     if (empty($json)) {
         return array();
     }
     if ($resultFormat !== 'objectList') {
         return $json;
     }
     $currencies = array();
     foreach ($json as $currencyCode) {
         $currencies[] = new PilipayCurrency(array('code' => $currencyCode));
     }
     return $currencies;
 }
示例#3
0
 /**
  * Update track number (logistics number)
  * @param $logisticsNo
  * @throws PilipayError
  */
 public function updateTrackNo($logisticsNo)
 {
     $params = array('orderNo' => $this->orderNo, 'merchantNo' => $this->merchantNO, 'logisticsNo' => $logisticsNo);
     PilipayLogger::instance()->log('info', "Update track NO: " . json_encode($params));
     $curl = new PilipayCurl();
     $response = $curl->post(PilipayConfig::getUpdateTrackNoUrl(), $params);
     PilipayLogger::instance()->log('info', 'Update track NO result: ' . print_r(array('request' => $params, 'response' => array('statusCode' => $curl->getResponseStatusCode(), 'statusText' => $curl->getResponseStatusText(), 'content' => $curl->getResponseContent())), true));
     if (!$response) {
         throw new PilipayError(PilipayError::EMPTY_RESPONSE, 'Updating tacking number');
     }
     if (strcasecmp(trim($response), 'success') !== 0) {
         throw new PilipayError(PilipayError::UPDATE_FAILED, 'Update tracking number failed: ' . $response);
     }
 }
 /**
  * Update track number (logistics number)
  *
  * @param $logisticsNo
  */
 public function updateTrackNo($logisticsNo)
 {
     $params = array('orderNo' => pSQL($this->orderNo), 'merchantNo' => pSQL($this->merchantNo), 'logisticsNo' => pSQL($logisticsNo), 'signMsg' => md5($this->orderNo . $logisticsNo . $this->merchantNo . $this->appSecret));
     PilipayLogger::instance()->log('info', "Update track NO: " . Tools::jsonEncode($params));
     $curl = new PilipayCurl();
     $curl->get(PilipayConfig::getUpdateTrackNoUrl(), $params);
     PilipayLogger::instance()->log('info', 'Update track NO result: ' . print_r(array('request' => $params, 'response' => array('statusCode' => $curl->getResponseStatusCode(), 'statusText' => $curl->getResponseStatusText(), 'content' => $curl->getResponseContent())), true));
 }