PayU integration by Krzysztof Gzocha
  • Namespace
  • Class

Namespaces

  • Team3
    • PayU
      • Annotation
      • Communication
        • CurlRequestBuilder
        • HttpStatusParser
        • Notification
        • Process
          • NotificationProcess
          • ResponseDeserializer
        • Request
          • Model
        • Response
          • Model
        • Sender
      • Configuration
        • Credentials
      • Order
        • Autocomplete
          • Strategy
        • Model
          • Buyer
          • Money
          • Products
          • ShippingMethods
          • Traits
        • Transformer
          • UserOrder
            • Strategy
              • Product
              • ShippingMethod
      • PropertyExtractor
        • Reader
      • Serializer
      • SignatureCalculator
        • Encoder
          • Algorithms
          • Strategy
        • ParametersSorter
        • Validator
      • ValidatorBuilder

Classes

  • Team3\PayU\ValidatorBuilder\ValidatorBuilder

Interfaces

  • Team3\PayU\ValidatorBuilder\ValidatorBuilderInterface
 1 <?php
 2 /**
 3  * @author Krzysztof Gzocha <krzysztof.gzocha@xsolve.pl>
 4  */
 5 namespace Team3\PayU\Communication\HttpStatusParser;
 6 
 7 use Buzz\Message\Response;
 8 
 9 /**
10  * {@inheritdoc}
11  */
12 class HttpStatusParser implements HttpStatusParserInterface
13 {
14     const SUCCESS_CODE = 200;
15     const REDIRECT_CODE = 302;
16 
17     /**
18      * @param Response $curlResponse
19      *
20      * @throws HttpStatusParserException
21      */
22     public function parse(Response $curlResponse)
23     {
24         $statusCode = $curlResponse->getStatusCode();
25 
26         if ($this->shouldThrowException($statusCode)) {
27             throw new HttpStatusParserException(
28                 $curlResponse->getContent(),
29                 $statusCode
30             );
31         }
32     }
33 
34     /**
35      * @param int $statusCode
36      *
37      * @return bool
38      */
39     private function shouldThrowException($statusCode)
40     {
41         return self::SUCCESS_CODE !== $statusCode
42             && self::REDIRECT_CODE !== $statusCode;
43     }
44 }
45 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen