protected function _initialize($attributes)
 {
     $this->_attributes = $attributes;
     if (isset($attributes['subject']['apiErrorResponse'])) {
         $wrapperNode = $attributes['subject']['apiErrorResponse'];
     } else {
         $wrapperNode = $attributes['subject'];
     }
     if (isset($wrapperNode['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($attributes['subject']['subscription']));
     }
     if (isset($wrapperNode['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($wrapperNode['merchantAccount']));
     }
     if (isset($wrapperNode['transaction'])) {
         $this->_set('transaction', Braintree_Transaction::factory($wrapperNode['transaction']));
     }
     if (isset($wrapperNode['disbursement'])) {
         $this->_set('disbursement', Braintree_Disbursement::factory($wrapperNode['disbursement']));
     }
     if (isset($wrapperNode['partnerMerchant'])) {
         $this->_set('partnerMerchant', Braintree_PartnerMerchant::factory($wrapperNode['partnerMerchant']));
     }
     if (isset($wrapperNode['errors'])) {
         $this->_set('errors', new Braintree_Error_ValidationErrorCollection($wrapperNode['errors']));
         $this->_set('message', $wrapperNode['message']);
     }
 }
Exemple #2
0
 /**
  * overrides default constructor
  * @ignore
  * @param array $response gateway response array
  */
 public function __construct($response)
 {
     $this->_attributes = $response;
     $this->_set('errors', new Braintree_Error_ErrorCollection($response['errors']));
     if (isset($response['verification'])) {
         $this->_set('creditCardVerification', new Braintree_Result_CreditCardVerification($response['verification']));
     } else {
         $this->_set('creditCardVerification', null);
     }
     if (isset($response['transaction'])) {
         $this->_set('transaction', Braintree_Transaction::factory($response['transaction']));
     } else {
         $this->_set('transaction', null);
     }
     if (isset($response['subscription'])) {
         $this->_set('subscription', Braintree_Subscription::factory($response['subscription']));
     } else {
         $this->_set('subscription', null);
     }
     if (isset($response['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($response['merchantAccount']));
     } else {
         $this->_set('merchantAccount', null);
     }
 }
 protected function _initialize($disbursementAttribs)
 {
     $this->_attributes = $disbursementAttribs;
     $this->merchantAccountDetails = $disbursementAttribs['merchantAccount'];
     if (isset($disbursementAttribs['merchantAccount'])) {
         $this->_set('merchantAccount', Braintree_MerchantAccount::factory($disbursementAttribs['merchantAccount']));
     }
 }
 private function _verifyGatewayResponse($response)
 {
     if (isset($response['merchantAccount'])) {
         // return a populated instance of Braintree_merchantAccount
         return new Braintree_Result_Successful(Braintree_MerchantAccount::factory($response['merchantAccount']));
     } else {
         if (isset($response['apiErrorResponse'])) {
             return new Braintree_Result_Error($response['apiErrorResponse']);
         } else {
             throw new Braintree_Exception_Unexpected("Expected merchant account or apiErrorResponse");
         }
     }
 }
 function testCreateMerchantAccountWithAllParams()
 {
     $params = array("id" => "sub_merchant_account", "status" => "active", "masterMerchantAccount" => array("id" => "master_merchant_account", "status" => "active"), "individual" => array("firstName" => "John", "lastName" => "Doe", "email" => "*****@*****.**", "dateOfBirth" => "1970-01-01", "phone" => "3125551234", "ssnLast4" => "6789", "address" => array("streetAddress" => "123 Fake St", "locality" => "Chicago", "region" => "IL", "postalCode" => "60622")), "business" => array("dbaName" => "James's Bloggs", "taxId" => "123456789"), "funding" => array("accountNumberLast4" => "8798", "routingNumber" => "071000013"));
     $merchantAccount = Braintree_MerchantAccount::factory($params);
     $this->assertEquals($merchantAccount->status, "active");
     $this->assertEquals($merchantAccount->id, "sub_merchant_account");
     $this->assertEquals($merchantAccount->masterMerchantAccount->id, "master_merchant_account");
     $this->assertEquals($merchantAccount->masterMerchantAccount->status, "active");
     $this->assertEquals($merchantAccount->individualDetails->firstName, "John");
     $this->assertEquals($merchantAccount->individualDetails->lastName, "Doe");
     $this->assertEquals($merchantAccount->individualDetails->email, "*****@*****.**");
     $this->assertEquals($merchantAccount->individualDetails->dateOfBirth, "1970-01-01");
     $this->assertEquals($merchantAccount->individualDetails->phone, "3125551234");
     $this->assertEquals($merchantAccount->individualDetails->ssnLast4, "6789");
     $this->assertEquals($merchantAccount->individualDetails->addressDetails->streetAddress, "123 Fake St");
     $this->assertEquals($merchantAccount->individualDetails->addressDetails->locality, "Chicago");
     $this->assertEquals($merchantAccount->individualDetails->addressDetails->region, "IL");
     $this->assertEquals($merchantAccount->individualDetails->addressDetails->postalCode, "60622");
     $this->assertEquals($merchantAccount->businessDetails->dbaName, "James's Bloggs");
     $this->assertEquals($merchantAccount->businessDetails->taxId, "123456789");
     $this->assertEquals($merchantAccount->fundingDetails->accountNumberLast4, "8798");
     $this->assertEquals($merchantAccount->fundingDetails->routingNumber, "071000013");
 }