Open Monograph Press  3.3.0
vendor/omnipay/paypal/src/Message/RestCreateCardRequest.php
1 <?php
6 namespace Omnipay\PayPal\Message;
7 
71 class RestCreateCardRequest extends AbstractRestRequest
72 {
73  public function getData()
74  {
75  $this->validate('card');
76  $this->getCard()->validate();
77 
78  $data = array(
79  'number' => $this->getCard()->getNumber(),
80  'type' => $this->getCard()->getBrand(),
81  'expire_month' => $this->getCard()->getExpiryMonth(),
82  'expire_year' => $this->getCard()->getExpiryYear(),
83  'cvv2' => $this->getCard()->getCvv(),
84  'first_name' => $this->getCard()->getFirstName(),
85  'last_name' => $this->getCard()->getLastName(),
86  'billing_address' => array(
87  'line1' => $this->getCard()->getAddress1(),
88  //'line2' => $this->getCard()->getAddress2(),
89  'city' => $this->getCard()->getCity(),
90  'state' => $this->getCard()->getState(),
91  'postal_code' => $this->getCard()->getPostcode(),
92  'country_code' => strtoupper($this->getCard()->getCountry()),
93  )
94  );
95 
96  // There's currently a quirk with the REST API that requires line2 to be
97  // non-empty if it's present. Jul 14, 2014
98  $line2 = $this->getCard()->getAddress2();
99  if (!empty($line2)) {
100  $data['billing_address']['line2'] = $line2;
101  }
102 
103  return $data;
104  }
105 
106  protected function getEndpoint()
107  {
108  return parent::getEndpoint() . '/vault/credit-cards';
109  }
110 }
Omnipay\PayPal\Message\RestCreateCardRequest\getEndpoint
getEndpoint()
Definition: vendor/omnipay/paypal/src/Message/RestCreateCardRequest.php:106
Omnipay\Common\Message\AbstractRequest\validate
validate()
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:226
Omnipay\PayPal\Message\RestCreateCardRequest\getData
getData()
Definition: vendor/omnipay/paypal/src/Message/RestCreateCardRequest.php:73
Omnipay\Common\Message\AbstractRequest\getCard
getCard()
Definition: lib/vendor/omnipay/common/src/Omnipay/Common/Message/AbstractRequest.php:241
Omnipay\PayPal\Message
Definition: lib/vendor/omnipay/paypal/src/Message/AbstractRequest.php:6