Exemplo n.º 1
0
 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));
 }
Exemplo n.º 2
0
 /**
  * sets instance properties from an array of values
  *
  * @ignore
  * @access protected
  * @param array $customerAttribs array of customer data
  * @return none
  */
 protected function _initialize($customerAttribs)
 {
     // set the attributes
     $this->_attributes = $customerAttribs;
     // map each address into its own object
     $addressArray = array();
     if (isset($customerAttribs['addresses'])) {
         foreach ($customerAttribs['addresses'] as $address) {
             $addressArray[] = Braintree_Address::factory($address);
         }
     }
     $this->_set('addresses', $addressArray);
     // map each creditCard into its own object
     $creditCardArray = array();
     if (isset($customerAttribs['creditCards'])) {
         foreach ($customerAttribs['creditCards'] as $creditCard) {
             $creditCardArray[] = Braintree_CreditCard::factory($creditCard);
         }
     }
     $this->_set('creditCards', $creditCardArray);
     // map each coinbaseAccount into its own object
     $coinbaseAccountArray = array();
     if (isset($customerAttribs['coinbaseAccounts'])) {
         foreach ($customerAttribs['coinbaseAccounts'] as $coinbaseAccount) {
             $coinbaseAccountArray[] = Braintree_CoinbaseAccount::factory($coinbaseAccount);
         }
     }
     $this->_set('coinbaseAccounts', $coinbaseAccountArray);
     // map each paypalAccount into its own object
     $paypalAccountArray = array();
     if (isset($customerAttribs['paypalAccounts'])) {
         foreach ($customerAttribs['paypalAccounts'] as $paypalAccount) {
             $paypalAccountArray[] = Braintree_PayPalAccount::factory($paypalAccount);
         }
     }
     $this->_set('paypalAccounts', $paypalAccountArray);
     // map each applePayCard into its own object
     $applePayCardArray = array();
     if (isset($customerAttribs['applePayCards'])) {
         foreach ($customerAttribs['applePayCards'] as $applePayCard) {
             $applePayCardArray[] = Braintree_applePayCard::factory($applePayCard);
         }
     }
     $this->_set('applePayCards', $applePayCardArray);
     // map each androidPayCard into its own object
     $androidPayCardArray = array();
     if (isset($customerAttribs['androidPayCards'])) {
         foreach ($customerAttribs['androidPayCards'] as $androidPayCard) {
             $androidPayCardArray[] = Braintree_AndroidPayCard::factory($androidPayCard);
         }
     }
     $this->_set('androidPayCards', $androidPayCardArray);
 }
Exemplo n.º 3
0
 /**
  * sets instance properties from an array of values
  *
  * @access protected
  * @param array $creditCardAttribs array of creditcard data
  * @return none
  */
 protected function _initialize($creditCardAttribs)
 {
     // set the attributes
     $this->_attributes = $creditCardAttribs;
     // map each address into its own object
     $billingAddress = isset($creditCardAttribs['billingAddress']) ? Braintree_Address::factory($creditCardAttribs['billingAddress']) : null;
     $subscriptionArray = array();
     if (isset($creditCardAttribs['subscriptions'])) {
         foreach ($creditCardAttribs['subscriptions'] as $subscription) {
             $subscriptionArray[] = Braintree_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);
 }
Exemplo n.º 4
0
 /**
  * generic method for validating incoming gateway responses
  *
  * creates a new Braintree_Address object and encapsulates
  * it inside a Braintree_Result_Successful object, or
  * encapsulates a Braintree_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 Braintree_Exception_Unexpected
  */
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['address'])) {
         // return a populated instance of Braintree_Address
         return new Braintree_Result_Successful(Braintree_Address::factory($response['address']));
     } else {
         if (isset($response['apiErrorResponse'])) {
             return new Braintree_Result_Error($response['apiErrorResponse']);
         } else {
             throw new Braintree_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 none
  */
 protected function _initialize($customerAttribs)
 {
     // set the attributes
     $this->_attributes = $customerAttribs;
     // map each address into its own object
     $addressArray = array();
     if (isset($customerAttribs['addresses'])) {
         foreach ($customerAttribs['addresses'] as $address) {
             $addressArray[] = Braintree_Address::factory($address);
         }
     }
     $this->_set('addresses', $addressArray);
     // map each creditcard into its own object
     $ccArray = array();
     if (isset($customerAttribs['creditCards'])) {
         foreach ($customerAttribs['creditCards'] as $creditCard) {
             $ccArray[] = Braintree_CreditCard::factory($creditCard);
         }
     }
     $this->_set('creditCards', $ccArray);
 }