1: <?php
2:
3: namespace mcfedr\Paypal\Notifications;
4:
5: use mcfedr\Paypal\Products\CartProduct;
6:
7: class CartNotification extends PaymentNotification {
8:
9: 10: 11: 12:
13: public $shipping;
14:
15: 16: 17: 18:
19: public $handling;
20:
21: 22: 23: 24: 25:
26: public $products;
27:
28: public function __construct($vars) {
29: parent::__construct($vars);
30: $this->type = static::CART;
31:
32: if (isset($vars['mc_handling'])) {
33: $this->handling = $vars['mc_handling'];
34: }
35:
36: if (isset($vars['mc_shipping'])) {
37: $this->shipping = $vars['mc_shipping'];
38: }
39: else if (isset($vars['shipping'])) {
40: $this->shipping = $vars['shipping'];
41: }
42:
43: if (isset($vars['mc_gross'])) {
44: $this->total = $vars['mc_gross'];
45: $this->amount = $this->total - (isset($this->handling) ? $this->handling : 0) - (isset($this->shipping) ? $this->shipping : 0);
46: }
47:
48: $this->products = array();
49: for ($i = 1; isset($vars["item_name$i"]); $i++) {
50: $this->products[] = new CartProduct($vars, $i);
51: }
52: if (isset($vars['item_name'])) {
53: $this->products[] = new CartProduct($vars);
54: }
55: return $this;
56: }
57:
58: }
59: