Пример #1
0
 public function __invoke(Request $request, Response $response, callable $next)
 {
     $xml = file_get_contents('php://input');
     $xml = preg_replace('/[\\n\\r]/', '', $xml);
     $xml = preg_replace('/>\\s+/', '>', $xml);
     $rootBodyClass = 'DTS\\eBaySDK\\Trading\\Types\\AbstractResponseType';
     $parserBody = new XmlParser($rootBodyClass);
     $body = mb_strstr($xml, "<soapenv:Body>", false);
     $body = trim($body, "<soapenv:Body>");
     $body = mb_strstr($body, "</soapenv:Body>", true);
     $body = '<' . $body;
     /** @var AbstractResponseType $notification */
     $notification = $parserBody->parse($body);
     $notification->NotificationSignature = mb_strstr($xml, '<ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">', false);
     $notification->NotificationSignature = trim($notification->NotificationSignature, '<ebl:NotificationSignature xmlns:ebl="urn:ebay:apis:eBLBaseComponents">');
     $notification->NotificationSignature = mb_strstr($notification->NotificationSignature, "</ebl:NotificationSignature>", true);
     $timestamp = mb_strstr($body, "<Timestamp>", false);
     $timestamp = trim($timestamp, "<Timestamp>");
     $timestamp = mb_strstr($timestamp, "</Timestamp>", true);
     if ($this->calculationSignature($timestamp) !== $notification->NotificationSignature) {
         throw new \Exception("Not Equalse signature", 403);
     }
     $item = ['add_date' => $notification->Timestamp->format("Y-m-d h:i:s"), 'soapaction' => $notification->NotificationEventName, 'data' => $body];
     $this->store->create($item);
     return $response->withStatus(200);
 }
Пример #2
0
 /**
  * Sends an API request.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string The name of the PHP class that will be created from the XML response.
  *
  * @return mixed A response object created from the XML respose.
  */
 protected function callOperation($name, \DTS\eBaySDK\Types\BaseType $request, $responseClass)
 {
     $debug = $this->config('debug');
     $url = $this->getUrl();
     $body = $this->buildRequestBody($request);
     $headers = $this->getEbayHeaders($name);
     if ($request->hasAttachment()) {
         $headers['Content-Type'] = 'multipart/related;boundary=MIME_boundary;type="application/xop+xml";start="<*****@*****.**>";start-info="text/xml"';
     } else {
         $headers['Content-Type'] = 'text/xml';
     }
     $headers['Content-Length'] = strlen($body);
     if ($debug) {
         $this->logRequest($url, $name, $headers, $body);
     }
     list($xmlResponse, $attachment) = $this->extractXml($this->httpClient->post($url, $headers, $body));
     if ($debug) {
         $this->logResponse($xmlResponse);
     }
     $xmlParser = new XmlParser($responseClass);
     $response = $xmlParser->parse($xmlResponse);
     $response->attachment($attachment);
     return $response;
 }
Пример #3
0
 /**
  * Sends an API request.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string The name of the PHP class that will be created from the XML response.
  *
  * @return mixed A response object created from the XML respose.
  */
 protected function callOperation($name, \DTS\eBaySDK\Types\BaseType $request, $responseClass)
 {
     $debug = $this->config('debug');
     $url = $this->getUrl();
     $body = $request->toRequestXml();
     $headers = $this->getEbayHeaders($name);
     $headers['Content-Type'] = 'text/xml';
     $headers['Content-Length'] = strlen($body);
     if ($debug) {
         $this->logRequest($url, $name, $headers, $body);
     }
     $response = $this->httpClient->post($url, $headers, $body);
     if ($debug) {
         $this->logResponse($response);
     }
     $xmlParser = new XmlParser($responseClass);
     return $xmlParser->parse($response);
 }
Пример #4
0
 /**
  * Sends an API request.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string The name of the PHP class that will be created from the XML response.
  *
  * @return mixed A response object created from the XML respose.
  */
 protected function callOperation($name, \DTS\eBaySDK\Types\BaseType $request, $responseClass)
 {
     $url = $this->getUrl();
     $body = $this->buildRequestBody($request);
     $headers = $this->buildRequestHeaders($name, $request, $body);
     $debug = $this->getConfig('debug');
     if ($debug !== false) {
         $this->debugRequest($url, $name, $headers, $body);
     }
     list($xmlResponse, $attachment) = $this->extractXml($this->sendRequest('POST', $url, $headers, $body));
     if ($debug !== false) {
         $this->debugResponse($xmlResponse);
     }
     $xmlParser = new XmlParser($responseClass);
     $response = $xmlParser->parse($xmlResponse);
     $response->attachment($attachment);
     return $response;
 }
Пример #5
0
 /**
  * Sends an asynchronous API request.
  *
  * @param string $name The name of the operation.
  * @param \DTS\eBaySDK\Types\BaseType $request Request object containing the request information.
  * @param string The name of the PHP class that will be created from the XML response.
  *
  * @return \GuzzleHttp\Promise\PromiseInterface A promise that will be resolved with an object created from the XML response.
  */
 protected function callOperationAsync($name, \DTS\eBaySDK\Types\BaseType $request, $responseClass)
 {
     $url = $this->getUrl();
     $body = $this->buildRequestBody($request);
     $headers = $this->buildRequestHeaders($name, $request, $body);
     $debug = $this->getConfig('debug');
     $httpHandler = $this->getConfig('httpHandler');
     $httpOptions = $this->getConfig('httpOptions');
     if ($debug !== false) {
         $this->debugRequest($url, $headers, $body);
     }
     $request = new Request('POST', $url, $headers, $body);
     return $httpHandler($request, $httpOptions)->then(function (ResponseInterface $res) use($debug, $responseClass) {
         list($xmlResponse, $attachment) = $this->extractXml($res->getBody()->getContents());
         if ($debug !== false) {
             $this->debugResponse($xmlResponse);
         }
         $xmlParser = new XmlParser($responseClass);
         $response = $xmlParser->parse($xmlResponse);
         $response->attachment($attachment);
         return $response;
     });
 }