1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace Omnipay\PaypalRest\Message; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* @author Ivan Kerin <[email protected]> |
7
|
|
|
* @copyright 2014, Clippings Ltd. |
8
|
|
|
* @license http://spdx.org/licenses/BSD-3-Clause |
9
|
|
|
*/ |
10
|
|
|
abstract class AbstractRequest extends \Omnipay\Common\Message\AbstractRequest |
11
|
|
|
{ |
12
|
|
|
const LIVE = 'https://api.paypal.com/v1'; |
13
|
|
|
const SANDBOX = 'https://api.sandbox.paypal.com/v1'; |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* @return string |
17
|
|
|
*/ |
18
|
|
|
public function getServer() |
19
|
|
|
{ |
20
|
|
|
return $this->getTestMode() ? self::SANDBOX : self::LIVE; |
21
|
|
|
} |
22
|
|
|
|
23
|
|
|
/** |
24
|
|
|
* Requires a valid "card" parameter |
25
|
|
|
* |
26
|
|
|
* @return array |
27
|
|
|
*/ |
28
|
|
|
public function getPaypalCard() |
29
|
|
|
{ |
30
|
|
|
$this->validate('card'); |
31
|
|
|
|
32
|
|
|
$card = $this->getCard(); |
33
|
|
|
$card->validate(); |
34
|
|
|
|
35
|
|
|
return array_filter(array( |
36
|
|
|
'number' => $card->getNumber(), |
37
|
|
|
'type' => $card->getBrand(), |
38
|
|
|
'expire_month' => $card->getExpiryMonth(), |
39
|
|
|
'expire_year' => $card->getExpiryYear(), |
40
|
|
|
'cvv2' => $card->getCvv(), |
41
|
|
|
'first_name' => $card->getFirstName(), |
42
|
|
|
'last_name' => $card->getLastName(), |
43
|
|
|
'billing_address' => array_filter(array( |
44
|
|
|
'line1' => $card->getAddress1(), |
45
|
|
|
'line2' => $card->getAddress2(), |
46
|
|
|
'city' => $card->getCity(), |
47
|
|
|
'state' => $card->getState(), |
48
|
|
|
'postal_code' => $card->getPostcode(), |
49
|
|
|
'country_code' => strtoupper($card->getCountry()), |
50
|
|
|
)) |
51
|
|
|
)); |
52
|
|
|
} |
53
|
|
|
} |
54
|
|
|
|