'Request\Ping', 'PingResponse' => 'Response\PingResponse', 'PingRsp' => 'Response\PingRsp', 'Lookup' => 'Request\Lookup', 'LookupResponse' => 'Response\LookupResponse', 'LookupResult' => 'Response\Lookup', 'LookupRsp' => 'Response\LookupRsp', 'ArrayOfCartItemResponse' => 'Response\CartItemsResponse', 'CartItemResponse' => 'Response\CartItemResponse', 'ResponseMessage' => 'Response\Message', 'ArrayOfResponseMessage' => 'Response\Messages', 'Address' => 'Entity\Address', 'CartItem' => 'Entity\CartItem', 'AuthorizedWithCapture' => 'Request\AuthorizedWithCapture', 'AuthorizedWithCaptureResponse' => 'Response\AuthorizedWithCaptureResponse', 'AuthorizedRsp' => 'Response\AuthorizedRsp', 'Returned' => 'Request\Returned', 'ReturnedResponse' => 'Response\ReturnedResponse', 'ReturnedRsp' => 'Response\ReturnedRsp', ]; public function __construct($wsdl = null, $options = null) { $this->_initClassmap(); parent::__construct($wsdl, $options); } protected function _initClassmap() { foreach ($this->classmap as &$class) { if ('\\' != $class[0]) { $class = __NAMESPACE__ . '\\' . $class; } } } public function setOptions($options) { foreach (['apiLoginId', 'apiKey'] as $option) { if (array_key_exists($option, $options)) { $this->$option = $options[$option]; unset($options[$option]); } } return parent::setOptions($options); } protected function getAuthData() { return ['apiLoginId' => $this->apiLoginId, 'apiKey' => $this->apiKey]; } public function ping() { /** @var Response\PingResponse $response */ $response = $this->call('Ping', [new Request\Ping($this->getAuthData())]); $result = $response->getPingResult(); if (MessageType::OK == $result->getResponseType()) { return true; } throw new Exception(implode(PHP_EOL, $result->getMessages())); } public function lookup(array $request) { $request = new Request\Lookup(array_merge($this->getAuthData(), $request)); /** @var Response\LookupResponse $response */ $response = $this->call('Lookup', [$request]); $result = $response->getLookupResult(); if (MessageType::OK != $result->getResponseType()) { throw new Exception($result->getMessages()); } return $result; } public function authorizeWithCapture(array $request) { $request = new Request\AuthorizedWithCapture(array_merge($this->getAuthData(), $request)); /** @var Response\AuthorizedWithCaptureResponse $response */ $response = $this->call('AuthorizedWithCapture', [$request]); $result = $response->getAuthorizedWithCaptureResult(); if (MessageType::OK != $result->getResponseType()) { throw new Exception($result->getMessages()); } return $result; } public function returned(array $request) { $request = new Request\Returned(array_merge($this->getAuthData(), $request)); /** @var Response\ReturnedResponse $response */ $response = $this->call('Returned', [$request]); $result = $response->getReturnedResult(); if (MessageType::OK != $result->getResponseType()) { throw new Exception($result->getMessages()); } return $result; } public function dumpLastRequest() { header('Content-Type: xml'); echo $this->getLastRequest(); exit; } public function dumpLastResponse() { header('Content-Type: xml'); echo $this->getLastResponse(); exit; } }