public function updateCustomer(array $args, Customer $Customer = null)
    {
        $default_args = [
            'api_key'  => '', // Stripe API key.
            'customer' => '', // Existing customer ID.

            // Everything else is optional (for update).
            // Anything not passed in will not be changed.

            'ip'    => '', // New IP address for customer.
            'email' => '', // New email address for customer.

            'fname' => '', // New first name for customer.
            'lname' => '', // New last name for customer.

            'source'            => '', // New source for customer.
            'is_default_source' => true, // Is the default source?
            'description'       => '', // New description for customer.

            'user_id'  => '', // New user ID for customer.
            'metadata' => '', // New metadata for customer.
        ];
        $args = (array) $args; // Force array.
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);
        extract($this->parseArgs(__FUNCTION__, $args));

        if (!$Customer && $args['customer']) {
            $Customer = $this->customer($args['customer']);
        }
        if (!($Customer instanceof Customer)) {
            $_error = sprintf('Failed to acquire customer for update.');
            return $this->exceptionError(new Exception($_error));
        }
        try { // Update.
            if ($args['email']) {
                $Customer->email = $args['email'];
            }
            if ($args['source']) {
                $Customer->source = $args['source'];

                if ($args['is_default_source']) {
                    $Customer->default_source = $args['source'];
                } // Update customer's default source.
            }
            if ($args['description']) {
                $Customer->description = $args['description'];
            }
            if ($args['ip']) {
                $Customer->metadata->ip = $args['ip'];
            }
            if ($args['email']) {
                $Customer->metadata->email = $args['email'];
            }
            if ($args['fname']) {
                $Customer->metadata->fname = $args['fname'];
            }
            if ($args['lname']) {
                $Customer->metadata->lname = $args['lname'];
            }
            if ($args['user_id']) {
                $Customer->metadata->user_id = $args['user_id'];
            }
            if ($args['metadata']) {
                foreach ($args['metadata'] as $_key => $_value) {
                    $Customer->metadata->{$_key} = $_value;
                } // unset($_key, $_value);
            }
            $Customer->save();
        } catch (\Throwable $Exception) {
            return $this->exceptionError($Exception);
        }
        return $Customer;
    }
public function updateCustomer(array $args, Customer $Customer = null)
    {
        $default_args = [
            'api_key'  => '', // Stripe API key.
            'customer' => '', // Existing customer ID.

            // Everything else is optional (for update).
            // Anything not passed in will not be changed.

            'ip'    => '', // New IP address for customer.
            'email' => '', // New email address for customer.

            'fname' => '', // New first name for customer.
            'lname' => '', // New last name for customer.

            'source'            => '', // New source for customer.
            'is_default_source' => true, // Is the default source?
            'description'       => '', // New description for customer.

            'user_id'  => '', // New user ID for customer.
            'metadata' => '', // New metadata for customer.
        ];
        $args = (array) $args; // Force array.
        $args = array_merge($default_args, $args);
        $args = array_intersect_key($args, $default_args);
        extract($this->parseArgs(__FUNCTION__, $args));

        if (!$Customer && $args['customer']) {
            $Customer = $this->customer($args['customer']);
        }
        if (!($Customer instanceof Customer)) {
            $_error = sprintf('Failed to acquire customer for update.');
            return $this->exceptionError(new Exception($_error));
        }
        try { // Update.
            if ($args['email']) {
                $Customer->email = $args['email'];
            }
            if ($args['source']) {
                $Customer->source = $args['source'];

                if ($args['is_default_source']) {
                    $Customer->default_source = $args['source'];
                } // Update customer's default source.
            }
            if ($args['description']) {
                $Customer->description = $args['description'];
            }
            if ($args['ip']) {
                $Customer->metadata->ip = $args['ip'];
            }
            if ($args['email']) {
                $Customer->metadata->email = $args['email'];
            }
            if ($args['fname']) {
                $Customer->metadata->fname = $args['fname'];
            }
            if ($args['lname']) {
                $Customer->metadata->lname = $args['lname'];
            }
            if ($args['user_id']) {
                $Customer->metadata->user_id = $args['user_id'];
            }
            if ($args['metadata']) {
                foreach ($args['metadata'] as $_key => $_value) {
                    $Customer->metadata->{$_key} = $_value;
                } // unset($_key, $_value);
            }
            $Customer->save();
        } catch (\Throwable $Exception) {
            return $this->exceptionError($Exception);
        }
        return $Customer;
    }
public function updateCustomer ( array $ args , Customer $ Customer = null ) { $ default_args = [ 'api_key' => '' , // Stripe API key. 'customer' => '' , // Existing customer ID. // Everything else is optional (for update). // Anything not passed in will not be changed. 'ip' => '' , // New IP address for customer. 'email' => '' , // New email address for customer. 'fname' => '' , // New first name for customer. 'lname' => '' , // New last name for customer. 'source' => '' , // New source for customer. 'is_default_source' => true , // Is the default source? 'description' => '' , // New description for customer. 'user_id' => '' , // New user ID for customer. 'metadata' => '' , // New metadata for customer. ] ; $ args = ( array ) $ args ; // Force array. $ args = array_merge ( $ default_args , $ args ) ; $ args = array_intersect_key ( $ args , $ default_args ) ; extract ( $ this -> parseArgs ( __FUNCTION__ , $ args ) ) ; if ( ! $ Customer && $ args [ 'customer' ] ) { $ Customer = $ this -> customer ( $ args [ 'customer' ] ) ; } if ( ! ( $ Customer instanceof Customer ) ) { $ _error = sprintf ( 'Failed to acquire customer for update.' ) ; return $ this -> exceptionError ( new Exception ( $ _error ) ) ; } try { // Update. if ( $ args [ 'email' ] ) { $ Customer -> email = $ args [ 'email' ] ; } if ( $ args [ 'source' ] ) { $ Customer -> source = $ args [ 'source' ] ; if ( $ args [ 'is_default_source' ] ) { $ Customer -> default_source = $ args [ 'source' ] ; } // Update customer's default source. } if ( $ args [ 'description' ] ) { $ Customer -> description = $ args [ 'description' ] ; } if ( $ args [ 'ip' ] ) { $ Customer -> metadata -> ip = $ args [ 'ip' ] ; } if ( $ args [ 'email' ] ) { $ Customer -> metadata -> email = $ args [ 'email' ] ; } if ( $ args [ 'fname' ] ) { $ Customer -> metadata -> fname = $ args [ 'fname' ] ; } if ( $ args [ 'lname' ] ) { $ Customer -> metadata -> lname = $ args [ 'lname' ] ; } if ( $ args [ 'user_id' ] ) { $ Customer -> metadata -> user_id = $ args [ 'user_id' ] ; } if ( $ args [ 'metadata' ] ) { foreach ( $ args [ 'metadata' ] as $ _key => $ _value ) { $ Customer -> metadata -> { $ _key } = $ _value ; } // unset($_key, $_value); } $ Customer -> save ( ) ; } catch ( \ Throwable $ Exception ) { return $ this -> exceptionError ( $ Exception ) ; } return $ Customer ; }
Update existing customer.

@since 170329.13807 Stripe utils.

@param array         $args     Arguments.
@param Customer|null $Customer Instance (optional).

@return Customer|Error Customer on success.
Update existing customer .