PHP 7.4.33
Preview: CreditCard.php Size: 9.73 KB
/home/godevadmin/www/admin/braintree/final/braintree_php-master/lib/Braintree/CreditCard.php

<?php
namespace Braintree;

/**
 * Braintree CreditCard module
 * Creates and manages Braintree CreditCards
 *
 * <b>== More information ==</b>
 *
 * For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}<br />
 * For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api}
 *
 * @package    Braintree
 * @category   Resources
 * @copyright  2015 Braintree, a division of PayPal, Inc.
 *
 * @property-read string $billingAddress
 * @property-read string $bin
 * @property-read string $cardType
 * @property-read string $cardholderName
 * @property-read string $createdAt
 * @property-read string $customerId
 * @property-read string $expirationDate
 * @property-read string $expirationMonth
 * @property-read string $expirationYear
 * @property-read string $imageUrl
 * @property-read string $last4
 * @property-read string $maskedNumber
 * @property-read string $token
 * @property-read string $updatedAt
 */
class CreditCard extends Base
{
    // Card Type
    const AMEX = 'American Express';
    const CARTE_BLANCHE = 'Carte Blanche';
    const CHINA_UNION_PAY = 'China UnionPay';
    const DINERS_CLUB_INTERNATIONAL = 'Diners Club';
    const DISCOVER = 'Discover';
    const JCB = 'JCB';
    const LASER = 'Laser';
    const MAESTRO = 'Maestro';
    const MASTER_CARD = 'MasterCard';
    const SOLO = 'Solo';
    const SWITCH_TYPE = 'Switch';
    const VISA = 'Visa';
    const UNKNOWN = 'Unknown';

    // Credit card origination location
	const INTERNATIONAL = "international";
	const US            = "us";

    const PREPAID_YES = 'Yes';
    const PREPAID_NO = 'No';
    const PREPAID_UNKNOWN = 'Unknown';

    const PAYROLL_YES = 'Yes';
    const PAYROLL_NO = 'No';
    const PAYROLL_UNKNOWN = 'Unknown';

    const HEALTHCARE_YES = 'Yes';
    const HEALTHCARE_NO = 'No';
    const HEALTHCARE_UNKNOWN = 'Unknown';

    const DURBIN_REGULATED_YES = 'Yes';
    const DURBIN_REGULATED_NO = 'No';
    const DURBIN_REGULATED_UNKNOWN = 'Unknown';

    const DEBIT_YES = 'Yes';
    const DEBIT_NO = 'No';
    const DEBIT_UNKNOWN = 'Unknown';

    const COMMERCIAL_YES = 'Yes';
    const COMMERCIAL_NO = 'No';
    const COMMERCIAL_UNKNOWN = 'Unknown';

    const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown";
    const ISSUING_BANK_UNKNOWN = "Unknown";
    const PRODUCT_ID_UNKNOWN = "Unknown";

    /* instance methods */
    /**
     * returns false if default is null or false
     *
     * @return boolean
     */
    public function isDefault()
    {
        return $this->default;
    }

    /**
     * checks whether the card is expired based on the current date
     *
     * @return boolean
     */
    public function isExpired()
    {
        return $this->expired;
    }

    /**
     * checks whether the card is associated with venmo sdk
     *
     * @return boolean
     */
    public function isVenmoSdk()
    {
        return $this->venmoSdk;
    }

    /**
     * sets instance properties from an array of values
     *
     * @access protected
     * @param array $creditCardAttribs array of creditcard data
     * @return void
     */
    protected function _initialize($creditCardAttribs)
    {
        // set the attributes
        $this->_attributes = $creditCardAttribs;

        // map each address into its own object
        $billingAddress = isset($creditCardAttribs['billingAddress']) ?
            Address::factory($creditCardAttribs['billingAddress']) :
            null;

        $subscriptionArray = [];
        if (isset($creditCardAttribs['subscriptions'])) {
            foreach ($creditCardAttribs['subscriptions'] AS $subscription) {
                $subscriptionArray[] = Subscription::factory($subscription);
            }
        }

        $this->_set('subscriptions', $subscriptionArray);
        $this->_set('billingAddress', $billingAddress);
        $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear);
        $this->_set('maskedNumber', $this->bin . '******' . $this->last4);

        if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) {
            $verifications = $creditCardAttribs['verifications'];
            usort($verifications, [$this, '_compareCreatedAtOnVerifications']);

            $this->_set('verification', CreditCardVerification::factory($verifications[0]));
        }
    }

    private function _compareCreatedAtOnVerifications($verificationAttrib1, $verificationAttrib2)
    {
        return ($verificationAttrib2['createdAt'] < $verificationAttrib1['createdAt']) ? -1 : 1;
    }

    /**
     * returns false if comparing object is not a CreditCard,
     * or is a CreditCard with a different id
     *
     * @param object $otherCreditCard customer to compare against
     * @return boolean
     */
    public function isEqual($otherCreditCard)
    {
        return !($otherCreditCard instanceof self) ? false : $this->token === $otherCreditCard->token;
    }

    /**
     * create a printable representation of the object as:
     * ClassName[property=value, property=value]
     * @return string
     */
    public function  __toString()
    {
        return __CLASS__ . '[' .
                Util::attributesToString($this->_attributes) .']';
    }

    /**
     *  factory method: returns an instance of CreditCard
     *  to the requesting method, with populated properties
     *
     * @ignore
     * @return CreditCard
     */
    public static function factory($attributes)
    {
        $defaultAttributes = [
            'bin' => '',
            'expirationMonth'    => '',
            'expirationYear'    => '',
            'last4'  => '',
        ];

        $instance = new self();
        $instance->_initialize(array_merge($defaultAttributes, $attributes));
        return $instance;
    }


    // static methods redirecting to gateway

    public static function create($attribs)
    {
        return Configuration::gateway()->creditCard()->create($attribs);
    }

    public static function createNoValidate($attribs)
    {
        return Configuration::gateway()->creditCard()->createNoValidate($attribs);
    }

    public static function createFromTransparentRedirect($queryString)
    {
        return Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString);
    }

    public static function createCreditCardUrl()
    {
        return Configuration::gateway()->creditCard()->createCreditCardUrl();
    }

    public static function expired()
    {
        return Configuration::gateway()->creditCard()->expired();
    }

    public static function fetchExpired($ids)
    {
        return Configuration::gateway()->creditCard()->fetchExpired($ids);
    }

    public static function expiringBetween($startDate, $endDate)
    {
        return Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate);
    }

    public static function fetchExpiring($startDate, $endDate, $ids)
    {
        return Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids);
    }

    public static function find($token)
    {
        return Configuration::gateway()->creditCard()->find($token);
    }

    public static function fromNonce($nonce)
    {
        return Configuration::gateway()->creditCard()->fromNonce($nonce);
    }

    public static function credit($token, $transactionAttribs)
    {
        return Configuration::gateway()->creditCard()->credit($token, $transactionAttribs);
    }

    public static function creditNoValidate($token, $transactionAttribs)
    {
        return Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs);
    }

    public static function sale($token, $transactionAttribs)
    {
        return Configuration::gateway()->creditCard()->sale($token, $transactionAttribs);
    }

    public static function saleNoValidate($token, $transactionAttribs)
    {
        return Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs);
    }

    public static function update($token, $attributes)
    {
        return Configuration::gateway()->creditCard()->update($token, $attributes);
    }

    public static function updateNoValidate($token, $attributes)
    {
        return Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes);
    }

    public static function updateCreditCardUrl()
    {
        return Configuration::gateway()->creditCard()->updateCreditCardUrl();
    }

    public static function updateFromTransparentRedirect($queryString)
    {
        return Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString);
    }

    public static function delete($token)
    {
        return Configuration::gateway()->creditCard()->delete($token);
    }

    /** @return array */
    public static function allCardTypes()
    {
        return [
            CreditCard::AMEX,
            CreditCard::CARTE_BLANCHE,
            CreditCard::CHINA_UNION_PAY,
            CreditCard::DINERS_CLUB_INTERNATIONAL,
            CreditCard::DISCOVER,
            CreditCard::JCB,
            CreditCard::LASER,
            CreditCard::MAESTRO,
            CreditCard::MASTER_CARD,
            CreditCard::SOLO,
            CreditCard::SWITCH_TYPE,
            CreditCard::VISA,
            CreditCard::UNKNOWN
        ];
    }
}
class_alias('Braintree\CreditCard', 'Braintree_CreditCard');

Directory Contents

Dirs: 9 × Files: 89

Name Size Perms Modified Actions
Dispute DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
Error DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
Exception DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
Result DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
Test DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
Xml DIR
- drwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.12 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.42 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
579 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1005 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.10 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
9.22 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.38 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.65 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.79 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.69 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.17 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.38 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.88 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.46 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
15.30 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.33 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
9.73 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
15.39 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.34 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.32 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.52 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
11.98 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
19.88 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.64 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
134 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.69 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.45 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
752 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
462 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
775 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.59 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
259 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.78 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
303 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
696 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.65 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
6.49 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.90 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
431 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
432 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
988 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.17 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
5.80 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.34 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
553 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
946 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.01 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
839 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.00 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
818 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.61 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
691 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
430 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1009 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
564 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.12 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
11.11 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.42 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.70 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.81 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
5.34 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.33 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
854 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
822 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.54 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
655 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.11 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.88 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
486 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
4.06 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
7.20 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.60 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.46 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
269 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
690 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
19.16 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
17.70 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
7.79 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.13 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
9.12 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
1.71 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.57 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
3.05 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
14.96 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
2.01 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
688 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
5.46 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
13.65 KB lrwxrwxr-x 2023-11-07 19:59:46
Edit Download
760 B lrwxrwxr-x 2023-11-07 19:59:46
Edit Download

If ZipArchive is unavailable, a .tar will be created (no compression).