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\Model\Buyer;
  6 
  7 use Symfony\Component\Validator\Context\ExecutionContextInterface;
  8 use JMS\Serializer\Annotation as JMS;
  9 use Symfony\Component\Validator\Constraints as Assert;
 10 
 11 /**
 12  * Class Buyer
 13  * @package Team3\PayU\Order\Model\Buyer
 14  * @JMS\AccessorOrder("alphabetical")
 15  */
 16 class Buyer implements BuyerInterface
 17 {
 18     /**
 19      * @var string
 20      * @Assert\Email()
 21      * @JMS\Type("string")
 22      */
 23     protected $email;
 24 
 25     /**
 26      * @var string
 27      * @JMS\Type("string")
 28      */
 29     protected $phone;
 30 
 31     /**
 32      * @var string
 33      * @JMS\SerializedName("firstName")
 34      * @JMS\Type("string")
 35      */
 36     protected $firstName;
 37 
 38     /**
 39      * @var string
 40      * @JMS\SerializedName("lastName")
 41      * @JMS\Type("string")
 42      */
 43     protected $lastName;
 44 
 45     /**
 46      * @var DeliveryInterface
 47      * @JMS\Type("Team3\PayU\Order\Model\Buyer\Delivery")
 48      * @Assert\Valid
 49      * @JMS\Groups({"delivery"})
 50      */
 51     protected $delivery;
 52 
 53     /**
 54      * @var InvoiceInterface
 55      * @JMS\Type("Team3\PayU\Order\Model\Buyer\Invoice")
 56      * @Assert\Valid()
 57      * @JMS\Groups({"invoice"})
 58      */
 59     protected $invoice;
 60 
 61     public function __construct()
 62     {
 63         $this->delivery = new Delivery();
 64         $this->invoice = new Invoice();
 65     }
 66 
 67     /**
 68      * @return bool
 69      */
 70     public function isFilled()
 71     {
 72         return $this->firstName
 73             && $this->lastName
 74             && $this->email;
 75     }
 76 
 77     /**
 78      * @param ExecutionContextInterface $executionContext
 79      * @Assert\Callback()
 80      */
 81     public function validate(
 82         ExecutionContextInterface $executionContext
 83     ) {
 84         if (!$this->getFirstName()
 85             && !$this->getLastName()
 86             && !$this->getEmail()) {
 87             return;
 88         }
 89 
 90         if (!$this->getFirstName()
 91             || !$this->getLastName()
 92             || !$this->getEmail()) {
 93             $executionContext
 94                 ->buildViolation(
 95                     sprintf('Object %s is not filled correctly', get_class($this))
 96                 )
 97                 ->addViolation();
 98         }
 99     }
100 
101     /**
102      * @return string
103      */
104     public function getEmail()
105     {
106         return $this->email;
107     }
108 
109     /**
110      * @param string $email
111      *
112      * @return Buyer
113      */
114     public function setEmail($email)
115     {
116         $this->email = $email;
117 
118         return $this;
119     }
120 
121     /**
122      * @return string
123      */
124     public function getFirstName()
125     {
126         return $this->firstName;
127     }
128 
129     /**
130      * @param string $firstName
131      *
132      * @return Buyer
133      */
134     public function setFirstName($firstName)
135     {
136         $this->firstName = $firstName;
137 
138         return $this;
139     }
140 
141     /**
142      * @return string
143      */
144     public function getLastName()
145     {
146         return $this->lastName;
147     }
148 
149     /**
150      * @param string $lastName
151      *
152      * @return Buyer
153      */
154     public function setLastName($lastName)
155     {
156         $this->lastName = $lastName;
157 
158         return $this;
159     }
160 
161     /**
162      * @return string
163      */
164     public function getPhone()
165     {
166         return $this->phone;
167     }
168 
169     /**
170      * @param string $phone
171      *
172      * @return Buyer
173      */
174     public function setPhone($phone)
175     {
176         $this->phone = $phone;
177 
178         return $this;
179     }
180 
181     /**
182      * @return DeliveryInterface
183      */
184     public function getDelivery()
185     {
186         return $this->delivery;
187     }
188 
189     /**
190      * @param DeliveryInterface $delivery
191      *
192      * @return Buyer
193      */
194     public function setDelivery(DeliveryInterface $delivery)
195     {
196         $this->delivery = $delivery;
197 
198         return $this;
199     }
200 
201     /**
202      * @return InvoiceInterface
203      */
204     public function getInvoice()
205     {
206         return $this->invoice;
207     }
208 
209     /**
210      * @param InvoiceInterface $invoice
211      *
212      * @return Buyer
213      */
214     public function setInvoice(InvoiceInterface $invoice)
215     {
216         $this->invoice = $invoice;
217 
218         return $this;
219     }
220 }
221 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen