cd0ee91caa4f621b9a6a7d8276f34544be8ccf5f
[WP-Plugins/glm-member-db-registrations.git] /
1 <?php
2 namespace PayPal\Api;
3
4 use PayPal\Common\PPModel;
5 use PayPal\Rest\IResource;
6 use PayPal\Rest\Call;
7 use PayPal\Rest\ApiContext;
8 use PayPal\Api\CreditCard;
9 use PayPal\Transport\PPRestCall;
10
11 class CreditCard extends PPModel implements IResource {
12
13         private static $credential;
14
15         /**
16          *
17          * @deprecated. Pass ApiContext to create/get methods instead
18          */
19         public static function setCredential($credential) {
20                 self::$credential = $credential;
21         }
22
23         /**
24          * ID of the credit card being saved for later use.
25          * @param string $id
26          */
27         public function setId($id) {
28                 $this->id = $id;
29                 return $this;
30         }
31
32         /**
33          * ID of the credit card being saved for later use.
34          * @return string
35          */
36         public function getId() {
37                 return $this->id;
38         }
39
40
41         /**
42          * Card number.
43          * @param string $number
44          */
45         public function setNumber($number) {
46                 $this->number = $number;
47                 return $this;
48         }
49
50         /**
51          * Card number.
52          * @return string
53          */
54         public function getNumber() {
55                 return $this->number;
56         }
57
58
59         /**
60          * Type of the Card (eg. Visa, Mastercard, etc.).
61          * @param string $type
62          */
63         public function setType($type) {
64                 $this->type = $type;
65                 return $this;
66         }
67
68         /**
69          * Type of the Card (eg. Visa, Mastercard, etc.).
70          * @return string
71          */
72         public function getType() {
73                 return $this->type;
74         }
75
76
77         /**
78          * card expiry month with value 1 - 12.
79          * @param integer $expire_month
80          */
81         public function setExpireMonth($expire_month) {
82                 $this->expire_month = $expire_month;
83                 return $this;
84         }
85
86         /**
87          * card expiry month with value 1 - 12.
88          * @return integer
89          */
90         public function getExpireMonth() {
91                 return $this->expire_month;
92         }
93
94         /**
95          * card expiry month with value 1 - 12.
96          * @param integer $expire_month
97          * @deprecated. Instead use setExpireMonth
98          */
99         public function setExpire_month($expire_month) {
100                 $this->expire_month = $expire_month;
101                 return $this;
102         }
103         /**
104          * card expiry month with value 1 - 12.
105          * @return integer
106          * @deprecated. Instead use getExpireMonth
107          */
108         public function getExpire_month() {
109                 return $this->expire_month;
110         }
111
112         /**
113          * 4 digit card expiry year
114          * @param integer $expire_year
115          */
116         public function setExpireYear($expire_year) {
117                 $this->expire_year = $expire_year;
118                 return $this;
119         }
120
121         /**
122          * 4 digit card expiry year
123          * @return integer
124          */
125         public function getExpireYear() {
126                 return $this->expire_year;
127         }
128
129         /**
130          * 4 digit card expiry year
131          * @param integer $expire_year
132          * @deprecated. Instead use setExpireYear
133          */
134         public function setExpire_year($expire_year) {
135                 $this->expire_year = $expire_year;
136                 return $this;
137         }
138         /**
139          * 4 digit card expiry year
140          * @return integer
141          * @deprecated. Instead use getExpireYear
142          */
143         public function getExpire_year() {
144                 return $this->expire_year;
145         }
146
147         /**
148          * Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
149          * @param string $cvv2
150          */
151         public function setCvv2($cvv2) {
152                 $this->cvv2 = $cvv2;
153                 return $this;
154         }
155
156         /**
157          * Card validation code. Only supported when making a Payment but not when saving a credit card for future use.
158          * @return string
159          */
160         public function getCvv2() {
161                 return $this->cvv2;
162         }
163
164
165         /**
166          * Card holder's first name.
167          * @param string $first_name
168          */
169         public function setFirstName($first_name) {
170                 $this->first_name = $first_name;
171                 return $this;
172         }
173
174         /**
175          * Card holder's first name.
176          * @return string
177          */
178         public function getFirstName() {
179                 return $this->first_name;
180         }
181
182         /**
183          * Card holder's first name.
184          * @param string $first_name
185          * @deprecated. Instead use setFirstName
186          */
187         public function setFirst_name($first_name) {
188                 $this->first_name = $first_name;
189                 return $this;
190         }
191         /**
192          * Card holder's first name.
193          * @return string
194          * @deprecated. Instead use getFirstName
195          */
196         public function getFirst_name() {
197                 return $this->first_name;
198         }
199
200         /**
201          * Card holder's last name.
202          * @param string $last_name
203          */
204         public function setLastName($last_name) {
205                 $this->last_name = $last_name;
206                 return $this;
207         }
208
209         /**
210          * Card holder's last name.
211          * @return string
212          */
213         public function getLastName() {
214                 return $this->last_name;
215         }
216
217         /**
218          * Card holder's last name.
219          * @param string $last_name
220          * @deprecated. Instead use setLastName
221          */
222         public function setLast_name($last_name) {
223                 $this->last_name = $last_name;
224                 return $this;
225         }
226         /**
227          * Card holder's last name.
228          * @return string
229          * @deprecated. Instead use getLastName
230          */
231         public function getLast_name() {
232                 return $this->last_name;
233         }
234
235         /**
236          * Billing Address associated with this card.
237          * @param PayPal\Api\Address $billing_address
238          */
239         public function setBillingAddress($billing_address) {
240                 $this->billing_address = $billing_address;
241                 return $this;
242         }
243
244         /**
245          * Billing Address associated with this card.
246          * @return PayPal\Api\Address
247          */
248         public function getBillingAddress() {
249                 return $this->billing_address;
250         }
251
252         /**
253          * Billing Address associated with this card.
254          * @param PayPal\Api\Address $billing_address
255          * @deprecated. Instead use setBillingAddress
256          */
257         public function setBilling_address($billing_address) {
258                 $this->billing_address = $billing_address;
259                 return $this;
260         }
261         /**
262          * Billing Address associated with this card.
263          * @return PayPal\Api\Address
264          * @deprecated. Instead use getBillingAddress
265          */
266         public function getBilling_address() {
267                 return $this->billing_address;
268         }
269
270         /**
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
273          */
274         public function setPayerId($payer_id) {
275                 $this->payer_id = $payer_id;
276                 return $this;
277         }
278
279         /**
280          * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
281          * @return string
282          */
283         public function getPayerId() {
284                 return $this->payer_id;
285         }
286
287         /**
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
291          */
292         public function setPayer_id($payer_id) {
293                 $this->payer_id = $payer_id;
294                 return $this;
295         }
296         /**
297          * A unique identifier of the payer generated and provided by the facilitator. This is required when creating or using a tokenized funding instrument.
298          * @return string
299          * @deprecated. Instead use getPayerId
300          */
301         public function getPayer_id() {
302                 return $this->payer_id;
303         }
304
305         /**
306          * State of the funding instrument.
307          * @param string $state
308          */
309         public function setState($state) {
310                 $this->state = $state;
311                 return $this;
312         }
313
314         /**
315          * State of the funding instrument.
316          * @return string
317          */
318         public function getState() {
319                 return $this->state;
320         }
321
322
323         /**
324          * Date/Time until this resource can be used fund a payment.
325          * @param string $valid_until
326          */
327         public function setValidUntil($valid_until) {
328                 $this->valid_until = $valid_until;
329                 return $this;
330         }
331
332         /**
333          * Date/Time until this resource can be used fund a payment.
334          * @return string
335          */
336         public function getValidUntil() {
337                 return $this->valid_until;
338         }
339
340         /**
341          * Date/Time until this resource can be used fund a payment.
342          * @param string $valid_until
343          * @deprecated. Instead use setValidUntil
344          */
345         public function setValid_until($valid_until) {
346                 $this->valid_until = $valid_until;
347                 return $this;
348         }
349         /**
350          * Date/Time until this resource can be used fund a payment.
351          * @return string
352          * @deprecated. Instead use getValidUntil
353          */
354         public function getValid_until() {
355                 return $this->valid_until;
356         }
357
358         /**
359          * 
360          * @array
361          * @param PayPal\Api\Links $links
362          */
363         public function setLinks($links) {
364                 $this->links = $links;
365                 return $this;
366         }
367
368         /**
369          * 
370          * @return PayPal\Api\Links
371          */
372         public function getLinks() {
373                 return $this->links;
374         }
375
376
377
378         public function create($apiContext = null) {
379                 $payLoad = $this->toJSON();
380                 if ($apiContext == null) {
381                         $apiContext = new ApiContext(self::$credential);
382                 }
383                 $call = new PPRestCall($apiContext);
384                 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card", "POST", $payLoad);
385                 $this->fromJson($json);
386                 return $this;
387         }
388
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");
392                 }
393                 $payLoad = "";
394                 if ($apiContext == null) {
395                         $apiContext = new ApiContext(self::$credential);
396                 }
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);
401                 return $ret;
402         }
403
404         public function delete($apiContext = null) {
405                 if ($this->getId() == null) {
406                         throw new \InvalidArgumentException("Id cannot be null");
407                 }
408                 $payLoad = "";
409                 if ($apiContext == null) {
410                         $apiContext = new ApiContext(self::$credential);
411                 }
412                 $call = new PPRestCall($apiContext);
413                 $json = $call->execute(array('PayPal\Rest\RestHandler'), "/v1/vault/credit-card/{$this->getId()}", "DELETE", $payLoad);
414     return true;
415         }
416 }