Overview
  • Namespace
  • Class

Namespaces

  • PayPal
    • Api
    • Auth
    • Cache
    • Common
    • Converter
    • Core
    • Exception
    • Handler
    • Log
    • Rest
    • Security
    • Transport
    • Validation

Classes

  • PayPal\Api\Address
  • PayPal\Api\Agreement
  • PayPal\Api\AgreementDetails
  • PayPal\Api\AgreementStateDescriptor
  • PayPal\Api\AgreementTransaction
  • PayPal\Api\AgreementTransactions
  • PayPal\Api\AlternatePayment
  • PayPal\Api\Amount
  • PayPal\Api\Authorization
  • PayPal\Api\BankAccount
  • PayPal\Api\BankAccountsList
  • PayPal\Api\BankToken
  • PayPal\Api\BaseAddress
  • PayPal\Api\Billing
  • PayPal\Api\BillingAgreementToken
  • PayPal\Api\BillingInfo
  • PayPal\Api\CancelNotification
  • PayPal\Api\Capture
  • PayPal\Api\CarrierAccount
  • PayPal\Api\CarrierAccountToken
  • PayPal\Api\CartBase
  • PayPal\Api\ChargeModel
  • PayPal\Api\Cost
  • PayPal\Api\CountryCode
  • PayPal\Api\CreateProfileResponse
  • PayPal\Api\Credit
  • PayPal\Api\CreditCard
  • PayPal\Api\CreditCardHistory
  • PayPal\Api\CreditCardList
  • PayPal\Api\CreditCardToken
  • PayPal\Api\CreditFinancingOffered
  • PayPal\Api\Currency
  • PayPal\Api\CurrencyConversion
  • PayPal\Api\CustomAmount
  • PayPal\Api\DetailedRefund
  • PayPal\Api\Details
  • PayPal\Api\Error
  • PayPal\Api\ErrorDetails
  • PayPal\Api\ExtendedBankAccount
  • PayPal\Api\ExternalFunding
  • PayPal\Api\FileAttachment
  • PayPal\Api\FlowConfig
  • PayPal\Api\FmfDetails
  • PayPal\Api\FundingDetail
  • PayPal\Api\FundingInstrument
  • PayPal\Api\FundingOption
  • PayPal\Api\FundingSource
  • PayPal\Api\FuturePayment
  • PayPal\Api\HyperSchema
  • PayPal\Api\Image
  • PayPal\Api\Incentive
  • PayPal\Api\InputFields
  • PayPal\Api\InstallmentInfo
  • PayPal\Api\InstallmentOption
  • PayPal\Api\Invoice
  • PayPal\Api\InvoiceAddress
  • PayPal\Api\InvoiceItem
  • PayPal\Api\InvoiceNumber
  • PayPal\Api\InvoiceSearchResponse
  • PayPal\Api\Item
  • PayPal\Api\ItemList
  • PayPal\Api\Links
  • PayPal\Api\Measurement
  • PayPal\Api\MerchantInfo
  • PayPal\Api\MerchantPreferences
  • PayPal\Api\Metadata
  • PayPal\Api\NameValuePair
  • PayPal\Api\Notification
  • PayPal\Api\OpenIdAddress
  • PayPal\Api\OpenIdError
  • PayPal\Api\OpenIdSession
  • PayPal\Api\OpenIdTokeninfo
  • PayPal\Api\OpenIdUserinfo
  • PayPal\Api\Order
  • PayPal\Api\OverrideChargeModel
  • PayPal\Api\Participant
  • PayPal\Api\Patch
  • PayPal\Api\PatchRequest
  • PayPal\Api\Payee
  • PayPal\Api\Payer
  • PayPal\Api\PayerInfo
  • PayPal\Api\Payment
  • PayPal\Api\PaymentCard
  • PayPal\Api\PaymentCardToken
  • PayPal\Api\PaymentDefinition
  • PayPal\Api\PaymentDetail
  • PayPal\Api\PaymentExecution
  • PayPal\Api\PaymentHistory
  • PayPal\Api\PaymentInstruction
  • PayPal\Api\PaymentOptions
  • PayPal\Api\PaymentSummary
  • PayPal\Api\PaymentTerm
  • PayPal\Api\Payout
  • PayPal\Api\PayoutBatch
  • PayPal\Api\PayoutBatchHeader
  • PayPal\Api\PayoutItem
  • PayPal\Api\PayoutItemDetails
  • PayPal\Api\PayoutSenderBatchHeader
  • PayPal\Api\Phone
  • PayPal\Api\Plan
  • PayPal\Api\PlanList
  • PayPal\Api\PotentialPayerInfo
  • PayPal\Api\Presentation
  • PayPal\Api\PrivateLabelCard
  • PayPal\Api\ProcessorResponse
  • PayPal\Api\RecipientBankingInstruction
  • PayPal\Api\RedirectUrls
  • PayPal\Api\Refund
  • PayPal\Api\RefundDetail
  • PayPal\Api\RefundRequest
  • PayPal\Api\RelatedResources
  • PayPal\Api\Sale
  • PayPal\Api\Search
  • PayPal\Api\ShippingAddress
  • PayPal\Api\ShippingCost
  • PayPal\Api\ShippingInfo
  • PayPal\Api\Tax
  • PayPal\Api\Template
  • PayPal\Api\TemplateData
  • PayPal\Api\Templates
  • PayPal\Api\TemplateSettings
  • PayPal\Api\TemplateSettingsMetadata
  • PayPal\Api\Terms
  • PayPal\Api\Transaction
  • PayPal\Api\TransactionBase
  • PayPal\Api\Transactions
  • PayPal\Api\VerifyWebhookSignature
  • PayPal\Api\VerifyWebhookSignatureResponse
  • PayPal\Api\Webhook
  • PayPal\Api\WebhookEvent
  • PayPal\Api\WebhookEventList
  • PayPal\Api\WebhookEventType
  • PayPal\Api\WebhookEventTypeList
  • PayPal\Api\WebhookList
  • PayPal\Api\WebProfile
  • PayPal\Auth\OAuthTokenCredential
  • PayPal\Cache\AuthorizationCache
  • PayPal\Common\ArrayUtil
  • PayPal\Common\PayPalModel
  • PayPal\Common\PayPalResourceModel
  • PayPal\Common\PayPalUserAgent
  • PayPal\Common\ReflectionUtil
  • PayPal\Converter\FormatConverter
  • PayPal\Core\PayPalConfigManager
  • PayPal\Core\PayPalConstants
  • PayPal\Core\PayPalCredentialManager
  • PayPal\Core\PayPalHttpConfig
  • PayPal\Core\PayPalHttpConnection
  • PayPal\Core\PayPalLoggingManager
  • PayPal\Handler\OauthHandler
  • PayPal\Handler\RestHandler
  • PayPal\Log\PayPalDefaultLogFactory
  • PayPal\Log\PayPalLogger
  • PayPal\Rest\ApiContext
  • PayPal\Security\Cipher
  • PayPal\Transport\PayPalRestCall
  • PayPal\Validation\ArgumentValidator
  • PayPal\Validation\JsonValidator
  • PayPal\Validation\NumericValidator
  • PayPal\Validation\UrlValidator

Interfaces

  • PayPal\Handler\IPayPalHandler
  • PayPal\Log\PayPalLogFactory
  • PayPal\Rest\IResource

Exceptions

  • PayPal\Exception\PayPalConfigurationException
  • PayPal\Exception\PayPalConnectionException
  • PayPal\Exception\PayPalInvalidCredentialException
  • PayPal\Exception\PayPalMissingCredentialException
  1 <?php
  2 
  3 namespace PayPal\Api;
  4 
  5 use PayPal\Common\PayPalResourceModel;
  6 use PayPal\Rest\ApiContext;
  7 use PayPal\Transport\PayPalRestCall;
  8 use PayPal\Validation\ArgumentValidator;
  9 
 10 /**
 11  * Class CreditCard
 12  *
 13  * @package    PayPal\Api
 14  *
 15  * @property string              number
 16  * @property string              type
 17  * @property int                 expire_month
 18  * @property int                 expire_year
 19  * @property string              cvv2
 20  * @property string              first_name
 21  * @property string              last_name
 22  * @property \PayPal\Api\Address billing_address
 23  * @property string              external_customer_id
 24  * @property string              state
 25  * @property string              valid_until
 26  * @property \PayPal\Api\Links[] links
 27  */
 28 class CreditCard extends PayPalResourceModel
 29 {
 30     /**
 31      * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.**
 32      *
 33      * @deprecated Not publicly available
 34      * @param string $id
 35      *
 36      * @return $this
 37      */
 38     public function setId($id)
 39     {
 40         $this->id = $id;
 41         return $this;
 42     }
 43 
 44     /**
 45      * ID of the credit card. This ID is provided in the response when storing credit cards. **Required if using a stored credit card.**
 46      *
 47      * @deprecated Not publicly available
 48      * @return string
 49      */
 50     public function getId()
 51     {
 52         return $this->id;
 53     }
 54 
 55     /**
 56      * Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.*
 57      *
 58      * @param string $number
 59      *
 60      * @return $this
 61      */
 62     public function setNumber($number)
 63     {
 64         $this->number = $number;
 65         return $this;
 66     }
 67 
 68     /**
 69      * Credit card number. Numeric characters only with no spaces or punctuation. The string must conform with modulo and length required by each credit card type. *Redacted in responses.*
 70      *
 71      * @return string
 72      */
 73     public function getNumber()
 74     {
 75         return $this->number;
 76     }
 77 
 78     /**
 79      * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`
 80      *
 81      * @param string $type
 82      *
 83      * @return $this
 84      */
 85     public function setType($type)
 86     {
 87         $this->type = $type;
 88         return $this;
 89     }
 90 
 91     /**
 92      * Credit card type. Valid types are: `visa`, `mastercard`, `discover`, `amex`
 93      *
 94      * @return string
 95      */
 96     public function getType()
 97     {
 98         return $this->type;
 99     }
100 
101     /**
102      * Expiration month with no leading zero. Acceptable values are 1 through 12.
103      *
104      * @param int $expire_month
105      *
106      * @return $this
107      */
108     public function setExpireMonth($expire_month)
109     {
110         $this->expire_month = $expire_month;
111         return $this;
112     }
113 
114     /**
115      * Expiration month with no leading zero. Acceptable values are 1 through 12.
116      *
117      * @return int
118      */
119     public function getExpireMonth()
120     {
121         return $this->expire_month;
122     }
123 
124     /**
125      * 4-digit expiration year.
126      *
127      * @param int $expire_year
128      *
129      * @return $this
130      */
131     public function setExpireYear($expire_year)
132     {
133         $this->expire_year = $expire_year;
134         return $this;
135     }
136 
137     /**
138      * 4-digit expiration year.
139      *
140      * @return int
141      */
142     public function getExpireYear()
143     {
144         return $this->expire_year;
145     }
146 
147     /**
148      * 3-4 digit card validation code.
149      *
150      * @param string $cvv2
151      *
152      * @return $this
153      */
154     public function setCvv2($cvv2)
155     {
156         $this->cvv2 = $cvv2;
157         return $this;
158     }
159 
160     /**
161      * 3-4 digit card validation code.
162      *
163      * @return string
164      */
165     public function getCvv2()
166     {
167         return $this->cvv2;
168     }
169 
170     /**
171      * Cardholder's first name.
172      *
173      * @param string $first_name
174      *
175      * @return $this
176      */
177     public function setFirstName($first_name)
178     {
179         $this->first_name = $first_name;
180         return $this;
181     }
182 
183     /**
184      * Cardholder's first name.
185      *
186      * @return string
187      */
188     public function getFirstName()
189     {
190         return $this->first_name;
191     }
192 
193     /**
194      * Cardholder's last name.
195      *
196      * @param string $last_name
197      *
198      * @return $this
199      */
200     public function setLastName($last_name)
201     {
202         $this->last_name = $last_name;
203         return $this;
204     }
205 
206     /**
207      * Cardholder's last name.
208      *
209      * @return string
210      */
211     public function getLastName()
212     {
213         return $this->last_name;
214     }
215 
216     /**
217      * Billing Address associated with this card.
218      *
219      * @param \PayPal\Api\Address $billing_address
220      *
221      * @return $this
222      */
223     public function setBillingAddress($billing_address)
224     {
225         $this->billing_address = $billing_address;
226         return $this;
227     }
228 
229     /**
230      * Billing Address associated with this card.
231      *
232      * @return \PayPal\Api\Address
233      */
234     public function getBillingAddress()
235     {
236         return $this->billing_address;
237     }
238 
239     /**
240      * A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.**
241      *
242      * @param string $external_customer_id
243      *
244      * @return $this
245      */
246     public function setExternalCustomerId($external_customer_id)
247     {
248         $this->external_customer_id = $external_customer_id;
249         return $this;
250     }
251 
252     /**
253      * A unique identifier of the customer to whom this bank account belongs. Generated and provided by the facilitator. **This is now used in favor of `payer_id` when creating or using a stored funding instrument in the vault.**
254      *
255      * @return string
256      */
257     public function getExternalCustomerId()
258     {
259         return $this->external_customer_id;
260     }
261 
262     /**
263      * A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
264      *
265      * @param string $merchant_id
266      *
267      * @return $this
268      */
269     public function setMerchantId($merchant_id)
270     {
271         $this->merchant_id = $merchant_id;
272         return $this;
273     }
274 
275     /**
276      * A user provided, optional convenvience field that functions as a unique identifier for the merchant on behalf of whom this credit card is being stored for. Note that this has no relation to PayPal merchant id
277      *
278      * @return string
279      */
280     public function getMerchantId()
281     {
282         return $this->merchant_id;
283     }
284 
285     /**
286      * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
287      *
288      * @deprecated This is being deprecated in favor of the `external_customer_id` property.
289      * @param string $payer_id
290      *
291      * @return $this
292      */
293     public function setPayerId($payer_id)
294     {
295         $this->payer_id = $payer_id;
296         return $this;
297     }
298 
299     /**
300      * A unique identifier that you can assign and track when storing a credit card or using a stored credit card. This ID can help to avoid unintentional use or misuse of credit cards. This ID can be any value you would like to associate with the saved card, such as a UUID, username, or email address. Required when using a stored credit card if a payer_id was originally provided when storing the credit card in vault.
301      *
302      * @deprecated This is being deprecated in favor of the `external_customer_id` property.
303      * @return string
304      */
305     public function getPayerId()
306     {
307         return $this->payer_id;
308     }
309 
310     /**
311      * A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
312      *
313      * @param string $external_card_id
314      *
315      * @return $this
316      */
317     public function setExternalCardId($external_card_id)
318     {
319         $this->external_card_id = $external_card_id;
320         return $this;
321     }
322 
323     /**
324      * A unique identifier of the bank account resource. Generated and provided by the facilitator so it can be used to restrict the usage of the bank account to the specific merchant.
325      *
326      * @return string
327      */
328     public function getExternalCardId()
329     {
330         return $this->external_card_id;
331     }
332 
333     /**
334      * State of the credit card funding instrument.
335      * Valid Values: ["expired", "ok"]
336      *
337      * @param string $state
338      *
339      * @return $this
340      */
341     public function setState($state)
342     {
343         $this->state = $state;
344         return $this;
345     }
346 
347     /**
348      * State of the credit card funding instrument.
349      *
350      * @return string
351      */
352     public function getState()
353     {
354         return $this->state;
355     }
356 
357     /**
358      * Funding instrument expiration date.
359      *
360      * @param string $create_time
361      *
362      * @return $this
363      */
364     public function setCreateTime($create_time)
365     {
366         $this->create_time = $create_time;
367         return $this;
368     }
369 
370     /**
371      * Resource creation time  as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates creation time.
372      *
373      * @return string
374      */
375     public function getCreateTime()
376     {
377         return $this->create_time;
378     }
379 
380     /**
381      * Resource creation time  as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
382      *
383      * @param string $update_time
384      *
385      * @return $this
386      */
387     public function setUpdateTime($update_time)
388     {
389         $this->update_time = $update_time;
390         return $this;
391     }
392 
393     /**
394      * Resource creation time  as ISO8601 date-time format (ex: 1994-11-05T13:15:30Z) that indicates the updation time.
395      *
396      * @return string
397      */
398     public function getUpdateTime()
399     {
400         return $this->update_time;
401     }
402 
403     /**
404      * Date/Time until this resource can be used fund a payment.
405      *
406      * @param string $valid_until
407      *
408      * @return $this
409      */
410     public function setValidUntil($valid_until)
411     {
412         $this->valid_until = $valid_until;
413         return $this;
414     }
415 
416     /**
417      * Funding instrument expiration date.
418      *
419      * @return string
420      */
421     public function getValidUntil()
422     {
423         return $this->valid_until;
424     }
425 
426     /**
427      * Creates a new Credit Card Resource (aka Tokenize).
428      *
429      * @param ApiContext     $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
430      * @param PayPalRestCall $restCall   is the Rest Call Service that is used to make rest calls
431      * @return CreditCard
432      */
433     public function create($apiContext = null, $restCall = null)
434     {
435         $payLoad = $this->toJSON();
436         $json = self::executeCall(
437             "/v1/vault/credit-cards",
438             "POST",
439             $payLoad,
440             null,
441             $apiContext,
442             $restCall
443         );
444         $this->fromJson($json);
445         return $this;
446     }
447 
448     /**
449      * Obtain the Credit Card resource for the given identifier.
450      *
451      * @param string         $creditCardId
452      * @param ApiContext     $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
453      * @param PayPalRestCall $restCall   is the Rest Call Service that is used to make rest calls
454      * @return CreditCard
455      */
456     public static function get($creditCardId, $apiContext = null, $restCall = null)
457     {
458         ArgumentValidator::validate($creditCardId, 'creditCardId');
459         $payLoad = "";
460         $json = self::executeCall(
461             "/v1/vault/credit-cards/$creditCardId",
462             "GET",
463             $payLoad,
464             null,
465             $apiContext,
466             $restCall
467         );
468         $ret = new CreditCard();
469         $ret->fromJson($json);
470         return $ret;
471     }
472 
473     /**
474      * Delete the Credit Card resource for the given identifier.
475      *
476      * @param ApiContext     $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
477      * @param PayPalRestCall $restCall   is the Rest Call Service that is used to make rest calls
478      * @return bool
479      */
480     public function delete($apiContext = null, $restCall = null)
481     {
482         ArgumentValidator::validate($this->getId(), "Id");
483         $payLoad = "";
484         self::executeCall(
485             "/v1/vault/credit-cards/{$this->getId()}",
486             "DELETE",
487             $payLoad,
488             null,
489             $apiContext,
490             $restCall
491         );
492         return true;
493     }
494 
495     /**
496      * Update information in a previously saved card. Only the modified fields need to be passed in the request.
497      *
498      * @param PatchRequest   $patchRequest
499      * @param ApiContext     $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
500      * @param PayPalRestCall $restCall   is the Rest Call Service that is used to make rest calls
501      * @return CreditCard
502      */
503     public function update($patchRequest, $apiContext = null, $restCall = null)
504     {
505         ArgumentValidator::validate($this->getId(), "Id");
506         ArgumentValidator::validate($patchRequest, 'patch');
507         $payload = $patchRequest->toJSON();
508         $json = self::executeCall(
509             "/v1/vault/credit-cards/{$this->getId()}",
510             "PATCH",
511             $payload,
512             null,
513             $apiContext,
514             $restCall
515         );
516         $this->fromJson($json);
517         return $this;
518     }
519 
520     /**
521      * Retrieves a list of Credit Card resources.
522      *
523      * @param array          $params
524      * @param ApiContext     $apiContext is the APIContext for this call. It can be used to pass dynamic configuration and credentials.
525      * @param PayPalRestCall $restCall   is the Rest Call Service that is used to make rest calls
526      * @return CreditCardList
527      */
528     public static function all($params, $apiContext = null, $restCall = null)
529     {
530         if (is_null($params)) {
531             $params = array();
532         }
533         ArgumentValidator::validate($params, 'params');
534         $payLoad = "";
535         $allowedParams = array(
536             'page_size' => 1,
537             'page' => 1,
538             'start_time' => 1,
539             'end_time' => 1,
540             'sort_order' => 1,
541             'sort_by' => 1,
542             'merchant_id' => 1,
543             'external_card_id' => 1,
544             'external_customer_id' => 1,
545             'total_required' => 1
546         );
547         $json = self::executeCall(
548             "/v1/vault/credit-cards" . "?" . http_build_query(array_intersect_key($params, $allowedParams)),
549             "GET",
550             $payLoad,
551             null,
552             $apiContext,
553             $restCall
554         );
555         $ret = new CreditCardList();
556         $ret->fromJson($json);
557         return $ret;
558     }
559 
560 }
561 
API documentation generated by ApiGen