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\Order\Autocomplete;
 6 
 7 use Psr\Log\LoggerInterface;
 8 use Team3\PayU\Configuration\ConfigurationInterface;
 9 use Team3\PayU\Order\Autocomplete\Strategy\AutocompleteStrategyInterface;
10 use Team3\PayU\Order\Model\OrderInterface;
11 
12 class OrderAutocomplete implements OrderAutocompleteInterface
13 {
14     /**
15      * @var AutocompleteStrategyInterface[]
16      */
17     private $strategies;
18 
19     /**
20      * @var LoggerInterface
21      */
22     private $logger;
23 
24     /**
25      * @param LoggerInterface $logger
26      */
27     public function __construct(LoggerInterface $logger)
28     {
29         $this->strategies = [];
30         $this->logger = $logger;
31     }
32 
33     /**
34      * @param OrderInterface         $order
35      * @param ConfigurationInterface $configuration
36      */
37     public function autocomplete(
38         OrderInterface $order,
39         ConfigurationInterface $configuration
40     ) {
41         foreach ($this->strategies as $strategy) {
42             if ($strategy->supports($order)) {
43                 $strategy->autocomplete($order, $configuration);
44                 $this->logAutocompletion($order, $strategy);
45             }
46         }
47     }
48 
49     /**
50      * @param AutocompleteStrategyInterface $autocompleteStrategy
51      *
52      * @return $this
53      */
54     public function addStrategy(
55         AutocompleteStrategyInterface $autocompleteStrategy
56     ) {
57         $this->strategies[] = $autocompleteStrategy;
58 
59         return $this;
60     }
61 
62     /**
63      * @param OrderInterface                $order
64      * @param AutocompleteStrategyInterface $strategy
65      */
66     private function logAutocompletion(
67         OrderInterface $order,
68         AutocompleteStrategyInterface $strategy
69     ) {
70         $this
71             ->logger
72             ->info(
73                 sprintf(
74                     'Order with ID %s parameters were autocompleted by %s',
75                     $order->getOrderId(),
76                     get_class($strategy)
77                 ),
78                 [
79                     'order' => $order,
80                     'strategy' => $strategy,
81                 ]
82             );
83     }
84 }
85 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen