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']); } }
/** * 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'])); } }
protected function _initialize($merchantAccountAttribs) { $this->_attributes = $merchantAccountAttribs; if (isset($merchantAccountAttribs['masterMerchantAccount'])) { $masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount']; $this->_set('masterMerchantAccount', Braintree_MerchantAccount::Factory($masterMerchantAccount)); } }
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"); } } }
/** * Check if specified Merchant Account Id is correct * * @return boolean */ protected function _checkMerchantAccountId() { $storeId = null; if (Mage::app()->getStore()->isAdmin()) { $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote(); $storeId = $quote->getStoreId(); } $merchantAccountId = Mage::getStoreConfig('payment/braintree/merchant_account_id', $storeId); try { Braintree_MerchantAccount::find($merchantAccountId); $result = true; } catch (Exception $e) { $result = false; } return $result; }
public function providerB_bankingSubmit() { $this->_braintreeConfigure(); $result = new stdClass(); $result = Braintree_MerchantAccount::create(array('individual' => array('firstName' => Input::get('first_name'), 'lastName' => Input::get('last_name'), 'email' => Input::get('email'), 'phone' => Input::get('phone'), 'dateOfBirth' => date('Y-m-d', strtotime(Input::get('dob'))), 'ssn' => Input::get('ssn'), 'address' => array('streetAddress' => Input::get('streetAddress'), 'locality' => Input::get('locality'), 'region' => Input::get('region'), 'postalCode' => Input::get('postalCode'))), 'funding' => array('descriptor' => 'UberForX', 'destination' => Braintree_MerchantAccount::FUNDING_DESTINATION_BANK, 'email' => Input::get('bankemail'), 'mobilePhone' => Input::get('bankphone'), 'accountNumber' => Input::get('accountNumber'), 'routingNumber' => Input::get('routingNumber')), 'tosAccepted' => true, 'masterMerchantAccountId' => Config::get('app.masterMerchantAccountId'), 'id' => "taxinow" . Input::get('id'))); Log::info('res = ' . print_r($result, true)); if ($result->success) { $pro = Walker::where('id', Input::get('id'))->first(); $pro->merchant_id = $result->merchantAccount->id; $pro->save(); Log::info(print_r($pro, true)); Log::info('Adding banking details to provider from Admin = ' . print_r($result, true)); return Redirect::to("/"); } else { Log::info('Error in adding banking details: ' . $result->message); return Redirect::to("banking_provider_mobile"); } }
protected function _initialize($merchantAccountAttribs) { $this->_attributes = $merchantAccountAttribs; if (isset($merchantAccountAttribs['individual'])) { $individual = $merchantAccountAttribs['individual']; $this->_set('individualDetails', Braintree_MerchantAccount_IndividualDetails::Factory($individual)); } if (isset($merchantAccountAttribs['business'])) { $business = $merchantAccountAttribs['business']; $this->_set('businessDetails', Braintree_MerchantAccount_BusinessDetails::Factory($business)); } if (isset($merchantAccountAttribs['funding'])) { $funding = $merchantAccountAttribs['funding']; $this->_set('fundingDetails', new Braintree_MerchantAccount_FundingDetails($funding)); } if (isset($merchantAccountAttribs['masterMerchantAccount'])) { $masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount']; $this->_set('masterMerchantAccount', Braintree_MerchantAccount::Factory($masterMerchantAccount)); } }
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"); }
function testUpdateWithInvalidFundingFields() { $params = array("funding" => array("destination" => Braintree_MerchantAccount::FUNDING_DESTINATION_EMAIL, "email" => "")); $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); $this->assertEquals(false, $result->success); $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("email"); $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_EMAIL_IS_REQUIRED); $params = array("funding" => array("destination" => Braintree_MerchantAccount::FUNDING_DESTINATION_MOBILE_PHONE, "mobilePhone" => "")); $result = Braintree_MerchantAccount::update("sandbox_sub_merchant_account", $params); $this->assertEquals(false, $result->success); $error = $result->errors->forKey("merchantAccount")->forKey("funding")->onAttribute("mobilePhone"); $this->assertEquals($error[0]->code, Braintree_Error_Codes::MERCHANT_ACCOUNT_FUNDING_MOBILE_PHONE_IS_REQUIRED); }
} else { if ($_POST['_act'] == 'findPaymentMethod') { $paymentMethod = Braintree_PaymentMethod::find($_POST['token']); print_r($paymentMethod); } else { if ($_POST['_act'] == 'deletePaymentMethod') { $search = (string) $_POST['token']; $file = './data/token.txt'; $contents = file_get_contents($file); echo $contents = str_replace($_POST['token'], trim((string) $_POST['token'] . "_DELETED\r\n"), $contents); file_put_contents($file, $contents); $paymentMethod = Braintree_PaymentMethod::delete($_POST['token']); print_r($paymentMethod); } else { if ($_POST['_act'] == 'createSubMerchant') { $result = Braintree_MerchantAccount::create(array('individual' => array('firstName' => $_POST['firstName'], 'lastName' => $_POST['lastName'], 'email' => $_POST['email'], 'phone' => $_POST['phone'], 'dateOfBirth' => $_POST['dateOfBirth'], 'ssn' => $_POST['ssn'], 'address' => array('streetAddress' => $_POST['streetAddress'], 'locality' => $_POST['locality'], 'region' => $_POST['region'], 'postalCode' => $_POST['postalCode'])), 'business' => array('legalName' => $_POST['legalName'], 'dbaName' => $_POST['dbaName'], 'taxId' => $_POST['taxId'], 'address' => array('streetAddress' => $_POST['streetAddress2'], 'locality' => $_POST['locality2'], 'region' => $_POST['region2'], 'postalCode' => $_POST['postalCode2'])), 'funding' => array('descriptor' => $_POST['descriptor'], 'destination' => Braintree_MerchantAccount::FUNDING_DESTINATION_BANK, 'email' => $_POST['email'], 'mobilePhone' => $_POST['mobilePhone'], 'accountNumber' => $_POST['accountNumber'], 'routingNumber' => $_POST['routingNumber']), 'tosAccepted' => true, 'masterMerchantAccountId' => "qzmnkckz54r94r4f", 'id' => "mc_" . time())); $file = './data/subMerchant.txt'; //[ADD Customer ID to text file] $subMerchantID = $result->merchantAccount->id . "\r\n"; // Write the contents to the file, // using the FILE_APPEND flag to append the content to the end of the file // and the LOCK_EX flag to prevent anyone else writing to the file at the same time file_put_contents($file, $subMerchantID, FILE_APPEND | LOCK_EX); print_r($result); } else { if ($_POST['_act'] == 'CreateTransEscrow') { $result = Braintree_Transaction::sale(array('merchantAccountId' => $_POST["sub_merchant_id"], 'amount' => $_POST["amount"], 'paymentMethodNonce' => $_POST["payment_method_nonce"], 'serviceFeeAmount' => $_POST["serviceFeeAmount"], 'options' => array('holdInEscrow' => true))); print_r($result); $file = './data/trans_id.txt'; //[ADD Customer ID to text file] $transID = $result->transaction->id . "\r\n";
public function updateSubMerchant($sub_merchant_id, $data) { $result = Braintree_MerchantAccount::update($sub_merchant_id, $data); if ($result->success) { return array('success' => 1, 'sub_merchant_id' => $result->merchantAccount->id, 'status' => $result->merchantAccount->status, 'currency_code' => $result->merchantAccount->currencyIsoCode); /* eg:Array ( [success] => 1 [sub_merchant_id] => jane_doe_instant5 [status] => pending [currency_code] => USD ) /* firstname=>approve_me Array ( [success] => 1 [sub_merchant_id] => approve_me_doe_instant [status] => pending [currency_code] => USD ) */ } else { return array('success' => 0, 'errors' => $result->errors->deepAll()); /* eg: Array ( [success] => 0 [errors] => Array ( [0] => Braintree_Error_Validation Object ( [_attribute:Braintree_Error_Validation:private] => mobilePhone [_code:Braintree_Error_Validation:private] => 82683 [_message:Braintree_Error_Validation:private] => Funding mobile phone is invalid. ) ) ) */ } }