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\OrderInterface;
 8 use Team3\PayU\Order\Transformer\UserOrder\TransformerProperties;
 9 use Team3\PayU\Order\Transformer\UserOrder\TransformerPropertiesRegExp;
10 use Team3\PayU\PropertyExtractor\ExtractorResult;
11 
12 class GeneralTransformer implements UserOrderTransformerStrategyInterface
13 {
14     /**
15      * @inheritdoc
16      */
17     public function transform(
18         OrderInterface $order,
19         ExtractorResult $extractorResult
20     ) {
21         $this->copyValue(
22             $order,
23             $extractorResult->getPropertyName(),
24             $extractorResult->getValue()
25         );
26     }
27 
28     /**
29      * Will return true if property name starts with "general."
30      *
31      * @inheritdoc
32      */
33     public function supports($propertyName)
34     {
35         return 1 === preg_match(
36             TransformerPropertiesRegExp::GENERAL_REGEXP,
37             $propertyName
38         );
39     }
40 
41     /**
42      * @param OrderInterface $order
43      * @param                $propertyName
44      * @param                $value
45      */
46     private function copyValue(
47         OrderInterface $order,
48         $propertyName,
49         $value
50     ) {
51         switch ($propertyName) {
52             case TransformerProperties::GENERAL_CUSTOMER_IP:
53                 $order->setCustomerIp($value);
54                 break;
55             case TransformerProperties::GENERAL_ORDER_ID:
56                 $order->setOrderId($value);
57                 break;
58             case TransformerProperties::GENERAL_ADDITIONAL_DESC:
59                 $order->setAdditionalDescription($value);
60                 break;
61             case TransformerProperties::GENERAL_CURRENCY_CODE:
62                 $order->setCurrencyCode($value);
63                 break;
64             case TransformerProperties::GENERAL_DESCRIPTION:
65                 $order->setDescription($value);
66                 break;
67             case TransformerProperties::GENERAL_MERCHANT_POS_ID:
68                 $order->setMerchantPosId($value);
69                 break;
70             case TransformerProperties::GENERAL_SIGNATURE:
71                 $order->setSignature($value);
72                 break;
73             case TransformerProperties::GENERAL_TOTAL_AMOUNT:
74                 $order->setTotalAmount($value);
75                 break;
76             default:
77         }
78     }
79 }
80 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen