A QCodo powered CMS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

598 lines
22 KiB

  1. <?php
  2. if(!defined('QUINTACMS') ) die('No Quinta.');
  3. if (!defined("ENDICIAREQUESTBASE.CLASS.PHP")){
  4. define("ENDICIAREQUESTBASE.CLASS.PHP",1);
  5. /**
  6. * Class EndiciaRequest - class for performing shipping requests via Endicia API web services
  7. *
  8. * This class provides an interface to shipping requests. Abstract methods MUST be implemented by
  9. * subclasses, others may be overridden as needed. Subclasses are instantiated by a call to
  10. * ShippingMethod::GetRequest($strRequestType). The primary function of this base class is to associate
  11. * the request with the ShippingMethod
  12. *
  13. * This class also connects to the specified server via the methods provided by extending WebServiceRequest.
  14. *
  15. *@todo
  16. * - implement the other Get methods, only label requests are finished!
  17. * -
  18. *
  19. *@author Erik Winn <sidewalksoftware@gmail.com>
  20. *
  21. *@version 0.3
  22. *
  23. *@package Quinta
  24. * @subpackage Classes
  25. */
  26. class EndiciaRequest extends ShippingRequest {
  27. /**
  28. * Assigned by Endicia - identifies the system making the request.
  29. *However, any string (strlen > 0 && < 50) will do as it is not checked
  30. *@var string strRequesterId
  31. */
  32. protected $strRequesterId;
  33. /**
  34. *@var string strRequestId
  35. */
  36. protected $strRequestId;
  37. /**
  38. * Endicia prefers the weight in ounces .. (0000.0)
  39. *@var float fltTotalWeightOz
  40. */
  41. protected $fltTotalWeightOz;
  42. /**
  43. * Type of label to return [Default, CertifiedMail, DestinationConfirm, International]
  44. * "Default" creates based on mail class. Note: if you want PDF images returned you
  45. * must set this to International for international labels.
  46. *@var string strLabelType
  47. */
  48. protected $strLabelType = 'Default';
  49. /**
  50. * The format for the returned image - this is the default for international using
  51. * LabelType "Default" is GIF so this is the best default for us.
  52. * [EPL2, GIF, JPEG, PDF, PNG, ZPLII ]
  53. *@var string strImageFormat
  54. */
  55. protected $strImageFormat = 'GIF';
  56. /**
  57. * [4X6 | 4X5 | 4X4.5 | 6X4 | 7X3 | Dmo30384 | EnvelopeSize10 | Mailer7X5 ]
  58. * The size for the returned image (inches)
  59. *@var string strLabelSize
  60. */
  61. protected $strLabelSize = '4X6';
  62. /**
  63. * Rotation for the returned image [None, Rotate90, Rotate180, Rotate270]
  64. *@var string strImageRotation
  65. */
  66. protected $strImageRotation = 'Rotate180';
  67. /**
  68. * Resolution for the returned image [150 | 203 | 300]
  69. *@var string strImageResolution
  70. */
  71. protected $strImageResolution = '203';
  72. /**
  73. * Endicia uses its own version of the USPS Service Types ..
  74. * For Domestic:
  75. * [Express, First, LibraryMail, MediaMail,ParcelPost, Priority]
  76. * For International:
  77. * [ExpressMailInternational, FirstClassMailInternational, PriorityMailInternational]
  78. *@var string strMailClass
  79. */
  80. protected $strMailClass;
  81. /**
  82. * Specifies nondelivery options for international labels and customs forms
  83. *@var string strNonDeliveryOption
  84. */
  85. protected $strNonDeliveryOption;
  86. /**
  87. * Unique identifier for the end user printing the label
  88. *@var string strPartnerCustomerId
  89. */
  90. protected $strPartnerCustomerId;
  91. /**
  92. * Unique identifier for the transaction (eg. invoice or order id)
  93. *@var string strPartnerTransactionId
  94. */
  95. protected $strPartnerTransactionId;
  96. /**
  97. * Name of the sender, required for international shipping and must contain
  98. * at least two words. This defaults to STORE_OWNER
  99. *@var string strFromName
  100. */
  101. protected $strFromName;
  102. /**
  103. * Name of the sender company
  104. * at least two words. This defaults to STORE_NAME
  105. *@var string strFromCompany
  106. */
  107. protected $strFromCompany;
  108. /**
  109. * Name of the sender city
  110. * at least two words. This defaults to STORE_CITY
  111. *@var string strFromCity
  112. */
  113. protected $strFromCity;
  114. /**
  115. * Line one of return address ..
  116. *@var string strReturnAddress1
  117. */
  118. protected $strReturnAddress1;
  119. /**
  120. * Line two of return address ..
  121. *@var string strReturnAddress2
  122. */
  123. protected $strReturnAddress2;
  124. /**
  125. * The total value of the shipment
  126. *@var float fltTotalValue
  127. */
  128. protected $fltTotalValue;
  129. /**
  130. * EndiciaRequest Constructor - sets defaults for this request method ..
  131. *
  132. * @param ShippingMethod objShippingMethod - the method to be used for the request
  133. */
  134. public function __construct(ShippingMethod $objShippingMethod){
  135. parent::__construct($objShippingMethod);
  136. if($objShippingMethod->TestMode){
  137. $this->strRemoteAccountId = ENDICIA_TESTACCOUNT_ID;
  138. $this->strRemotePassword = ENDICIA_TESTPASSWORD;
  139. $this->strRequestId = ENDICIA_TESTREQUEST_ID;
  140. $this->strRequesterId = ENDICIA_TESTREQUESTER_ID;
  141. $this->strRemoteDomainName = ENDICIA_TESTDOMAIN;
  142. } else {
  143. $this->strRemoteAccountId = ENDICIA_ACCOUNT_ID;
  144. $this->strRemotePassword = ENDICIA_PASSWORD;
  145. $this->strRequestId = ENDICIA_REQUEST_ID;
  146. $this->strRequesterId = ENDICIA_REQUESTER_ID;
  147. $this->strRemoteDomainName = ENDICIA_DOMAIN;
  148. }
  149. $this->strRemoteCgiUrl = '/LabelService/EwsLabelService.asmx/';
  150. //combine weight as endicia accepts only ounces
  151. $this->fltTotalWeightOz = round( ($objShippingMethod->Ounces + ($objShippingMethod->Pounds * 16)), 2);
  152. //and the minimum is one.
  153. if($this->fltTotalWeightOz < 1)
  154. $this->fltTotalWeightOz = 1;
  155. $this->fltTotalValue = $objShippingMethod->Order->ProductTotalCharged;
  156. $this->strPartnerTransactionId = 'BPCB' . $objShippingMethod->Order->Id;
  157. $this->strPartnerCustomerId = STORE_NAME;
  158. $this->strFromCompany = STORE_NAME;
  159. $this->strReturnAddress1 = STORE_ADDRESS1;
  160. $this->strReturnAddress2 = STORE_ADDRESS2;
  161. $this->strFromCity = STORE_CITY;
  162. $this->strFromName = STORE_OWNER;
  163. $aryFromName = explode( ' ', $this->strFromName );
  164. if(count( $aryFromName ) < 2 )
  165. throw new Exception('EndiciaRequest: FromName (STORE_OWNER) must have at least 2 words!');
  166. if($this->objShippingMethod->Order->IsInternational){
  167. $this->strLabelType = 'International';
  168. // $this->strImageFormat = 'GIF';
  169. }
  170. //translate USPS service types - ugly as these change .. careful.
  171. ///@todo - fill out the rest here .. library, parcel, etc .. no time ..
  172. if( 'FIRST CLASS' == $objShippingMethod->ServiceType )
  173. $this->strMailClass = 'First';
  174. elseif( 'PRIORITY' == $objShippingMethod->ServiceType )
  175. $this->strMailClass = 'Priority';
  176. elseif( 'EXPRESS' == $objShippingMethod->ServiceType )
  177. $this->strMailClass = 'Express';
  178. elseif( 'Express Mail International' == $objShippingMethod->ServiceType )
  179. $this->strMailClass = 'ExpressMailInternational';
  180. elseif( 'First Class Mail International' == $objShippingMethod->ServiceType )
  181. $this->strMailClass = 'FirstClassMailInternational';
  182. elseif( 'Priority Mail International' == $objShippingMethod->ServiceType )
  183. $this->strMailClass = 'PriorityMailInternational';
  184. else // assume we are using the Endicia ShippingMethod natively
  185. $this->strMailClass = $objShippingMethod->ServiceType;
  186. }
  187. /**
  188. * Returns a shipping label image suitable for printing
  189. *@return image object containing the image code
  190. */
  191. public function GetLabel(){
  192. $this->createRequest(ShippingRequestType::Label, WebRequestType::POST);
  193. $this->submitRequest();
  194. return $this->objShippingLabelImage;
  195. }
  196. /**
  197. * Creates a label image request
  198. */
  199. protected function createLabelRequest(){
  200. $this->strApiName = 'GetPostageLabelXML';
  201. if('Express Mail International' == $this->ServiceType
  202. || 'Priority Mail International' == $this->ServiceType )
  203. $this->strImageRotation ='Rotate90';
  204. $strXML = 'labelRequestXML=';
  205. $strXML .= sprintf('<LabelRequest Test="%s" LabelType="%s" LabelSize="%s" LabelFormat="%s" ImageRotation="%s" ImageResolution="%s">',
  206. $this->Test,
  207. $this->strLabelType,
  208. $this->strLabelSize,
  209. $this->strImageFormat,
  210. $this->strImageRotation,
  211. $this->strImageResolution
  212. );
  213. $strXML .= '<RequesterID>' . $this->strRequesterId . '</RequesterID>';
  214. $strXML .= '<AccountID>' . $this->RemoteAccountId . '</AccountID>';
  215. $strXML .= '<PassPhrase>' . $this->RemotePassword . '</PassPhrase>';
  216. $strXML .= '<MailClass>' . $this->strMailClass . '</MailClass>';
  217. $strXML .= '<WeightOz>' . $this->fltTotalWeightOz. '</WeightOz>';
  218. if($this->fltTotalValue)
  219. $strXML .= '<Value>' . $this->fltTotalValue . '</Value>';
  220. $strXML .= '<OriginCountry>' . $this->OriginCountry . '</OriginCountry>';
  221. ///@todo -- make this smarter ..
  222. $strXML .= '<Description>Consumer Goods</Description>';
  223. $strXML .= '<PartnerCustomerID>' . $this->strPartnerCustomerId . '</PartnerCustomerID>';
  224. $strXML .= '<PartnerTransactionID>' . $this->strPartnerTransactionId . '</PartnerTransactionID>';
  225. $strXML .= $this->formatAddress($this->objShippingMethod->Order);
  226. $strXML .= '<FromCompany>' . $this->strFromCompany . '</FromCompany>';
  227. $strXML .= '<FromName>' . $this->strFromName . '</FromName>';
  228. $strXML .= '<ReturnAddress1>' . $this->strReturnAddress1 . '</ReturnAddress1>';
  229. $strXML .= '<ReturnAddress2>' . $this->strReturnAddress2 . '</ReturnAddress2>';
  230. $strXML .= '<FromCity>' . $this->strFromCity . '</FromCity>';
  231. $strXML .= '<FromState>' . $this->OriginStateCode . '</FromState>';
  232. $strXML .= '<FromPostalCode>' . substr($this->OriginZip, 0, 5) . '</FromPostalCode>';
  233. $strPhone = preg_replace( '/[\- ]/', '', STORE_PHONE );
  234. $strXML .= '<FromPhone>' . $strPhone . '</FromPhone>';
  235. if($this->objShippingMethod->Order->IsInternational){
  236. $strXML .= '<FromCountry>' . $this->OriginCountry . '</FromCountry>';
  237. $this->initCustomsInformationArray();
  238. foreach($this->aryCustomsInformation as $intIndex => $objInfo){
  239. $intIdx = $intIndex + 1;
  240. $strXML .= '<CustomsDescription' . $intIdx . '>' . $objInfo->Description. '</CustomsDescription' . $intIdx . '>';
  241. $strXML .= '<CustomsQuantity' . $intIdx . '>' . $objInfo->Quantity . '</CustomsQuantity' . $intIdx . '>';
  242. $strXML .= '<CustomsWeight' . $intIdx . '>' . ceil($objInfo->Weight) . '</CustomsWeight' . $intIdx . '>';
  243. $strXML .= '<CustomsValue' . $intIdx . '>' . $objInfo->Value . '</CustomsValue' . $intIdx . '>';
  244. $strXML .= '<CustomsCountry' . $intIdx . '>' . $objInfo->OriginCountry . '</CustomsCountry' . $intIdx . '>';
  245. }
  246. }
  247. $strXML .= '</LabelRequest>';
  248. $this->strRequest = $strXML;
  249. }
  250. /**
  251. * Creates an account status request
  252. */
  253. protected function createAccountStatusRequest(){
  254. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  255. ShippingRequestType::ToString($this->ShippingRequestType)) );
  256. $this->strApiName = 'GetAccountStatusXML';
  257. $strXML = 'accountStatusRequestXML=';
  258. $strXML .= '<AccountStatusRequest Test="' . $this->Test . '">';
  259. $strXML .= '<RequesterID>' . $this->RequesterId . '</RequesterID>';
  260. $strXML .= '<RequestID>' . $this->RequestId . '</RequestID>';
  261. $strXML .= '<CertifiedIntermediary>';
  262. $strXML .= '<AccountID>' . $this->RemoteAccountId. '</AccountID>';
  263. $strXML .= '<PassPhrase>' . $this->RemotePassword . '</PassPhrase>';
  264. $strXML .= '</CertifiedIntermediary>';
  265. $strXML .= '</AccountStatusRequest>';
  266. $this->strRequest = $strXML;
  267. }
  268. /**
  269. * Creates a request submitting an account credit payment
  270. */
  271. protected function createCreditAccountRequest($fltAmount){
  272. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s UNTESTED DO NOT USE! ',
  273. ShippingRequestType::ToString($this->ShippingRequestType)) );
  274. $this->strApiName = 'BuyPostageXML';
  275. if( ! is_numeric($fltAmount) || $fltAmount < 10 || $fltAmount >= 100000)
  276. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s - Param: %s ' .
  277. 'Postage amount must be a number between 10 and 99999.99.',
  278. ShippingRequestType::ToString($this->ShippingRequestType),
  279. $fltAmount ));
  280. $strXML = 'recreditRequestXML=';
  281. $strXML .= '<RecreditRequest Test="' . $this->Test . '">';
  282. $strXML .= '<RequesterID>' . $this->RequesterId . '</RequesterID>';
  283. $strXML .= '<RequestID>' . $this->RequestId . '</RequestID>';
  284. $strXML .= '<CertifiedIntermediary>';
  285. $strXML .= '<AccountID>' . $this->RemoteAccountId . '</AccountID>';
  286. $strXML .= '<PassPhrase>' . $this->RemotePassword . '</PassPhrase>';
  287. $strXML .= '</CertifiedIntermediary>';
  288. $strXML .= '<RecreditAmount>' . round($fltAmount, 2) . '</RecreditAmount>';
  289. $strXML .= '</RecreditRequest>';
  290. $this->strRequest = $strXML;
  291. }
  292. //Response handlers
  293. /**
  294. * Handles a rate request
  295. */
  296. protected function handleRateResponse(){
  297. $objDomDoc = $this->getDomDocument('RateRequestResponse');
  298. if($objDomDoc){
  299. $strErrorMessage = $this->requestErrors($objDomDoc);
  300. if($strErrorMessage){
  301. $this->blnHasErrors = true;
  302. $this->strErrors = $strErrorMessage;
  303. $this->fltRate = null;
  304. }else{
  305. $this->fltRate = $objDomDoc->getElementsByTagName('NetCharge')->item(0)->nodeValue;
  306. }
  307. } else {
  308. // die($this->strResponse);
  309. $this->HasErrors = true;
  310. $this->ErrorMessages = 'Unknown Endicia error ..';
  311. $this->fltRate = 0;
  312. }
  313. }
  314. /**
  315. * Handles a label image request response
  316. * This function handles the entire label request which includes extracting the tracking number
  317. * and other information from the response XML.
  318. */
  319. protected function handleLabelResponse(){
  320. $objDomDoc = $this->getDomDocument('LabelRequestResponse');
  321. if($objDomDoc){
  322. $strErrorMessage = $this->requestErrors($objDomDoc);
  323. if($strErrorMessage){
  324. $this->blnHasErrors = true;
  325. $this->strErrors = $strErrorMessage;
  326. $this->objShippingLabelImage = null;
  327. } else {
  328. $objImageNodeList = $objDomDoc->getElementsByTagName('Base64LabelImage');
  329. //if nothing, try the other tag - International is usually in there ..
  330. if($objImageNodeList->length <= 0)
  331. $objImageNodeList = $objDomDoc->getElementsByTagName('Image');
  332. //still nothing? ruh roh ..
  333. if($objImageNodeList->length <= 0)
  334. throw new Exception('EndiciaRequest: No label image returned for Order ' . $this->Order->Id);
  335. $this->objShippingLabelImage = base64_decode( $objImageNodeList->item(0)->nodeValue );
  336. if(!$this->objShippingLabelImage)
  337. throw new Exception('EndiciaRequest: Empty image!');
  338. if($this->Order->IsInternational){//get customs forms if available ..
  339. if($objImageNodeList->length > 1)
  340. for($intIdx = 1; $intIdx < $objImageNodeList->length; ++$intIdx)
  341. $this->aryCustomsFormImages[] = base64_decode($objImageNodeList->item($intIdx)->nodeValue);
  342. }
  343. //try to save the tracking number ..
  344. $objTrackingNumberNodeList = $objDomDoc->getElementsByTagName('TrackingNumber');
  345. if($objTrackingNumberNodeList->length > 0){
  346. $strTrackingNumber = $objTrackingNumberNodeList->item(0)->nodeValue;
  347. if(!empty($strTrackingNumber)){
  348. if(! TrackingNumber::LoadByOrderIdNumber($this->objShippingMethod->OrderId, $strTrackingNumber )){
  349. $objTrackingNumber = new TrackingNumber();
  350. $objTrackingNumber->OrderId = $this->objShippingMethod->OrderId;
  351. $objTrackingNumber->Number = $strTrackingNumber;
  352. $objTrackingNumber->Save();
  353. }
  354. }
  355. }
  356. $objFinalPriceNodeList = $objDomDoc->getElementsByTagName('FinalPostage');
  357. if($objFinalPriceNodeList->length > 0){
  358. $strFinalPrice = $objFinalPriceNodeList->item(0)->nodeValue;
  359. if(!empty($strFinalPrice)){
  360. $this->objShippingMethod->Order->ShippingCost = $strFinalPrice;
  361. $this->objShippingMethod->Order->Save(false,true);
  362. }
  363. }
  364. }
  365. }else {
  366. // die($this->strResponse);
  367. $this->blnHasErrors = true;
  368. $this->strErrors = 'Unknown Endicia error ..Request:' . $this->strRequest . ' Response:' . $this->strResponse;
  369. $this->objShippingLabelImage = 0;
  370. }
  371. }
  372. /**
  373. * Utility function to format the address for a label or rate request, creates a
  374. * string containing the XML tags for the address
  375. *@return string
  376. */
  377. private function formatAddress($objOrder){
  378. $strToReturn = '';
  379. $intAddressLine = 1;
  380. $strToReturn .= '<ToName>' . $objOrder->FullShippingName . '</ToName>';
  381. if($objOrder->ShippingCompany)
  382. $strToReturn .= '<ToCompany>' . $objOrder->ShippingCompany . '</ToCompany>';
  383. //Endicia allows 4 Address lines so we have to be clever here ..
  384. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingStreet1 . '</ToAddress' . $intAddressLine . '>';
  385. ++$intAddressLine;
  386. if($objOrder->ShippingStreet2){//line 2
  387. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingStreet2 . '</ToAddress' . $intAddressLine . '>';
  388. ++$intAddressLine;
  389. }
  390. if($objOrder->ShippingSuburb){//line 2 or 3 ..
  391. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingSuburb . '</ToAddress' . $intAddressLine . '>';
  392. ++$intAddressLine;
  393. }
  394. //line 2, 3 or 4 ..
  395. if($objOrder->ShippingCounty){//line
  396. $strToReturn .= '<ToAddress' . $intAddressLine . '>' . $objOrder->ShippingCounty . '</ToAddress' . $intAddressLine . '>';
  397. ++$intAddressLine;
  398. }
  399. $strToReturn .= '<ToCity>' . $objOrder->ShippingCity . '</ToCity>';
  400. if( ZoneType::NoZone != $this->objShippingMethod->DestinationStateId )
  401. $strToReturn .= '<ToState>' . $this->objShippingMethod->DestinationStateCode . '</ToState>';
  402. //truncate zip else endicia complains ..
  403. $strToReturn .= '<ToPostalCode>' . substr( trim($this->objShippingMethod->DestinationZip), 0, 5) . '</ToPostalCode>';
  404. $strToReturn .= '<ToCountry>' . $this->objShippingMethod->DestinationCountry . '</ToCountry>';
  405. $strPhoneNumber = trim($objOrder->Account->Person->PhoneNumber);
  406. if( !empty($strPhoneNumber) && 'N/A' != $strPhoneNumber)
  407. $strPhoneNumber = preg_replace('/[^\d]/', '', $strPhoneNumber);
  408. else
  409. $strPhoneNumber = '8885551212';
  410. $strToReturn .= '<ToPhone>' . $strPhoneNumber . '</ToPhone>';
  411. return $strToReturn;
  412. }
  413. /**
  414. * Utility function to check for request errors - returns either a string containing
  415. * server error messages or false if there were none.
  416. *@param DOMDocument objDomDoc - the server response ..
  417. *@return string | boolean error messages or false if request succeeded.
  418. */
  419. private function requestErrors($objDomDoc){
  420. $mixToReturn = false;
  421. $nodeListStatus = $objDomDoc->getElementsByTagName('Status');
  422. //Status is zero on success ..
  423. if($nodeListStatus->item(0)->nodeValue > 0){
  424. $nodeListErrors = $objDomDoc->getElementsByTagName('ErrorMessage');
  425. $this->blnHasErrors = true;
  426. $mixToReturn = 'Request: ' . $this->strRequest;
  427. if( $nodeListErrors->length)
  428. $mixToReturn .= ' Message: ' . $nodeListErrors->item(0)->nodeValue;
  429. else
  430. $mixToReturn .= ' ... Endicia had no comment. ';
  431. }
  432. return $mixToReturn;
  433. }
  434. ///Gettors
  435. public function __get($strName){
  436. switch ($strName){
  437. case 'Test':
  438. return $this->TestMode ? 'YES' : 'NO';
  439. case 'Carrier':
  440. return $this->objShippingMethod->Carrier ;
  441. default:
  442. try {
  443. return parent::__get($strName);
  444. } catch (QCallerException $objExc) {
  445. $objExc->IncrementOffset();
  446. throw $objExc;
  447. }
  448. }
  449. }
  450. ///Settors
  451. public function __set($strName, $mixValue){
  452. switch ($strName){
  453. case 'FromName':
  454. try {
  455. return ($this->strFromDate = QType::Cast($mixValue, QType::String));
  456. } catch (QInvalidCastException $objExc) {
  457. $objExc->IncrementOffset();
  458. throw $objExc;
  459. }
  460. case 'Container':
  461. return ($this->objShippingMethod->Container = $mixValue);
  462. default:
  463. try {
  464. return (parent::__set($strName, $mixValue));
  465. } catch (QCallerException $objExc) {
  466. $objExc->IncrementOffset();
  467. throw $objExc;
  468. }
  469. }
  470. }
  471. /*************************************************************************************/
  472. ///@todo - implement the other Get methods ..:
  473. /**
  474. * Returns a rate for this method to the order address
  475. *@return float containing the rate for the order address
  476. */
  477. public function GetRate()
  478. {
  479. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  480. ShippingRequestType::ToString($this->ShippingRequestType)) );
  481. }
  482. /**
  483. * Returns an account status report
  484. *@return string containing the status report
  485. */
  486. public function GetAccountStatus()
  487. {
  488. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  489. ShippingRequestType::ToString($this->ShippingRequestType)) );
  490. }
  491. /**
  492. * Returns whether this method is available for the order address
  493. *@return boolean true if method is available
  494. */
  495. public function GetAvailability()
  496. {
  497. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  498. ShippingRequestType::ToString($this->ShippingRequestType)) );
  499. }
  500. /**
  501. * Submits an account credit payment
  502. *@return boolean true on success
  503. */
  504. public function CreditAccount()
  505. {
  506. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  507. ShippingRequestType::ToString($this->ShippingRequestType)) );
  508. }
  509. //Request string creators
  510. /**
  511. * Creates a rate request
  512. */
  513. protected function createRateRequest()
  514. {
  515. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  516. ShippingRequestType::ToString($this->ShippingRequestType)) );
  517. }
  518. /**
  519. * Creates a method available request
  520. */
  521. protected function createAvailabilityRequest()
  522. {
  523. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  524. ShippingRequestType::ToString($this->ShippingRequestType)) );
  525. }
  526. /**
  527. * Handles an account status request
  528. */
  529. protected function handleAccountStatusResponse()
  530. {
  531. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  532. ShippingRequestType::ToString($this->ShippingRequestType)) );
  533. }
  534. /**
  535. * Handles a request submitting an account credit payment
  536. */
  537. protected function handleCreditAccountResponse()
  538. {
  539. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  540. ShippingRequestType::ToString($this->ShippingRequestType)) );
  541. }
  542. /**
  543. * Handles a method available request
  544. */
  545. protected function handleAvailabilityResponse()
  546. {
  547. throw new QCallerException(sprintf('EndiciaRequest: Shipping request type %s unsupported! ',
  548. ShippingRequestType::ToString($this->ShippingRequestType)) );
  549. }
  550. /*************************************************************************************/
  551. }//end class
  552. }//end define
  553. ?>