Open Journal Systems  3.3.0
lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php
1 <?php
7 
11 
36 {
37  const API_VERSION = '119.0';
38 
39  protected $liveEndpoint = 'https://api-3t.paypal.com/nvp';
40  protected $testEndpoint = 'https://api-3t.sandbox.paypal.com/nvp';
41 
42  public function getUsername()
43  {
44  return $this->getParameter('username');
45  }
46 
47  public function setUsername($value)
48  {
49  return $this->setParameter('username', $value);
50  }
51 
52  public function getPassword()
53  {
54  return $this->getParameter('password');
55  }
56 
57  public function setPassword($value)
58  {
59  return $this->setParameter('password', $value);
60  }
61 
62  public function getSignature()
63  {
64  return $this->getParameter('signature');
65  }
66 
67  public function setSignature($value)
68  {
69  return $this->setParameter('signature', $value);
70  }
71 
72  public function getSubject()
73  {
74  return $this->getParameter('subject');
75  }
76 
77  public function setSubject($value)
78  {
79  return $this->setParameter('subject', $value);
80  }
81 
82  public function getSolutionType()
83  {
84  return $this->getParameter('solutionType');
85  }
86 
87  public function setSolutionType($value)
88  {
89  return $this->setParameter('solutionType', $value);
90  }
91 
92  public function getLandingPage()
93  {
94  return $this->getParameter('landingPage');
95  }
96 
97  public function setLandingPage($value)
98  {
99  return $this->setParameter('landingPage', $value);
100  }
101 
102  public function getHeaderImageUrl()
103  {
104  return $this->getParameter('headerImageUrl');
105  }
106 
107  public function setHeaderImageUrl($value)
108  {
109  return $this->setParameter('headerImageUrl', $value);
110  }
111 
112  public function getLogoImageUrl()
113  {
114  return $this->getParameter('logoImageUrl');
115  }
116 
117  public function setLogoImageUrl($value)
118  {
119  return $this->setParameter('logoImageUrl', $value);
120  }
121 
122  public function getBorderColor()
123  {
124  return $this->getParameter('borderColor');
125  }
126 
127  public function setBorderColor($value)
128  {
129  return $this->setParameter('borderColor', $value);
130  }
131 
132  public function getBrandName()
133  {
134  return $this->getParameter('brandName');
135  }
136 
137  public function setBrandName($value)
138  {
139  return $this->setParameter('brandName', $value);
140  }
141 
142  public function getNoShipping()
143  {
144  return $this->getParameter('noShipping');
145  }
146 
147  public function setNoShipping($value)
148  {
149  return $this->setParameter('noShipping', $value);
150  }
151 
152  public function getAllowNote()
153  {
154  return $this->getParameter('allowNote');
155  }
156 
157  public function setAllowNote($value)
158  {
159  return $this->setParameter('allowNote', $value);
160  }
161 
162  public function getAddressOverride()
163  {
164  return $this->getParameter('addressOverride');
165  }
166 
167  public function setAddressOverride($value)
168  {
169  return $this->setParameter('addressOverride', $value);
170  }
171 
172  public function getMaxAmount()
173  {
174  return $this->getParameter('maxAmount');
175  }
176 
177  public function setMaxAmount($value)
178  {
179  return $this->setParameter('maxAmount', $value);
180  }
181 
182  public function getTaxAmount()
183  {
184  return $this->getParameter('taxAmount');
185  }
186 
187  public function setTaxAmount($value)
188  {
189  return $this->setParameter('taxAmount', $value);
190  }
191 
192  public function getShippingAmount()
193  {
194  return $this->getParameter('shippingAmount');
195  }
196 
197  public function setShippingAmount($value)
198  {
199  return $this->setParameter('shippingAmount', $value);
200  }
201 
202  public function getHandlingAmount()
203  {
204  return $this->getParameter('handlingAmount');
205  }
206 
207  public function setHandlingAmount($value)
208  {
209  return $this->setParameter('handlingAmount', $value);
210  }
211 
212  public function getShippingDiscount()
213  {
214  return $this->getParameter('shippingDiscount');
215  }
216 
217  public function setShippingDiscount($value)
218  {
219  return $this->setParameter('shippingDiscount', $value);
220  }
221 
222  public function getInsuranceAmount()
223  {
224  return $this->getParameter('insuranceAmount');
225  }
226 
227  public function setInsuranceAmount($value)
228  {
229  return $this->setParameter('insuranceAmount', $value);
230  }
231 
232  public function getLocaleCode()
233  {
234  return $this->getParameter('localeCode');
235  }
236 
237  /*
238  * Used to change the locale of PayPal pages.
239  * Accepts 2 or 5 character language codes as described here:
240  * https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECCustomizing/
241  *
242  * If no value/invalid value is passed, the gateway will default it for you
243  */
244  public function setLocaleCode($value)
245  {
246  return $this->setParameter('localeCode', $value);
247  }
248 
249  public function setCustomerServiceNumber($value)
250  {
251  return $this->setParameter('customerServiceNumber', $value);
252  }
253 
254  public function getCustomerServiceNumber()
255  {
256  return $this->getParameter('customerServiceNumber');
257  }
258 
259  public function setSellerPaypalAccountId($value)
260  {
261  return $this->setParameter('sellerPaypalAccountId', $value);
262  }
263 
264  public function getSellerPaypalAccountId()
265  {
266  return $this->getParameter('sellerPaypalAccountId');
267  }
268 
272  public function setButtonSource($value)
273  {
274  return $this->setParameter('ButtonSource', $value);
275  }
276 
277  public function getButtonSource()
278  {
279  return $this->getParameter('ButtonSource');
280  }
281 
282  protected function getBaseData()
283  {
284  $data = array();
285  $data['VERSION'] = static::API_VERSION;
286  $data['USER'] = $this->getUsername();
287  $data['PWD'] = $this->getPassword();
288  $data['SIGNATURE'] = $this->getSignature();
289  $data['SUBJECT'] = $this->getSubject();
290  $bnCode = $this->getButtonSource();
291  if (!empty($bnCode)) {
292  $data['BUTTONSOURCE'] = $bnCode;
293  }
294 
295  return $data;
296  }
297 
298  protected function getItemData()
299  {
300  $data = array();
301  $items = $this->getItems();
302  if ($items) {
303  $data["PAYMENTREQUEST_0_ITEMAMT"] = 0;
304  foreach ($items as $n => $item) {
305  $data["L_PAYMENTREQUEST_0_NAME$n"] = $item->getName();
306  $data["L_PAYMENTREQUEST_0_DESC$n"] = $item->getDescription();
307  $data["L_PAYMENTREQUEST_0_QTY$n"] = $item->getQuantity();
308  $data["L_PAYMENTREQUEST_0_AMT$n"] = $this->formatCurrency($item->getPrice());
309  if ($item instanceof PayPalItem) {
310  $data["L_PAYMENTREQUEST_0_NUMBER$n"] = $item->getCode();
311  }
312 
313  $data["PAYMENTREQUEST_0_ITEMAMT"] += $item->getQuantity() * $this->formatCurrency($item->getPrice());
314  }
315  $data["PAYMENTREQUEST_0_ITEMAMT"] = $this->formatCurrency($data["PAYMENTREQUEST_0_ITEMAMT"]);
316  }
317 
318  return $data;
319  }
320 
321  public function sendData($data)
322  {
323  $httpRequest = $this->httpClient->post($this->getEndpoint(), null, http_build_query($data, '', '&'));
324  $httpRequest->getCurlOptions()->set(CURLOPT_SSLVERSION, 6); // CURL_SSLVERSION_TLSv1_2 for libcurl < 7.35
325  $httpResponse = $httpRequest->send();
326 
327  return $this->createResponse($httpResponse->getBody());
328  }
329 
330  protected function getEndpoint()
331  {
332  return $this->getTestMode() ? $this->testEndpoint : $this->liveEndpoint;
333  }
334 
335  protected function createResponse($data)
336  {
337  return $this->response = new Response($this, $data);
338  }
339 
345  public function setItems($items)
346  {
347  if ($items && !$items instanceof ItemBag) {
348  $items = new PayPalItemBag($items);
349  }
350 
351  return $this->setParameter('items', $items);
352  }
353 }
Omnipay\PayPal\Message\AbstractRequest\getCustomerServiceNumber
getCustomerServiceNumber()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:254
Omnipay\PayPal\Message\AbstractRequest\setBrandName
setBrandName($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:137
Omnipay\PayPal\Message\AbstractRequest\getShippingAmount
getShippingAmount()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:192
Omnipay\PayPal\Message\AbstractRequest\getShippingDiscount
getShippingDiscount()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:212
Omnipay\PayPal\Message\AbstractRequest\setSubject
setSubject($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:77
Omnipay\Common\Message\AbstractRequest\getTestMode
getTestMode()
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:201
Omnipay\PayPal\Message\AbstractRequest\getPassword
getPassword()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:52
Omnipay\PayPal\Message\AbstractRequest\getHandlingAmount
getHandlingAmount()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:202
Omnipay\PayPal\Message\AbstractRequest\setMaxAmount
setMaxAmount($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:177
Omnipay\Common\Message\AbstractRequest\$httpRequest
$httpRequest
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:92
Omnipay\PayPal\Message\AbstractRequest\setAddressOverride
setAddressOverride($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:167
Omnipay\Common\Message\AbstractRequest\getParameter
getParameter($key)
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:172
Omnipay\Common\Message\AbstractRequest\formatCurrency
formatCurrency($amount)
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:446
Omnipay\Common\Message\AbstractRequest\setParameter
setParameter($key, $value)
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:185
Omnipay\PayPal\Message\Response
Definition: lib/vendor/omnipay/paypal/src/Message/Response.php:11
Omnipay\Common\Message\AbstractRequest
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:62
Omnipay\PayPal\Message\AbstractRequest\setSolutionType
setSolutionType($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:87
Omnipay\PayPal\Message\AbstractRequest\getItemData
getItemData()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:298
Omnipay\PayPal\Message\AbstractRequest\setButtonSource
setButtonSource($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:272
Omnipay\PayPal\Message\AbstractRequest\$testEndpoint
$testEndpoint
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:40
Omnipay\PayPal\Message\AbstractRequest\createResponse
createResponse($data)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:335
Omnipay\PayPal\Message\AbstractRequest\getHeaderImageUrl
getHeaderImageUrl()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:102
Omnipay\PayPal\Message\AbstractRequest\setTaxAmount
setTaxAmount($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:187
Omnipay\Common\Message\AbstractRequest\getItems
getItems()
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:529
Omnipay\PayPal\Message\AbstractRequest\API_VERSION
const API_VERSION
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:37
Omnipay\PayPal\Message\AbstractRequest\getBrandName
getBrandName()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:132
Omnipay\PayPal\Message\AbstractRequest\setSellerPaypalAccountId
setSellerPaypalAccountId($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:259
Omnipay\PayPal\Message\AbstractRequest\setBorderColor
setBorderColor($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:127
Omnipay\PayPal\Message\AbstractRequest\setSignature
setSignature($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:67
Omnipay\PayPal\Message\AbstractRequest\getMaxAmount
getMaxAmount()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:172
Omnipay\PayPal\Message\AbstractRequest\$liveEndpoint
$liveEndpoint
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:39
Omnipay\PayPal\Message\AbstractRequest\getUsername
getUsername()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:42
Omnipay\PayPal\Message\AbstractRequest\getSellerPaypalAccountId
getSellerPaypalAccountId()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:264
Omnipay\PayPal\Message\AbstractRequest\setLandingPage
setLandingPage($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:97
Omnipay\PayPal\Message\AbstractRequest\getInsuranceAmount
getInsuranceAmount()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:222
Omnipay\PayPal\Message\AbstractRequest\setHeaderImageUrl
setHeaderImageUrl($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:107
Omnipay\PayPal\Message\AbstractRequest\sendData
sendData($data)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:321
Omnipay\PayPal\Message\AbstractRequest\getEndpoint
getEndpoint()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:330
Omnipay\PayPal\Message\AbstractRequest\setAllowNote
setAllowNote($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:157
Omnipay\PayPal\Message\AbstractRequest\setItems
setItems($items)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:345
Omnipay\PayPal\Message\AbstractRequest\setInsuranceAmount
setInsuranceAmount($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:227
Omnipay\PayPal\Message\AbstractRequest\getSignature
getSignature()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:62
Omnipay\PayPal\Message\AbstractRequest\getButtonSource
getButtonSource()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:277
Omnipay\PayPal\Message\AbstractRequest\getLandingPage
getLandingPage()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:92
Omnipay\PayPal\Message\AbstractRequest
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:35
Omnipay\PayPal\Message\AbstractRequest\setHandlingAmount
setHandlingAmount($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:207
Omnipay\PayPal\Message\AbstractRequest\setLocaleCode
setLocaleCode($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:244
Omnipay\PayPal\Message\AbstractRequest\getBorderColor
getBorderColor()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:122
Omnipay\PayPal\Message\AbstractRequest\setShippingDiscount
setShippingDiscount($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:217
Omnipay\PayPal\Message\AbstractRequest\getLocaleCode
getLocaleCode()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:232
Omnipay\PayPal\Message\AbstractRequest\getNoShipping
getNoShipping()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:142
Omnipay\PayPal\Message\AbstractRequest\getAddressOverride
getAddressOverride()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:162
Omnipay\PayPal\Message\AbstractRequest\setNoShipping
setNoShipping($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:147
Omnipay\PayPal\PayPalItemBag
Definition: lib/vendor/omnipay/paypal/src/PayPalItemBag.php:16
Omnipay\PayPal\Message\AbstractRequest\setPassword
setPassword($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:57
Omnipay\PayPal\Message\AbstractRequest\getTaxAmount
getTaxAmount()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:182
Omnipay\PayPal\Message\AbstractRequest\setLogoImageUrl
setLogoImageUrl($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:117
Omnipay\PayPal\Message\AbstractRequest\setUsername
setUsername($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:47
Omnipay\Common\ItemBag
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/ItemBag.php:16
Omnipay\PayPal\Message\AbstractRequest\getLogoImageUrl
getLogoImageUrl()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:112
Omnipay\PayPal\PayPalItem
Definition: lib/vendor/omnipay/paypal/src/PayPalItem.php:15
Omnipay\PayPal\Message\AbstractRequest\getAllowNote
getAllowNote()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:152
Omnipay\PayPal\Message\AbstractRequest\getBaseData
getBaseData()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:282
Omnipay\PayPal\Message\AbstractRequest\getSolutionType
getSolutionType()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:82
Omnipay\PayPal\Message\AbstractRequest\setCustomerServiceNumber
setCustomerServiceNumber($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:249
Omnipay\PayPal\Message\AbstractRequest\setShippingAmount
setShippingAmount($value)
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:197
Omnipay\PayPal\Message
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:6
Omnipay\PayPal\Message\AbstractRequest\getSubject
getSubject()
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:72