1: <?php
2:
3: namespace mcfedr\Paypal;
4:
5: /**
6: * Settings used in paypal transactions
7: */
8: class Settings {
9:
10: /**
11: * Currency, default is GBP, might be USD or something else
12: * @var string
13: */
14: public $currency = 'GBP';
15:
16: /**
17: * Local to use on paypal pages, default is GB
18: * @var string
19: */
20: public $local = 'GB';
21:
22: /**
23: * Text for cancel button show on paypal pages
24: * @var string
25: */
26: public $cancelBtn = 'Return to merchant';
27:
28: /**
29: * Can the user change the quantity of items in cart
30: * @var bool
31: */
32: public $canChooseQuantity = false;
33:
34: /**
35: * Whether to collect shipping info
36: * @var bool
37: */
38: public $shippingInfoNeeded = false;
39:
40: /**
41: * Allow user to leave a note
42: * @var bool
43: */
44: public $allowMerchantNote = false;
45:
46: /**
47: * URL of logo image for paypal pages
48: * @var string
49: */
50: public $imageURL = null;
51:
52: /**
53: * Color of paypal area on paypal pages
54: * eg 'ff0000' for red
55: * @var string
56: */
57: public $payflowColor = null;
58:
59: /**
60: * Backgroundcolor of header area
61: * eg 'ff0000' for red
62: * @var string
63: */
64: public $headerBackgroundColor = null;
65:
66: /**
67: * Color of 2px border around the header
68: * eg 'ff0000' for red
69: * @var string
70: */
71: public $headerBorderColor = null;
72:
73: /**
74: * If you use weight based shipping costyou should set the unit of item weights
75: * @var string
76: */
77: public $weightUnit = null;
78:
79: /**
80: * Cause all notifications to be logged to stderr
81: * @var bool|\Psr\Log\LoggerInterface
82: */
83: public $logNotifications = false;
84:
85: /**
86: * Create a settings object
87: *
88: * @param string $currency
89: * @param bool|\Psr\Log\LoggerInterface $logging
90: */
91: public function __construct($currency = 'GBP', $logging = false) {
92: $this->currency = $currency;
93: $this->logNotifications = $logging;
94: }
95:
96: /**
97: * Sets up the array with the vars for the settings
98: *
99: * @param array $params
100: */
101: public function setParams(&$params) {
102: if (!empty($this->local)) {
103: $params['lc'] = $this->local;
104: }
105: if (!empty($this->currency)) {
106: $params['currency_code'] = $this->currency;
107: }
108: if (!empty($this->cancelBtn)) {
109: $params['cbt'] = $this->cancelBtn;
110: }
111: $params['undefined_quantity'] = !empty($this->canChooseQuantity) && $this->canChooseQuantity ? 1 : 0;
112: $params['no_shipping'] = !empty($this->shippingInfoNeeded) && $this->shippingInfoNeeded ? 0 : 1;
113: $params['no_note'] = !empty($this->allowMerchantNote) && $this->allowMerchantNote ? 0 : 1;
114: $params["weight_unit"] = empty($this->weight_unit) ? 'kgs' : $this->weight_unit;
115: if (!empty($this->imageURL)) {
116: $params['image_url'] = $this->imageURL;
117: }
118: if (!empty($this->payflowColor)) {
119: $params['cpp_payflow_color'] = $this->payflowColor;
120: }
121: if (!empty($this->headerBackgroundColor)) {
122: $params['cpp_headerback_color'] = $this->headerBackgroundColor;
123: }
124: if (!empty($this->headerBorderColor)) {
125: $params['cpp_headerborder_color'] = $this->headerBorderColor;
126: }
127: }
128:
129: }
130: