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