PHP Class Braintree\CustomerGateway

== More information == For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api}
ファイルを表示 Open project: braintree/braintree_php Class Usage Examples

Protected Properties

Property Type Description
$_attributes registry of customer data

Public Methods

Method Description
__construct ( $gateway )
__toString ( ) : string returns a string representation of the customer
_defaultPaymentMethodFilter ( $paymentMethod )
_doCreate ( string $subPath, array $params ) : mixed sends the create request to the gateway
all ( )
create ( array $attribs = [] ) : Braintree_Result_Successful | Braintree_Result_Error Creates a customer using the given +attributes+. If :id is not passed, the gateway will generate it.
createCustomerUrl ( ) : string
createFromTransparentRedirect ( $queryString ) : Customer create a customer from a TransparentRedirect operation
createNoValidate ( array $attribs = [] ) : Customer attempts the create operation assuming all data will validate returns a Customer object instead of a Result
createSignature ( ) : array creates a full array signature of a valid create request
credit ( integer $customerId, array $transactionAttribs ) : Braintree\Result\Successful | Error credit a customer for the passed transaction
creditNoValidate ( integer $customerId, array $transactionAttribs ) : Transaction credit a customer, assuming validations will pass
defaultPaymentMethod ( ) : CreditCard | braintree\PayPalAccount | braintree\ApplePayCard | braintree\AndroidPayCard returns the customer's default payment method
delete ( string $customerId ) delete a customer by id
fetch ( $query, $ids )
find ( $id ) : Customer | boolean find a customer by id
isEqual ( object $otherCust ) : boolean returns false if comparing object is not a Customer, or is a Customer with a different id
paymentMethods ( ) : array returns an array containt all of the customer's payment methods
sale ( string $customerId, array $transactionAttribs ) : Braintree\Result\Successful | Error create a new sale for a customer
saleNoValidate ( string $customerId, array $transactionAttribs ) : Transaction create a new sale for a customer, assuming validations will pass
search ( mixed $query ) : ResourceCollection Returns a ResourceCollection of customers matching the search query.
update ( string $customerId, array $attributes ) : Braintree\Result\Successful | Error updates the customer record
updateCustomerUrl ( ) : string
updateFromTransparentRedirect ( string $queryString ) : object update a customer from a TransparentRedirect operation
updateNoValidate ( string $customerId, array $attributes ) : Customer update a customer record, assuming validations will pass
updateSignature ( ) : array creates a full array signature of a valid update request

Protected Methods

Method Description
_initialize ( array $customerAttribs ) : void sets instance properties from an array of values

Private Methods

Method Description
_doUpdate ( $httpVerb, string $subPath, array $params ) : mixed sends the update request to the gateway
_validateId ( $id = null ) verifies that a valid customer id is being used
_verifyGatewayResponse ( array $response ) : Braintree\Result\Successful | Error generic method for validating incoming gateway responses

Method Details

__construct() public method

public __construct ( $gateway )

__toString() public method

returns a string representation of the customer
public __toString ( ) : string
return string

_defaultPaymentMethodFilter() public static method

public static _defaultPaymentMethodFilter ( $paymentMethod )

_doCreate() public method

sends the create request to the gateway
public _doCreate ( string $subPath, array $params ) : mixed
$subPath string
$params array
return mixed

_initialize() protected method

sets instance properties from an array of values
protected _initialize ( array $customerAttribs ) : void
$customerAttribs array array of customer data
return void

all() public method

public all ( )

create() public method

$result = Customer::create(array( 'first_name' => 'John', 'last_name' => 'Smith', 'company' => 'Smith Co.', 'email' => '[email protected]', 'website' => 'www.smithco.com', 'fax' => '419-555-1234', 'phone' => '614-555-1234' )); if($result->success) { echo 'Created customer ' . $result->customer->id; } else { echo 'Could not create customer, see result->errors'; }
public create ( array $attribs = [] ) : Braintree_Result_Successful | Braintree_Result_Error
$attribs array
return Braintree_Result_Successful | Braintree_Result_Error

createCustomerUrl() public method

Deprecation: since version 2.3.0
public createCustomerUrl ( ) : string
return string

createFromTransparentRedirect() public method

create a customer from a TransparentRedirect operation
Deprecation: since version 2.3.0
public createFromTransparentRedirect ( $queryString ) : Customer
return Customer

createNoValidate() public method

attempts the create operation assuming all data will validate returns a Customer object instead of a Result
public createNoValidate ( array $attribs = [] ) : Customer
$attribs array
return Customer

createSignature() public static method

creates a full array signature of a valid create request
public static createSignature ( ) : array
return array gateway create request format

credit() public method

credit a customer for the passed transaction
public credit ( integer $customerId, array $transactionAttribs ) : Braintree\Result\Successful | Error
$customerId integer
$transactionAttribs array
return Braintree\Result\Successful | Braintree\Result\Error

creditNoValidate() public method

returns a Transaction object on success
public creditNoValidate ( integer $customerId, array $transactionAttribs ) : Transaction
$customerId integer
$transactionAttribs array
return Transaction

defaultPaymentMethod() public method

returns the customer's default payment method
public defaultPaymentMethod ( ) : CreditCard | braintree\PayPalAccount | braintree\ApplePayCard | braintree\AndroidPayCard
return CreditCard | braintree\PayPalAccount | braintree\ApplePayCard | braintree\AndroidPayCard

delete() public method

delete a customer by id
public delete ( string $customerId )
$customerId string

fetch() public method

public fetch ( $query, $ids )

find() public method

find a customer by id
public find ( $id ) : Customer | boolean
return Customer | boolean The customer object or false if the request fails.

isEqual() public method

returns false if comparing object is not a Customer, or is a Customer with a different id
public isEqual ( object $otherCust ) : boolean
$otherCust object customer to compare against
return boolean

paymentMethods() public method

returns an array containt all of the customer's payment methods
public paymentMethods ( ) : array
return array

sale() public method

create a new sale for a customer
See also: Transaction::sale()
public sale ( string $customerId, array $transactionAttribs ) : Braintree\Result\Successful | Error
$customerId string
$transactionAttribs array
return Braintree\Result\Successful | Braintree\Result\Error

saleNoValidate() public method

returns a Transaction object on success
See also: Transaction::sale()
public saleNoValidate ( string $customerId, array $transactionAttribs ) : Transaction
$customerId string
$transactionAttribs array
return Transaction

update() public method

if calling this method in static context, customerId is the 2nd attribute. customerId is not sent in object context.
public update ( string $customerId, array $attributes ) : Braintree\Result\Successful | Error
$customerId string (optional)
$attributes array
return Braintree\Result\Successful | Braintree\Result\Error

updateCustomerUrl() public method

Deprecation: since version 2.3.0
public updateCustomerUrl ( ) : string
return string

updateFromTransparentRedirect() public method

update a customer from a TransparentRedirect operation
Deprecation: since version 2.3.0
public updateFromTransparentRedirect ( string $queryString ) : object
$queryString string
return object

updateNoValidate() public method

if calling this method in static context, customerId is the 2nd attribute. customerId is not sent in object context. returns a Customer object on success
public updateNoValidate ( string $customerId, array $attributes ) : Customer
$customerId string
$attributes array
return Customer

updateSignature() public static method

creates a full array signature of a valid update request
public static updateSignature ( ) : array
return array update request format

Property Details

$_attributes protected_oe property

registry of customer data
protected $_attributes