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;
  6 
  7 use JMS\Serializer\Annotation as JMS;
  8 use Team3\PayU\Order\Model\Buyer\Buyer;
  9 use Team3\PayU\Order\Model\Buyer\BuyerInterface;
 10 use Team3\PayU\Order\Model\Money\Money;
 11 use Team3\PayU\Order\Model\Money\MoneyInterface;
 12 use Team3\PayU\Order\Model\Products\ProductCollection;
 13 use Team3\PayU\Order\Model\ShippingMethods\ShippingMethodCollection;
 14 use Team3\PayU\Order\Model\Traits\OrderIdentificationParametersTrait;
 15 use Team3\PayU\Order\Model\Traits\ProductCollectionTrait;
 16 use Team3\PayU\Order\Model\Traits\ShippingMethodCollectionTrait;
 17 use Team3\PayU\Order\Model\Traits\UrlsTrait;
 18 use Symfony\Component\Validator\Constraints as Assert;
 19 
 20 /**
 21  * Class Order
 22  * @package Team3\PayU\Order\Model
 23  * @JMS\AccessorOrder("alphabetical")
 24  * @JMS\AccessType("public_method")
 25  */
 26 class Order implements OrderInterface
 27 {
 28     use IsFilledTrait;
 29     use UrlsTrait;
 30     use ProductCollectionTrait;
 31     use ShippingMethodCollectionTrait;
 32     use OrderIdentificationParametersTrait;
 33 
 34     /**
 35      * @var BuyerInterface
 36      * @JMS\Type("Team3\PayU\Order\Model\Buyer\Buyer")
 37      * @JMS\Groups({"buyer"})
 38      * @Assert\Valid()
 39      */
 40     protected $buyer;
 41 
 42     /**
 43      * @var string
 44      * @JMS\Type("string")
 45      * @JMS\SerializedName("customerIp")
 46      * @Assert\Ip()
 47      * @Assert\NotBlank()
 48      */
 49     protected $customerIp;
 50 
 51     /**
 52      * @var string
 53      * @JMS\Type("string")
 54      * @JMS\SerializedName("merchantPosId")
 55      * @Assert\NotBlank()
 56      */
 57     protected $merchantPosId;
 58 
 59     /**
 60      * @var string
 61      * @JMS\Type("string")
 62      * @Assert\NotBlank()
 63      */
 64     protected $description;
 65 
 66     /**
 67      * @var string
 68      * @JMS\Type("string")
 69      * @JMS\Accessor(
 70      *             getter="getAdditionalDescription",
 71      *             setter="setAdditionalDescription"
 72      *             )
 73      * @JMS\SerializedName("additionalDescription")
 74      */
 75     protected $extraDescription;
 76 
 77     /**
 78      * @var string
 79      * @JMS\Type("string")
 80      * @JMS\SerializedName("currencyCode")
 81      * @Assert\NotBlank()
 82      */
 83     protected $currencyCode;
 84 
 85     /**
 86      * @var MoneyInterface
 87      * @JMS\Type("integer")
 88      * @JMS\SerializedName("totalAmount")
 89      * @JMS\Accessor(
 90      *                     getter="getTotalAmountForSerialization",
 91      *                     setter="setTotalAmountFromDeserialization"
 92      *                     )
 93      * @Assert\Type(type="object")
 94      * @Assert\NotBlank()
 95      * @Assert\Valid
 96      */
 97     protected $totalAmount;
 98 
 99     /**
100      * @var string
101      * @JMS\Type("string")
102      * @JMS\SerializedName("OpenPayU-Signature")
103      * @Assert\NotBlank()
104      */
105     protected $signature;
106 
107     /**
108      * @var \DateTime
109      * @JMS\Type("string")
110      * @JMS\Accessor(
111      *                setter="setCreatedAtFromDeserialization"
112      *                )
113      * @JMS\SerializedName("orderCreateDate")
114      */
115     protected $createdAt;
116 
117     /**
118      * @var OrderStatusInterface
119      * @JMS\Type("string")
120      * @JMS\Accessor(
121      *                           getter="getStatusForSerialization",
122      *                           setter="setStatusFromDeserialization"
123      *                           )
124      */
125     protected $status;
126 
127     public function __construct()
128     {
129         $this->buyer = new Buyer();
130         $this->productCollection = new ProductCollection();
131         $this->shippingCollection = new ShippingMethodCollection();
132         $this->status = new OrderStatus();
133         $this->totalAmount = new Money(0);
134     }
135 
136     /**
137      * @return BuyerInterface
138      */
139     public function getBuyer()
140     {
141         return $this->buyer;
142     }
143 
144     /**
145      * @param BuyerInterface $buyer
146      *
147      * @return Order
148      */
149     public function setBuyer(BuyerInterface $buyer)
150     {
151         $this->buyer = $buyer;
152 
153         return $this;
154     }
155 
156     /**
157      * @return string
158      */
159     public function getAdditionalDescription()
160     {
161         return $this->extraDescription;
162     }
163 
164     /**
165      * @param string $additionalDescription
166      *
167      * @return $this
168      */
169     public function setAdditionalDescription($additionalDescription)
170     {
171         $this->extraDescription = $additionalDescription;
172 
173         return $this;
174     }
175 
176     /**
177      * @return string
178      */
179     public function getCurrencyCode()
180     {
181         return $this->currencyCode;
182     }
183 
184     /**
185      * @param string $currencyCode
186      *
187      * @return $this
188      */
189     public function setCurrencyCode($currencyCode)
190     {
191         $this->currencyCode = $currencyCode;
192 
193         return $this;
194     }
195 
196     /**
197      * @return string
198      */
199     public function getCustomerIp()
200     {
201         return $this->customerIp;
202     }
203 
204     /**
205      * @param string $customerIp
206      *
207      * @return $this
208      */
209     public function setCustomerIp($customerIp)
210     {
211         $this->customerIp = $customerIp;
212 
213         return $this;
214     }
215 
216     /**
217      * @return string
218      */
219     public function getDescription()
220     {
221         return $this->description;
222     }
223 
224     /**
225      * @param string $description
226      *
227      * @return $this
228      */
229     public function setDescription($description)
230     {
231         $this->description = $description;
232 
233         return $this;
234     }
235 
236     /**
237      * @return string
238      */
239     public function getMerchantPosId()
240     {
241         return $this->merchantPosId;
242     }
243 
244     /**
245      * @param string $merchantPosId
246      *
247      * @return $this
248      */
249     public function setMerchantPosId($merchantPosId)
250     {
251         $this->merchantPosId = $merchantPosId;
252 
253         return $this;
254     }
255 
256     /**
257      * @return string
258      */
259     public function getSignature()
260     {
261         return $this->signature;
262     }
263 
264     /**
265      * @param string $signature
266      *
267      * @return $this
268      */
269     public function setSignature($signature)
270     {
271         $this->signature = $signature;
272 
273         return $this;
274     }
275 
276     /**
277      * @return MoneyInterface
278      */
279     public function getTotalAmount()
280     {
281         return $this->totalAmount;
282     }
283 
284     /**
285      * @param MoneyInterface $totalAmount
286      *
287      * @return $this
288      */
289     public function setTotalAmount(MoneyInterface $totalAmount)
290     {
291         $this->totalAmount = $totalAmount;
292 
293         return $this;
294     }
295 
296     /**
297      * @param int $price
298      *
299      * @return $this
300      */
301     public function setTotalAmountFromDeserialization($price)
302     {
303         $this->totalAmount = new Money($price / 100);
304 
305         return $this;
306     }
307 
308     /**
309      * @return int
310      */
311     public function getTotalAmountForSerialization()
312     {
313         return $this->totalAmount->getValueWithoutSeparation(2);
314     }
315 
316     /**
317      * @return \DateTime
318      */
319     public function getCreatedAt()
320     {
321         return $this->createdAt;
322     }
323 
324     /**
325      * @param \DateTime $createdAt
326      *
327      * @return $this
328      */
329     public function setCreatedAt(\DateTime $createdAt)
330     {
331         $this->createdAt = $createdAt;
332 
333         return $this;
334     }
335 
336     /**
337      * @return OrderStatus
338      */
339     public function getStatus()
340     {
341         return $this->status;
342     }
343 
344     /**
345      * @return string
346      */
347     public function getStatusForSerialization()
348     {
349         return $this->status->getValue();
350     }
351 
352     /**
353      * @param OrderStatusInterface $status
354      *
355      * @return $this
356      */
357     public function setStatus(OrderStatusInterface $status)
358     {
359         $this->status = $status;
360 
361         return $this;
362     }
363 
364     /**
365      * @param string $status
366      *
367      * @return $this
368      */
369     public function setStatusFromDeserialization($status)
370     {
371         $this->status = new OrderStatus($status);
372 
373         return $this;
374     }
375 
376     /**
377      * PayU is using different datetime formats for different things.
378      * This method will capture any datetime format and parse it into DateTime object
379      * @param string $createdAt
380      *
381      * @return $this
382      */
383     public function setCreatedAtFromDeserialization($createdAt)
384     {
385         $this->createdAt = new \DateTime($createdAt);
386 
387         return $this;
388     }
389 }
390 
PayU integration by Krzysztof Gzocha API documentation generated by ApiGen