public function testCustomerIdNotEqual() { $first = Braintree\Address::factory(array('customerId' => 'c1', 'id' => 'a1')); $second = Braintree\Address::factory(array('customerId' => 'not c1', 'id' => 'a1')); $this->assertFalse($first->isEqual($second)); $this->assertFalse($second->isEqual($first)); }
/** * generic method for validating incoming gateway responses * * creates a new Address object and encapsulates * it inside a Result\Successful object, or * encapsulates an Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid * * @ignore * @param array $response gateway response values * @return object Result\Successful or Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['address'])) { // return a populated instance of Address return new Result\Successful(Address::factory($response['address'])); } else { if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected("Expected address or apiErrorResponse"); } } }
/** * sets instance properties from an array of values * * @ignore * @access protected * @param array $customerAttribs array of customer data * @return void */ protected function _initialize($customerAttribs) { // set the attributes $this->_attributes = $customerAttribs; // map each address into its own object $addressArray = []; if (isset($customerAttribs['addresses'])) { foreach ($customerAttribs['addresses'] as $address) { $addressArray[] = Address::factory($address); } } $this->_set('addresses', $addressArray); // map each creditCard into its own object $creditCardArray = []; if (isset($customerAttribs['creditCards'])) { foreach ($customerAttribs['creditCards'] as $creditCard) { $creditCardArray[] = CreditCard::factory($creditCard); } } $this->_set('creditCards', $creditCardArray); // map each coinbaseAccount into its own object $coinbaseAccountArray = []; if (isset($customerAttribs['coinbaseAccounts'])) { foreach ($customerAttribs['coinbaseAccounts'] as $coinbaseAccount) { $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount); } } $this->_set('coinbaseAccounts', $coinbaseAccountArray); // map each paypalAccount into its own object $paypalAccountArray = []; if (isset($customerAttribs['paypalAccounts'])) { foreach ($customerAttribs['paypalAccounts'] as $paypalAccount) { $paypalAccountArray[] = PayPalAccount::factory($paypalAccount); } } $this->_set('paypalAccounts', $paypalAccountArray); // map each applePayCard into its own object $applePayCardArray = []; if (isset($customerAttribs['applePayCards'])) { foreach ($customerAttribs['applePayCards'] as $applePayCard) { $applePayCardArray[] = ApplePayCard::factory($applePayCard); } } $this->_set('applePayCards', $applePayCardArray); // map each androidPayCard into its own object $androidPayCardArray = []; if (isset($customerAttribs['androidPayCards'])) { foreach ($customerAttribs['androidPayCards'] as $androidPayCard) { $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard); } } $this->_set('androidPayCards', $androidPayCardArray); $this->_set('paymentMethods', array_merge($this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards)); }