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\Transformer\UserOrder\Strategy;
 6 
 7 use Team3\PayU\Order\Model\Buyer\BuyerInterface;
 8 use Team3\PayU\Order\Model\OrderInterface;
 9 use Team3\PayU\Order\Transformer\UserOrder\TransformerProperties;
10 use Team3\PayU\Order\Transformer\UserOrder\TransformerPropertiesRegExp;
11 use Team3\PayU\PropertyExtractor\ExtractorResult;
12 
13 class BuyerTransformer implements UserOrderTransformerStrategyInterface
14 {
15     /**
16      * @inheritdoc
17      */
18     public function transform(
19         OrderInterface $order,
20         ExtractorResult $extractorResult
21     ) {
22         $this->copyValue(
23             $order->getBuyer(),
24             $extractorResult
25         );
26     }
27 
28     /**
29      * @inheritdoc
30      */
31     public function supports($propertyName)
32     {
33         return 1 === preg_match(
34             TransformerPropertiesRegExp::BUYER_REGEXP,
35             $propertyName
36         );
37     }
38 
39     /**
40      * @param BuyerInterface  $buyer
41      * @param ExtractorResult $extractorResult
42      */
43     private function copyValue(
44         BuyerInterface $buyer,
45         ExtractorResult $extractorResult
46     ) {
47         switch ($extractorResult->getPropertyName()) {
48             case TransformerProperties::BUYER_EMAIL:
49                 $buyer->setEmail($extractorResult->getValue());
50                 break;
51             case TransformerProperties::BUYER_PHONE:
52                 $buyer->setPhone($extractorResult->getValue());
53                 break;
54             case TransformerProperties::BUYER_FIRST_NAME:
55                 $buyer->setFirstName($extractorResult->getValue());
56                 break;
57             case TransformerProperties::BUYER_LAST_NAME:
58                 $buyer->setLastName($extractorResult->getValue());
59                 break;
60             default:
61         }
62     }
63 }
64 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen