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']);
     }
 }
Пример #2
0
 function testTransactions()
 {
     $disbursement = Braintree_Disbursement::factory(array("id" => "123456", "merchantAccount" => array("id" => "sandbox_sub_merchant_account", "masterMerchantAccount" => array("id" => "sandbox_master_merchant_account", "status" => "active"), "status" => "active"), "transactionIds" => array("sub_merchant_transaction"), "exceptionMessage" => "invalid_account_number", "amount" => "100.00", "disbursementDate" => new DateTime("2013-04-10"), "followUpAction" => "update", "retry" => false, "success" => false));
     $transactions = $disbursement->transactions();
     $this->assertNotNull($transactions);
     $this->assertEquals(sizeOf($transactions), 1);
     $this->assertEquals($transactions->firstItem()->id, 'sub_merchant_transaction');
 }
Пример #3
0
 function testToString()
 {
     $disbursement = Braintree_Disbursement::factory(array("id" => "123456", "merchantAccount" => array("id" => "sandbox_sub_merchant_account", "masterMerchantAccount" => array("id" => "sandbox_master_merchant_account", "status" => "active"), "status" => "active"), "transactionIds" => array("sub_merchant_transaction"), "exceptionMessage" => "invalid_account_number", "amount" => "100.00", "disbursementDate" => new DateTime("2013-04-10"), "followUpAction" => "update", "retry" => false, "success" => false));
     $this->assertEquals((string) $disbursement, 'Braintree_Disbursement[id=123456, merchantAccountDetails=id=sandbox_sub_merchant_account, masterMerchantAccount=id=sandbox_master_merchant_account, status=active, status=active, exceptionMessage=invalid_account_number, amount=100.00, disbursementDate=Wednesday, 10-Apr-13 00:00:00 UTC, followUpAction=update, retry=, success=, transactionIds=0=sub_merchant_transaction]');
 }