Overview

Namespaces

  • mcfedr
    • Paypal
      • Exceptions
      • Notifications
      • Products
  • PHP

Classes

  • AdaptivePaymentNotification
  • CartChangeNotification
  • CartNotification
  • MasspayNotification
  • MasspayNotifications
  • Notification
  • PaymentNotification
  • SubscriptionNotification
  • Overview
  • Namespace
  • Class
  • Tree
 1: <?php
 2: 
 3: namespace mcfedr\Paypal\Notifications;
 4: 
 5: use mcfedr\Paypal\Products\CartProduct;
 6: 
 7: class CartNotification extends PaymentNotification {
 8: 
 9:     /**
10:      * Amount paid for shipping
11:      * @var double
12:      */
13:     public $shipping;
14: 
15:     /**
16:      * Amount paid for handling
17:      * @var double
18:      */
19:     public $handling;
20: 
21:     /**
22:      * The products purchased in this transaction
23:      * Can be used to check the right amounts where paid and the cart is what you expected
24:      * @var array {@link mcfedr\Paypal\Products\CartProduct}
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: 
Paypal API documentation generated by ApiGen 2.8.0