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

<?php
namespace Braintree;

/**
 * Braintree Customer module
 * Creates and manages Customers
 *
 * <b>== More information ==</b>
 *
 * For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
 *
 * @package    Braintree
 * @category   Resources
 * @copyright  2015 Braintree, a division of PayPal, Inc.
 *
 * @property-read array  $addresses
 * @property-read array  $paymentMethods
 * @property-read string $company
 * @property-read string $createdAt
 * @property-read array  $creditCards
 * @property-read array  $paypalAccounts
 * @property-read array  $applePayCards
 * @property-read array  $androidPayCards
 * @property-read array  $amexExpressCheckoutCards
 * @property-read array  $venmoAccounts
 * @property-read array  $coinbaseAccounts
 * @property-read array  $customFields custom fields passed with the request
 * @property-read string $email
 * @property-read string $fax
 * @property-read string $firstName
 * @property-read string $id
 * @property-read string $lastName
 * @property-read string $phone
 * @property-read string $updatedAt
 * @property-read string $website
 */
class Customer extends Base
{
    /**
     *
     * @return Customer[]
     */
    public static function all()
    {
        return Configuration::gateway()->customer()->all();
    }

    /**
     *
     * @param string $query
     * @param int[] $ids
     * @return Customer|Customer[]
     */
    public static function fetch($query, $ids)
    {
        return Configuration::gateway()->customer()->fetch($query, $ids);
    }

    /**
     *
     * @param array $attribs
     * @return Result\Successful|Result\Error
     */
    public static function create($attribs = [])
    {
        return Configuration::gateway()->customer()->create($attribs);
    }

    /**
     *
     * @param array $attribs
     * @return Customer
     */
    public static function createNoValidate($attribs = [])
    {
        return Configuration::gateway()->customer()->createNoValidate($attribs);
    }

    /**
     * @deprecated since version 2.3.0
     * @param string $queryString
     * @return Result\Successful
     */
    public static function createFromTransparentRedirect($queryString)
    {
        return Configuration::gateway()->customer()->createFromTransparentRedirect($queryString);
    }

    /**
     * @deprecated since version 2.3.0
     * @return string
     */
    public static function createCustomerUrl()
    {
        return Configuration::gateway()->customer()->createCustomerUrl();
    }

    /**
     *
     * @throws Exception\NotFound
     * @param string $id customer id
     * @return Customer
     */
    public static function find($id)
    {
        return Configuration::gateway()->customer()->find($id);
    }

    /**
     *
     * @param int $customerId
     * @param array $transactionAttribs
     * @return Result\Successful|Result\Error
     */
    public static function credit($customerId, $transactionAttribs)
    {
        return Configuration::gateway()->customer()->credit($customerId, $transactionAttribs);
    }

    /**
     *
     * @throws Exception\ValidationError
     * @param type $customerId
     * @param type $transactionAttribs
     * @return Transaction
     */
    public static function creditNoValidate($customerId, $transactionAttribs)
    {
        return Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs);
    }

    /**
     *
     * @throws Exception on invalid id or non-200 http response code
     * @param int $customerId
     * @return Result\Successful
     */
    public static function delete($customerId)
    {
        return Configuration::gateway()->customer()->delete($customerId);
    }

    /**
     *
     * @param int $customerId
     * @param array $transactionAttribs
     * @return Transaction
     */
    public static function sale($customerId, $transactionAttribs)
    {
        return Configuration::gateway()->customer()->sale($customerId, $transactionAttribs);
    }

    /**
     *
     * @param int $customerId
     * @param array $transactionAttribs
     * @return Transaction
     */
    public static function saleNoValidate($customerId, $transactionAttribs)
    {
        return Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs);
    }

    /**
     *
     * @throws InvalidArgumentException
     * @param string $query
     * @return ResourceCollection
     */
    public static function search($query)
    {
        return Configuration::gateway()->customer()->search($query);
    }

    /**
     *
     * @throws Exception\Unexpected
     * @param int $customerId
     * @param array $attributes
     * @return Result\Successful|Result\Error
     */
    public static function update($customerId, $attributes)
    {
        return Configuration::gateway()->customer()->update($customerId, $attributes);
    }

    /**
     *
     * @throws Exception\Unexpected
     * @param int $customerId
     * @param array $attributes
     * @return CustomerGateway
     */
    public static function updateNoValidate($customerId, $attributes)
    {
        return Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes);
    }

    /**
     *
     * @deprecated since version 2.3.0
     * @return string
     */
    public static function updateCustomerUrl()
    {
        return Configuration::gateway()->customer()->updateCustomerUrl();
    }

    /**
     *
     * @deprecated since version 2.3.0
     * @param string $queryString
     * @return Result\Successful|Result\Error
     */
    public static function updateFromTransparentRedirect($queryString)
    {
        return Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString);
    }

    /* instance methods */

    /**
     * sets instance properties from an array of values
     *
     * @ignore
     * @access protected
     * @param array $customerAttribs array of customer data
     */
    protected function _initialize($customerAttribs)
    {
        $this->_attributes = $customerAttribs;

        $addressArray = [];
        if (isset($customerAttribs['addresses'])) {

            foreach ($customerAttribs['addresses'] AS $address) {
                $addressArray[] = Address::factory($address);
            }
        }
        $this->_set('addresses', $addressArray);

        $creditCardArray = [];
        if (isset($customerAttribs['creditCards'])) {
            foreach ($customerAttribs['creditCards'] AS $creditCard) {
                $creditCardArray[] = CreditCard::factory($creditCard);
            }
        }
        $this->_set('creditCards', $creditCardArray);

        $coinbaseAccountArray = [];
        if (isset($customerAttribs['coinbaseAccounts'])) {
            foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) {
                $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount);
            }
        }
        $this->_set('coinbaseAccounts', $coinbaseAccountArray);

        $paypalAccountArray = [];
        if (isset($customerAttribs['paypalAccounts'])) {
            foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) {
                $paypalAccountArray[] = PayPalAccount::factory($paypalAccount);
            }
        }
        $this->_set('paypalAccounts', $paypalAccountArray);

        $applePayCardArray = [];
        if (isset($customerAttribs['applePayCards'])) {
            foreach ($customerAttribs['applePayCards'] AS $applePayCard) {
                $applePayCardArray[] = ApplePayCard::factory($applePayCard);
            }
        }
        $this->_set('applePayCards', $applePayCardArray);

        $androidPayCardArray = [];
        if (isset($customerAttribs['androidPayCards'])) {
            foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) {
                $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard);
            }
        }
        $this->_set('androidPayCards', $androidPayCardArray);

        $amexExpressCheckoutCardArray = [];
        if (isset($customerAttribs['amexExpressCheckoutCards'])) {
            foreach ($customerAttribs['amexExpressCheckoutCards'] AS $amexExpressCheckoutCard) {
                $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard);
            }
        }
        $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray);

        $venmoAccountArray = array();
        if (isset($customerAttribs['venmoAccounts'])) {
            foreach ($customerAttribs['venmoAccounts'] AS $venmoAccount) {
                $venmoAccountArray[] = VenmoAccount::factory($venmoAccount);
            }
        }
        $this->_set('venmoAccounts', $venmoAccountArray);

        $usBankAccountArray = array();
        if (isset($customerAttribs['usBankAccounts'])) {
            foreach ($customerAttribs['usBankAccounts'] AS $usBankAccount) {
                $usBankAccountArray[] = UsBankAccount::factory($usBankAccount);
            }
        }
        $this->_set('usBankAccounts', $usBankAccountArray);

        $this->_set('paymentMethods', array_merge(
            $this->creditCards,
            $this->paypalAccounts,
            $this->applePayCards,
            $this->coinbaseAccounts,
            $this->androidPayCards,
            $this->amexExpressCheckoutCards,
            $this->venmoAccounts,
            $this->usBankAccounts
        ));
    }

    /**
     * returns a string representation of the customer
     * @return string
     */
    public function  __toString()
    {
        return __CLASS__ . '[' .
                Util::attributesToString($this->_attributes) .']';
    }

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

    /**
     * returns an array containt all of the customer's payment methods
     *
     * @deprecated since version 3.1.0 - use the paymentMethods property directly
     *
     * @return array
     */
    public function paymentMethods()
    {
        return $this->paymentMethods;
    }

    /**
     * returns the customer's default payment method
     *
     * @return CreditCard|PayPalAccount
     */
    public function defaultPaymentMethod()
    {
        $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\Customer::_defaultPaymentMethodFilter');
        return current($defaultPaymentMethods);
    }

    public static function _defaultPaymentMethodFilter($paymentMethod)
    {
        return $paymentMethod->isDefault();
    }

    /* private class properties  */

    /**
     * @access protected
     * @var array registry of customer data
     */
    protected $_attributes = [
        'addresses'   => '',
        'company'     => '',
        'creditCards' => '',
        'email'       => '',
        'fax'         => '',
        'firstName'   => '',
        'id'          => '',
        'lastName'    => '',
        'phone'       => '',
        'createdAt'   => '',
        'updatedAt'   => '',
        'website'     => '',
        ];

    /**
     *  factory method: returns an instance of Customer
     *  to the requesting method, with populated properties
     *
     * @ignore
     * @param array $attributes
     * @return Customer
     */
    public static function factory($attributes)
    {
        $instance = new Customer();
        $instance->_initialize($attributes);
        return $instance;
    }
}
class_alias('Braintree\Customer', 'Braintree_Customer');

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).