4 use PayPal\Common\PPModel;
5 use PayPal\Rest\IResource;
7 use PayPal\Rest\ApiContext;
8 use PayPal\Api\CreditCard;
9 use PayPal\Transport\PPRestCall;
11 class CreditCard extends PPModel implements IResource {
13 private static $credential;
17 * @deprecated. Pass ApiContext to create/get methods instead
19 public static function setCredential($credential) {
20 self::$credential = $credential;
24 * ID of the credit card being saved for later use.
27 public function setId($id) {
33 * ID of the credit card being saved for later use.
36 public function getId() {
43 * @param string $number
45 public function setNumber($number) {
46 $this->number = $number;
54 public function getNumber() {
60 * Type of the Card (eg. Visa, Mastercard, etc.).
63 public function setType($type) {
69 * Type of the Card (eg. Visa, Mastercard, etc.).
72 public function getType() {
78 * card expiry month with value 1 - 12.
79 * @param integer $expire_month
81 public function setExpireMonth($expire_month) {
82 $this->expire_month = $expire_month;
87 * card expiry month with value 1 - 12.
90 public function getExpireMonth() {
91 return $this->expire_month;
95 * card expiry month with value 1 - 12.
96 * @param integer $expire_month
97 * @deprecated. Instead use setExpireMonth
99 public function setExpire_month($expire_month) {
100 $this->expire_month = $expire_month;
104 * card expiry month with value 1 - 12.
106 * @deprecated. Instead use getExpireMonth
108 public function getExpire_month() {
109 return $this->expire_month;
113 * 4 digit card expiry year
114 * @param integer $expire_year
116 public function setExpireYear($expire_year) {
117 $this->expire_year = $expire_year;
122 * 4 digit card expiry year
125 public function getExpireYear() {
126 return $this->expire_year;
130 * 4 digit card expiry year
131 * @param integer $expire_year
132 * @deprecated. Instead use setExpireYear
134 public function setExpire_year($expire_year) {
135 $this->expire_year = $expire_year;
139 * 4 digit card expiry year
141 * @deprecated. Instead use getExpireYear
143 public function getExpire_year() {
144 return $this->expire_year;
148 * Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
149 * @param string $cvv2
151 public function setCvv2($cvv2) {
157 * Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
160 public function getCvv2() {
166 * Card holder's first name.
167 * @param string $first_name
169 public function setFirstName($first_name) {
170 $this->first_name = $first_name;
175 * Card holder's first name.
178 public function getFirstName() {
179 return $this->first_name;
183 * Card holder's first name.
184 * @param string $first_name
185 * @deprecated. Instead use setFirstName
187 public function setFirst_name($first_name) {
188 $this->first_name = $first_name;
192 * Card holder's first name.
194 * @deprecated. Instead use getFirstName
196 public function getFirst_name() {
197 return $this->first_name;
201 * Card holder's last name.
202 * @param string $last_name
204 public function setLastName($last_name) {
205 $this->last_name = $last_name;
210 * Card holder's last name.
213 public function getLastName() {
214 return $this->last_name;
218 * Card holder's last name.
219 * @param string $last_name
220 * @deprecated. Instead use setLastName
222 public function setLast_name($last_name) {
223 $this->last_name = $last_name;
227 * Card holder's last name.
229 * @deprecated. Instead use getLastName
231 public function getLast_name() {
232 return $this->last_name;
236 * Billing Address associated with this card.
237 * @param PayPal\Api\Address $billing_address
239 public function setBillingAddress($billing_address) {
240 $this->billing_address = $billing_address;
245 * Billing Address associated with this card.
246 * @return PayPal\Api\Address
248 public function getBillingAddress() {
249 return $this->billing_address;
253 * Billing Address associated with this card.
254 * @param PayPal\Api\Address $billing_address
255 * @deprecated. Instead use setBillingAddress
257 public function setBilling_address($billing_address) {
258 $this->billing_address = $billing_address;
262 * Billing Address associated with this card.
263 * @return PayPal\Api\Address
264 * @deprecated. Instead use getBillingAddress
266 public function getBilling_address() {
267 return $this->billing_address;
271 * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
272 * @param string $payer_id
274 public function setPayerId($payer_id) {
275 $this->payer_id = $payer_id;
280 * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
283 public function getPayerId() {
284 return $this->payer_id;
288 * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
289 * @param string $payer_id
290 * @deprecated. Instead use setPayerId
292 public function setPayer_id($payer_id) {
293 $this->payer_id = $payer_id;
297 * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
299 * @deprecated. Instead use getPayerId
301 public function getPayer_id() {
302 return $this->payer_id;
306 * State of the funding instrument.
307 * @param string $state
309 public function setState($state) {
310 $this->state = $state;
315 * State of the funding instrument.
318 public function getState() {
324 * Date/Time until this resource can be used fund a payment.
325 * @param string $valid_until
327 public function setValidUntil($valid_until) {
328 $this->valid_until = $valid_until;
333 * Date/Time until this resource can be used fund a payment.
336 public function getValidUntil() {
337 return $this->valid_until;
341 * Date/Time until this resource can be used fund a payment.
342 * @param string $valid_until
343 * @deprecated. Instead use setValidUntil
345 public function setValid_until($valid_until) {
346 $this->valid_until = $valid_until;
350 * Date/Time until this resource can be used fund a payment.
352 * @deprecated. Instead use getValidUntil
354 public function getValid_until() {
355 return $this->valid_until;
361 * @param PayPal\Api\Links $links
363 public function setLinks($links) {
364 $this->links = $links;
370 * @return PayPal\Api\Links
372 public function getLinks() {
378 public function create($apiContext = null) {
379 $payLoad = $this->toJSON();
380 if ($apiContext == null) {
381 $apiContext = new ApiContext(self::$credential);
383 $call = new PPRestCall($apiContext);
384 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card", "POST", $payLoad);
385 $this->fromJson($json);
389 public static function get($creditCardId, $apiContext = null) {
390 if (($creditCardId == null) || (strlen($creditCardId) <= 0)) {
391 throw new \InvalidArgumentException("creditCardId cannot be null or empty");
394 if ($apiContext == null) {
395 $apiContext = new ApiContext(self::$credential);
397 $call = new PPRestCall($apiContext);
398 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/$creditCardId", "GET", $payLoad);
399 $ret = new CreditCard();
400 $ret->fromJson($json);
404 public function delete($apiContext = null) {
405 if ($this->getId() == null) {
406 throw new \InvalidArgumentException("Id cannot be null");
409 if ($apiContext == null) {
410 $apiContext = new ApiContext(self::$credential);
412 $call = new PPRestCall($apiContext);
413 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "DELETE", $payLoad);