v7‰PNG  IHDR Ÿ f Õ†C1 sRGB ®Îé gAMA ± üa pHYs à ÃÇo¨d GIDATx^íÜL”÷ð÷Yçªö("Bh_ò«®¸¢§q5kÖ*:þ0A­ºšÖ¥]VkJ¢M»¶f¸±8\k2íll£1]q®ÙÔ‚ÆT braintree.php000064400000120033152101632460007227 0ustar00getPluginUrl(self::ACTION_CC)); $action->cc_id = $invoice->getSecureId($this->getId()); $result->setAction($action); } function getSupportedCurrencies() { return array_keys(Am_Currency::getFullList()); } protected function ccActionValidateSetInvoice(Am_Mvc_Request $request, array $invokeArgs) { $invoiceId = $request->getFiltered('cc_id'); if (!$invoiceId) throw new Am_Exception_InputError("invoice_id is empty - seems you have followed wrong url, please return back to continue"); $invoice = $this->getDi()->invoiceTable->findBySecureId($invoiceId, $this->getId()); if (!$invoice) throw new Am_Exception_InputError('You have used wrong link for payment page, please return back and try again'); if ($invoice->isCompleted()) throw new Am_Exception_InputError(sprintf(___('Payment is already processed, please go to %sMembership page%s'), "", "")); if ($invoice->paysys_id != $this->getId()) throw new Am_Exception_InputError("You have used wrong link for payment page, please return back and try again"); if ($invoice->tm_added < sqlTime('-30 days')) throw new Am_Exception_InputError("Invoice expired - you cannot open invoice after 30 days elapsed"); $this->invoice = $invoice; // set for reference } public function getRecurringType() { return self::REPORTS_CRONREBILL; } function createForm($actionName) { return new Am_Form_CreditCard_Braintree($this, $actionName); } function createController(Am_Mvc_Request $request, Am_Mvc_Response $response, array $invokeArgs) { return new Am_Mvc_Controller_CreditCard_Braintree($request, $response, $invokeArgs); } public function init() { parent::init(); if ($this->isConfigured()) { require_once('lib/Braintree.php'); \Braintree\Configuration::merchantId($this->getConfig('merchant_id')); \Braintree\Configuration::privateKey($this->getConfig('private_key')); \Braintree\Configuration::publicKey($this->getConfig('public_key')); \Braintree\Configuration::environment($this->getConfig('sandbox') ? 'sandbox' : 'production'); if ($this->getConfig('multicurrency')) $this->getDi()->billingPlanTable->customFields() ->add(new Am_CustomFieldText('braintree_merchant_account_id', "BrainTree Merchant Account ID", "please set this up if you sell products in different currencies")); } } public function getConfig($key = null, $default = null) { if (in_array($key, array('merchant_id', 'public_key', 'private_key', 'merchant_account_id'))) return parent::getConfig(($this->getConfig('sandbox') ? 'test_' : '') . $key, $default); else return parent::getConfig($key, $default); } public function isConfigured() { return $this->getConfig('merchant_id') && $this->getConfig('public_key') && $this->getConfig('private_key'); } public function _initSetupForm(Am_Form_Setup $form) { $form->addText('merchant_id')->setLabel('Your BrainTree Merchant ID'); $form->addText('public_key')->setLabel('Your BrainTree Public Key'); $form->addText('private_key')->setLabel('Your BrainTree Private Key'); $form->addText('merchant_account_id')->setLabel('Your BrainTree Merchant Account ID'); $form->addText('test_merchant_id')->setLabel('Your BrainTree SANDBOX Merchant ID'); $form->addText('test_public_key')->setLabel('Your BrainTree SANDBOX Public Key'); $form->addText('test_private_key')->setLabel('Your BrainTree SANDBOX Private Key'); $form->addText('test_merchant_account_id')->setLabel('Your BrainTree SANDBOX Merchant Account ID'); $form->addAdvCheckbox('sandbox')->setLabel('Sandbox testing'); $form->addAdvCheckbox('hosted')->setLabel( "Use 'Hosted Fields'\n " . "SAQ A compliant solution"); $form->addAdvCheckbox('multicurrency')->setLabel("Use different merchant account ID's\n" . 'if you sell products in different currencies you need to setup merchant account ID for each product'); } // We do not store CC info. public function storesCcInfo() { return false; } public function getUpdateCcLink($user) { try { if (!($bid = $user->data()->get(Am_Paysystem_Braintree::CUSTOMER_ID))) return false; if (!($bt_member = \Braintree\Customer::find($bid))) { $this->getDi()->errorLogTable->log('Wrong customer braintree id'); return false; } if (!($token = $bt_member->creditCards[0]->token)) { $this->getDi()->errorLogTable->log('Empty token for credit card'); return false; } return $this->getPluginUrl('update'); } catch (Exception $e) { $this->getDi()->errorLogTable->logException($e); } } function doBill(\Invoice $invoice, $doFirst, \CcRecord $cc = null) { $this->invoice = $invoice; $this->cc = $cc; $result = new Am_Paysystem_Result(); if ($this->getConfig('hosted')) $this->_doBillHosted($invoice, $doFirst, $cc, $result); else $this->_doBill($invoice, $doFirst, $cc, $result); return $result; } public function _doBill(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result) { if ($doFirst) { try { // We was redirected from Braintree so need to get result; $res = \Braintree\TransparentRedirect::confirm($_SERVER['QUERY_STRING']); if ($res instanceof \Braintree\Result\Error) { $result->setFailed($res->message); return; } else { $invoice->getUser()->data()->set(self::CUSTOMER_ID, $res->customer->id)->update(); } } catch (\Braintree\Exception\NotFound $e) { } catch (Exception $e) { $result->setFailed($e->getMessage()); return; } } if (!($customer_id = $invoice->getUser()->data()->get(self::CUSTOMER_ID))) { $result->setFailed('Empty customer ID. Please update CC info'); return; } // Now attempt to submit transaction if required; if ($doFirst && !(float) $invoice->first_total) { $transaction = new Am_Paysystem_Transaction_Free($this); $transaction->setInvoice($invoice); $transaction->process(); $result->setSuccess($transaction); } else { $transaction = new Am_Paysystem_Transaction_CreditCard_Braintree_Sale($this, $invoice, null, $doFirst); $transaction->run($result); } } public function _doBillHosted(Invoice $invoice, $doFirst, CcRecord $cc, Am_Paysystem_Result $result) { // Now attempt to submit transaction if required; if ($doFirst) { if (!(float) $invoice->first_total) { // Create Customer here; $transaction = new Am_Paysystem_Transaction_Free($this); $transaction->setInvoice($invoice); $transaction->process(); $result->setSuccess($transaction); } else { $transaction = new Am_Paysystem_Transaction_CreditCard_Braintree_SaleHosted($this, $invoice, null, $doFirst); $transaction->setCC($cc); $transaction->run($result); } } else $this->_doBill($invoice, $doFirst, $cc, $result); } public function processRefund(InvoicePayment $payment, Am_Paysystem_Result $result, $amount) { $trans = new Am_Paysystem_Transaction_CreditCard_Braintree_Refund($this, $payment->getInvoice(), null, null, $payment); $trans->run($result); if (!$result->isSuccess()) { $result->setErrorMessages(null); $trans = new Am_Paysystem_Transaction_CreditCard_Braintree_Void($this, $payment->getInvoice(), null, null, $payment); $trans->run($result); } return $result; } } class Am_Form_CreditCard_Braintree extends Am_Form_CreditCard { public function __construct(Am_Paysystem_CreditCard $plugin, $formType = self::PAYFORM) { $this->plugin = $plugin; $this->formType = $formType; $this->payButtons = array( self::PAYFORM => ___('Subscribe And Pay'), self::ADMIN_UPDATE => ___('Update Credit Card Info'), self::USER_UPDATE => ___('Update Credit Card Info'), self::ADMIN_INSERT => ___('Update Credit Card Info'), ); Am_Form::__construct('cc', array('action' => \Braintree\TransparentRedirect::url())); } public function init() { Am_Form::init(); if ($this->plugin->getConfig('hosted')) $this->createFormHosted(); else $this->createFormRegular(); // if free trial set _TPL_CC_INFO_SUBMIT_BUT2 $buttons = $this->addGroup(); $buttons->addSubmit('_cc_', array('value' => ' ' . $this->payButtons[$this->formType] . ' ')); $this->plugin->onFormInit($this); } function createFormRegular() { if ($this->formType == self::PAYFORM) $fn = 'customer__'; else $fn = ''; $name = $this->addGroup()->setLabel(___("Cardholder Name\n" . 'cardholder first and last name, exactly as on the card')); $name->addRule('required', ___('Please enter credit card holder name')); $name->addText($fn . 'credit_card__cardholder_name', array('size' => 30)) ->addRule('required', ___('Please enter cardholder name exactly as on card')) ->addRule('regex', ___('Please enter credit card holder name'), '|^[a-zA-Z_\' -]+$|'); $this->addText($fn . 'credit_card__number', array('autocomplete' => 'off', 'size' => 22, 'maxlength' => 22)) ->setLabel(___('Credit Card Number'), ___('for example: 1111222233334444')) ->addRule('required', ___('Please enter Credit Card Number')) ->addRule('regex', ___('Invalid Credit Card Number'), '/^[0-9 -]+$/') ->addRule('callback2', 'Invalid CC#', array($this->plugin, 'validateCreditCardNumber')); $gr = $this->addGroup() ->setLabel(___("Card Expire\n" . 'Select card expiration date - month and year')); $gr->addSelect($fn . 'credit_card__expiration_month') ->loadOptions($this->getMonthOptions()); $gr->addSelect($fn . 'credit_card__expiration_year') ->loadOptions($this->getYearOptions()); $this->addPassword($fn . 'credit_card__cvv', array('autocomplete' => 'off', 'size' => 4, 'maxlength' => 4)) ->setLabel(___("Credit Card Code\n" . 'The "Card Code" is a three- or four-digit security code that ' . 'is printed on the back of credit cards in the card\'s ' . 'signature panel (or on the front for American Express cards).')) ->addRule('required', ___('Please enter Credit Card Code')) ->addRule('regex', ___('Please enter Credit Card Code'), '/^\s*\d{3,4}\s*$/'); $fieldSet = $this->addFieldset(___('Address Info')) ->setLabel(___("Address Info\n" . '(must match your credit card statement delivery address)')); $bname = $fieldSet->addGroup()->setLabel(___("Billing Name\n" . 'Billing Address First and Last name')); $bname->addRule('required', ___('Please enter billing name')); $bname->addText($fn . 'credit_card__billing_address__first_name', array('size' => 15)) ->addRule('required', ___('Please enter first name')) ->addRule('regex', ___('Please enter first name'), '|^[a-zA-Z_\' -]+$|'); $bname->addText($fn . 'credit_card__billing_address__last_name', array('size' => 15)) ->addRule('required', ___('Please enter last name')) ->addRule('regex', ___('Please enter last name'), '|^[a-zA-Z_\' -]+$|'); $fieldSet->addText($fn . 'credit_card__billing_address__street_address') ->setLabel(___('Street Address')) ->addRule('required', ___('Please enter Street Address')); $fieldSet->addText($fn . 'credit_card__billing_address__extended_address') ->setLabel(___('Street Address (Second Line)')); $fieldSet->addText($fn . 'credit_card__billing_address__locality') ->setLabel(___('City')); $fieldSet->addText($fn . 'credit_card__billing_address__postal_code') ->setLabel(___('Zipcode')) ->addRule('required', ___('Please enter ZIP code')); $country = $fieldSet->addSelect($fn . 'credit_card__billing_address__country_name')->setLabel(___('Country')) ->setId('f_cc_country') ->loadOptions(Am_Di::getInstance()->countryTable->getOptions(true)); $country->addRule('required', ___('Please enter Country')); $group = $fieldSet->addGroup()->setLabel(___('State')); $group->addRule('required', ___('Please enter State')); $stateSelect = $group->addSelect($fn . 'credit_card__billing_address__region') ->setId('f_cc_state') ->loadOptions($stateOptions = Am_Di::getInstance()->stateTable->getOptions(@$_REQUEST['cc_country'], true)); $stateText = $group->addText($fn . 'credit_card__billing_address__region')->setId('t_cc_state'); $disableObj = $stateOptions ? $stateText : $stateSelect; $disableObj->setAttribute('disabled', 'disabled')->setAttribute('style', 'display: none'); } function createFormHosted() { if ($this->formType == self::PAYFORM) $fn = 'customer__'; else $fn = ''; $this->addHTML() ->setHTML("
") ->setLabel(___('Credit Card Number'), ___('for example: 1111222233334444')); $this->addHTML()->setHTML("
") ->setLabel(___("Card Expire\n" . 'Card expiration date - month and year')); $this->addHTML()->setHTML("
") ->setLabel(___("Credit Card Code\n" . 'The "Card Code" is a three- or four-digit security code that ' . 'is printed on the back of credit cards in the card\'s ' . 'signature panel (or on the front for American Express cards).')); $this->addHidden('nonce', array('id' => 'nonce')); $fieldSet = $this->addFieldset(___('Address Info')) ->setLabel(___("Address Info\n" . '(must match your credit card statement delivery address)')); $bname = $fieldSet->addGroup()->setLabel(___("Billing Name\n" . 'Billing Address First and Last name')); $bname->addRule('required', ___('Please enter billing name')); $bname->addText($fn . 'credit_card__billing_address__first_name', array('size' => 15)) ->addRule('required', ___('Please enter first name')) ->addRule('regex', ___('Please enter first name'), '|^[a-zA-Z_\' -]+$|'); $bname->addText($fn . 'credit_card__billing_address__last_name', array('size' => 15)) ->addRule('required', ___('Please enter last name')) ->addRule('regex', ___('Please enter last name'), '|^[a-zA-Z_\' -]+$|'); $fieldSet->addText($fn . 'credit_card__billing_address__street_address') ->setLabel(___('Street Address')) ->addRule('required', ___('Please enter Street Address')); $fieldSet->addText($fn . 'credit_card__billing_address__extended_address') ->setLabel(___('Street Address (Second Line)')); $fieldSet->addText($fn . 'credit_card__billing_address__locality') ->setLabel(___('City')); $fieldSet->addText($fn . 'credit_card__billing_address__postal_code') ->setLabel(___('Zipcode')) ->addRule('required', ___('Please enter ZIP code')); $country = $fieldSet->addSelect($fn . 'credit_card__billing_address__country_name')->setLabel(___('Country')) ->setId('f_cc_country') ->loadOptions(Am_Di::getInstance()->countryTable->getOptions(true)); $country->addRule('required', ___('Please enter Country')); $group = $fieldSet->addGroup()->setLabel(___('State')); $group->addRule('required', ___('Please enter State')); $stateSelect = $group->addSelect($fn . 'credit_card__billing_address__region') ->setId('f_cc_state') ->loadOptions($stateOptions = Am_Di::getInstance()->stateTable->getOptions(@$_REQUEST['cc_country'], true)); $stateText = $group->addText($fn . 'credit_card__billing_address__region')->setId('t_cc_state'); $disableObj = $stateOptions ? $stateText : $stateSelect; $disableObj->setAttribute('disabled', 'disabled')->setAttribute('style', 'display: none'); $clientToken = \Braintree\ClientToken::generate(); $this->addScript()->setScript(<<'+msg+''); } braintree.client.create({ authorization: '{$clientToken}', }, function (err, clientInstance) { if(err){ formError(err); return; } braintree.hostedFields.create({ client: clientInstance, styles: { 'input': { 'font-size': '14px' }, 'input.invalid': { 'color': 'red' }, 'input.valid': { 'color': 'green' } }, fields: { number: { selector: '#cc-number', placeholder: '4111 1111 1111 1111' }, cvv: { selector: '#cc-cvv', placeholder: '123' }, expirationDate: { selector: '#cc-expire', placeholder: '10/2019' }, } }, function (hostedFieldsErr, hostedFieldsInstance) { if (hostedFieldsErr) { formError(hostedFieldsErr); return; } submit.prop('disabled', ''); frm.on('submit', function (event) { if(frm.find('#nonce').val()) return; event.preventDefault(); hostedFieldsInstance.tokenize({vault: true}, function (tokenizeErr, payload) { if (tokenizeErr) { console.log(tokenizeErr); formError(tokenizeErr); return; } frm.find('#nonce').val(payload.nonce); frm.submit(); }); }); }); }); }); CUT ); } public function getDefaultValuesSalem(\Braintree\Customer $user) { if ($this->formType == self::PAYFORM) $fn = 'customer__'; else $fn = ''; return array_merge(array( $fn . 'credit_card__cardholder_name' => strtoupper($user->creditCards[0]->cardholderName), $fn . 'credit_card__number' => preg_replace("/[0-9]/", "*", substr($user->creditCards[0]->maskedNumber, 0, -4)) . substr($user->creditCards[0]->maskedNumber, -4), //display last 4 digits $fn . 'credit_card__expiration_month' => strtoupper($user->creditCards[0]->expirationMonth), //displayed empty $fn . 'credit_card__expiration_year' => $user->creditCards[0]->expirationYear - 2000, //since drop down only has last 2 digits of a year BUT displayed empty ), array( $fn . 'credit_card__billing_address__first_name' => strtoupper($user->creditCards[0]->billingAddress->firstName?:$user->firstName), $fn . 'credit_card__billing_address__last_name' => strtoupper($user->creditCards[0]->billingAddress->lastName?:$user->lastName), $fn . 'credit_card__billing_address__street_address' => strtoupper($user->creditCards[0]->billingAddress->streetAddress), //address1 $fn . 'credit_card__billing_address__extended_address' => strtoupper($user->creditCards[0]->billingAddress->extendedAddress), //address 2 $fn . 'credit_card__billing_address__locality' => strtoupper($user->creditCards[0]->billingAddress->locality), $fn . 'credit_card__billing_address__region' => $user->creditCards[0]->billingAddress->region, //state $fn . 'credit_card__billing_address__postal_code' => $user->creditCards[0]->billingAddress->postalCode, //zipcode $fn . 'credit_card__billing_address__country_name' => $user->creditCards[0]->billingAddress->countryCodeAlpha2, // getting the country for dropdown ) ); } public function getDefaultValues(User $user) { if ($this->formType == self::PAYFORM) $fn = 'customer__'; else $fn = ''; return array( $fn . 'credit_card__cardholder_name' => strtoupper($user->name_f . ' ' . $user->name_l), $fn . 'credit_card__billing_address__first_name' => $user->name_f, $fn . 'credit_card__billing_address__last_name' => $user->name_l, $fn . 'credit_card__billing_address__street_address' => $user->street, $fn . 'credit_card__billing_address__extended_address' => $user->street2, $fn . 'credit_card__billing_address__locality' => $user->city, $fn . 'credit_card__billing_address__region' => $user->state, $fn . 'credit_card__billing_address__postal_code' => $user->zip, $fn . 'credit_card__billing_address__country_name' => $user->country, ); } private function getMonthOptions() { $locale = Am_Di::getInstance()->locale; $months = array(); foreach ($locale->getMonthNames('wide', false) as $k => $v) $months[sprintf('%02d', $k)] = sprintf('(%02d) %s', $k, $v); $months[''] = ''; ksort($months); return $months; } private function getYearOptions() { $years4 = range(date('Y'), date('Y') + 10); $years2 = range(date('y'), date('y') + 10); array_unshift($years4, ''); array_unshift($years2, ''); return array_combine($years2, $years4); } } class Am_Mvc_Controller_CreditCard_Braintree extends Am_Mvc_Controller_CreditCard { function preDispatch() { parent::preDispatch(); if ($this->plugin->getConfig('hosted')) { $this->view->headScript() ->appendFile('https://js.braintreegateway.com/web/3.5.0/js/client.min.js') ->appendFile('https://js.braintreegateway.com/web/3.5.0/js/hosted-fields.min.js') ->appendFile('https://js.braintreegateway.com/web/3.5.0/js/paypal.min.js') ->appendFile('https://js.braintreegateway.com/web/3.5.0/js/data-collector.min.js'); $this->view->headStyle()->appendStyle(" .hosted-field { padding: 0.5em; border-radius: 3px; border: 1px solid #c2c2c2; height: 30px; box-sizing: border-box; display: inline-block; box-shadow: none; font-size: 14px; } "); } } function addClientToken(Am_Form_CreditCard_Braintree $form, User $user = null) { if (empty($user) && $this->invoice) $user = $this->invoice->getUser(); $customerId = $user->data()->get(Am_Paysystem_Braintree::CUSTOMER_ID); if (empty($customerId)) { $customers = \Braintree\Customer::search([ \Braintree\CustomerSearch::email()->is($user->email) ]); if ($customers->maximumCount()) $customerId = $customers->firstItem()->id; } if (empty($customerId)) { // Create it; $result = \Braintree\Customer::create([ 'email' => $user->email, 'firstName' => $user->name_f, 'lastName' => $user->name_l, ]); if ($result->success) { $customerId = $result->customer->id; } } if (empty($customerId)) throw new Am_Exception_InternalError("Unable to create/get customer token! Can't continue"); $user->data()->set(Am_Paysystem_Braintree::CUSTOMER_ID, $customerId)->update(); $clientToken = \Braintree\ClientToken::generate(array('customerId' => $customerId)); $form->addScript()->setScript("var clientToken = '{$clientToken}';"); } function createForm() { $form = $this->plugin->createForm(Am_Form_CreditCard::PAYFORM, $this->invoice); $form->addHidden(Am_Mvc_Controller::ACTION_KEY)->setValue($this->_request->getActionName()); $form->addHidden('cc_id')->setValue($this->getFiltered('cc_id')); $user = $this->invoice->getUser(); $form->setDataSources(array( $this->_request, new HTML_QuickForm2_DataSource_Array($form->getDefaultValues($user)) )); if (!$this->plugin->getConfig('hosted')) $form->addHidden('tr_data')->setValue( \Braintree\TransparentRedirect::createCustomerData(array( 'redirectUrl' => $this->plugin->getPluginUrl(Am_Paysystem_Braintree::ACTION_CC) . "?cc_id=" . $this->getFiltered('cc_id'), 'customer' => array( 'firstName' => $this->invoice->getUser()->name_f, 'lastName' => $this->invoice->getUser()->name_l, 'email' => $this->invoice->getUser()->email, 'phone' => $this->invoice->getUser()->phone, ) )) ); else { // $this->addClientToken($form); $form->setAction($this->plugin->getPluginUrl(Am_Paysystem_Braintree::ACTION_CC)); } return $form; } public function createUpdateForm() { $user = $this->getDi()->auth->getUser(true); if (!$user) throw new Am_Exception_InputError("You are not logged-in"); if (!($bid = $user->data()->get(Am_Paysystem_Braintree::CUSTOMER_ID))) throw new Am_Exception_Paysystem('Customer braintree id is empty'); if (!($bt_member = \Braintree\Customer::find($bid))) throw new Am_Exception_Paysystem('Wrong customer braintree id'); if (!($token = $bt_member->creditCards[0]->token)) throw new Am_Exception_Paysystem('Empty token for credit card'); $form = $this->plugin->createForm(Am_Form_CreditCard::USER_UPDATE); $elements = $form->getElements(); $form->setDataSources(array( $this->_request, new HTML_QuickForm2_DataSource_Array($r = $form->getDefaultValuesSalem($bt_member)) )); $form->insertBefore( (new Am_Form_Element_Html()) ->setHTML(sprintf("%s exp. %s/%s", $r['credit_card__number'], $r['credit_card__expiration_month'], $r['credit_card__expiration_year'])) ->setLabel(___('Current Credit Card Info')), array_shift($elements) ); if (!$this->plugin->getConfig('hosted')) $form->addHidden('tr_data')->setValue( \Braintree\TransparentRedirect::updateCreditCardData(array( 'redirectUrl' => $this->plugin->getPluginUrl(Am_Paysystem_Braintree::ACTION_UPDATE), 'paymentMethodToken' => $token, 'creditCard' => array( 'billingAddress' => array( 'options' => array( 'updateExisting' => true ) ) ) )) ); else { //$this->addClientToken($form, $user); $form->setAction($this->plugin->getPluginUrl(Am_Paysystem_Braintree::ACTION_UPDATE)); } return $form; } public function ccAction() { // invoice must be set to this point by the plugin if (!$this->invoice) throw new Am_Exception_InternalError('Empty invoice - internal error!'); $this->form = $this->createForm(); if (($this->getParam('http_status') && $this->getParam('hash')) || ($this->plugin->getConfig('hosted') && $this->getParam('nonce'))) { if ($this->processCc()) return; } $this->view->form = $this->form; $this->view->invoice = $this->invoice; $this->view->display_receipt = true; $this->view->display('cc/info.phtml'); } public function updateAction() { $this->form = $this->createUpdateForm(); if ($this->getParam('http_status') && $this->getParam('hash')) { $res = \Braintree\TransparentRedirect::confirm($_SERVER['QUERY_STRING']); if ($res instanceof \Braintree\Result\Error) { $this->form->getElementById('credit_card__number-0')->setError($res->message); } else { return $this->_response->redirectLocation($this->getDi()->url('member', null, false)); } } else if ($this->plugin->getConfig('hosted') && $this->getParam('nonce')) { $user = $this->getDi()->auth->getUser(true); if (!$user) throw new Am_Exception_InputError("You are not logged-in"); if (!($bid = $user->data()->get(Am_Paysystem_Braintree::CUSTOMER_ID))) throw new Am_Exception_Paysystem('Customer braintree id is empty'); if (!($bt_member = \Braintree\Customer::find($bid))) throw new Am_Exception_Paysystem('Wrong customer braintree id'); if (!($token = $bt_member->creditCards[0]->token)) throw new Am_Exception_Paysystem('Empty token for credit card'); $result = Braintree_Customer::update( $bid, array( 'firstName' => $user->name_f, 'lastName' => $user->name_l, 'email' => $user->email, 'creditCard' => array( 'paymentMethodNonce' => $this->getParam('nonce'), 'options' => array( 'updateExistingToken' => $token ), 'billingAddress' => array( 'streetAddress' => $this->getParam('credit_card__billing_address__street_address'), 'extendedAddress' => $this->getParam('credit_card__billing_address__extended_address'), 'locality' => $this->getParam('credit_card__billing_address__locality'), 'region' => $this->getParam('credit_card__billing_address__region'), 'postalCode' => $this->getParam('credit_card__billing_address__postal_code'), 'countryCodeAlpha2' => $this->getParam('credit_card__billing_address__country_name'), 'options' => array( 'updateExisting' => true ) ) ) ) ); if ($result->success) return $this->_response->redirectLocation($this->getDi()->url('member', null, false)); $error_text = ''; if ($errors = $result->errors->deepAll()) { if (!is_array($errors)) $errors = array($errors); foreach ($errors as $error) { $error_text .= $error->message; } $this->view->error = "Error: " . @$error_text; } } $this->view->form = $this->form; $this->view->invoice = null; $this->view->display_receipt = false; $this->view->display('cc/info.phtml'); } } class Am_Paysystem_Transaction_CreditCard_Braintree extends Am_Paysystem_Transaction_CreditCard { protected $paysystemResponse; public function getUniqId() { return $this->paysystemResponse->transaction->id; } public function getRequest() { } public function submitTransaction($request) { } public function validate() { } public function run(Am_Paysystem_Result $result) { $this->result = $result; $log = $this->getInvoiceLog(); $request = $this->getRequest(); $log->add($request); $this->paysystemResponse = $this->submitTransaction($request); $log->add($this->paysystemResponse); if ($this->paysystemResponse->success) { try { $result->setSuccess($this); $this->processValidated(); } catch (Exception $e) { if ($e instanceof PHPUnit_Framework_Error) throw $e; if ($e instanceof PHPUnit_Framework_Asser) throw $e; if (!$result->isFailure()) $result->setFailed(___("Payment failed")); $log->add($e); } }else { $error_text = ''; if ($errors = $this->paysystemResponse->errors->deepAll()) { if (!is_array($errors)) $errors = array($errors); foreach ($errors as $error) { $error_text .= $error->message; } $result->setFailed("Error: " . @$error_text); } else if ($this->paysystemResponse->transaction->status == 'processor_declined') { $result->setFailed("Declined: " . $this->paysystemResponse->transaction->processorResponseText); } else { $result->setFailed("Gateway Rejected: " . $this->paysystemResponse->transaction->gatewayRejectionReason); } } } public function parseResponse() { } } class Am_Paysystem_Transaction_CreditCard_Braintree_Sale extends Am_Paysystem_Transaction_CreditCard_Braintree { function getRequest() { $vars = array( 'amount' => ($this->doFirst ? $this->invoice->first_total : $this->invoice->second_total), 'customerId' => $this->invoice->getUser()->data()->get(Am_Paysystem_Braintree::CUSTOMER_ID), 'orderId' => $this->invoice->public_id . '-' . time(), 'options' => array( 'submitForSettlement' => true ) ); if ($this->plugin->getConfig('multicurrency')) { $vars['merchantAccountId'] = $this->invoice->getItem(0)->getBillingPlanData('braintree_merchant_account_id')?:$this->plugin->getConfig('merchant_account_id'); } elseif ($id = $this->plugin->getConfig('merchant_account_id')) $vars['merchantAccountId'] = $id; return $vars; } function submitTransaction($request) { return \Braintree\Transaction::sale($request); } } class Am_Paysystem_Transaction_CreditCard_Braintree_SaleHosted extends Am_Paysystem_Transaction_CreditCard_Braintree { protected $cc; function setCC($cc) { $this->cc = $cc; } function getRequest() { $vars = array( 'amount' => ($this->doFirst ? $this->invoice->first_total : $this->invoice->second_total), 'orderId' => $this->invoice->public_id . '-' . time(), 'paymentMethodNonce' => $this->cc->nonce, 'options' => array( 'submitForSettlement' => true, 'storeInVaultOnSuccess' => true, 'addBillingAddressToPaymentMethod' => true, ), 'customer' => array( 'firstName' => $this->invoice->getFirstName(), 'lastName' => $this->invoice->getLastName(), 'email' => $this->invoice->getEmail() ), 'billing' => array( 'streetAddress' => $this->cc->customer__credit_card__billing_address__street_address, 'extendedAddress' => $this->cc->customer__credit_card__billing_address__extended_address, 'locality' => $this->cc->customer__credit_card__billing_address__locality, 'region' => $this->cc->customer__credit_card__billing_address__region, 'postalCode' => $this->cc->customer__credit_card__billing_address__postal_code, 'countryCodeAlpha2' => $this->cc->customer__credit_card__billing_address__country_name ), ); return $vars; } function submitTransaction($request) { return \Braintree\Transaction::sale($request); } function processValidated() { $this->invoice->getUser()->data()->set(Am_Paysystem_Braintree::CUSTOMER_ID, $this->paysystemResponse->transaction->customer['id'])->update(); parent::processValidated(); } } class Am_Paysystem_Transaction_CreditCard_Braintree_Refund extends Am_Paysystem_Transaction_CreditCard_Braintree { protected $payment; function __construct(Am_Paysystem_Abstract $plugin, Invoice $invoice, $request, $doFirst, $payment) { $this->payment = $payment; parent::__construct($plugin, $invoice, $request, $doFirst); } function getRequest() { return $this->payment->transaction_id; } function submitTransaction($request) { return \Braintree\Transaction::refund($request); } function processValidated() { $this->invoice->addRefund($this, $this->payment->transaction_id); } } class Am_Paysystem_Transaction_CreditCard_Braintree_Void extends Am_Paysystem_Transaction_CreditCard_Braintree { protected $payment; function __construct(Am_Paysystem_Abstract $plugin, Invoice $invoice, $request, $doFirst, $payment) { $this->payment = $payment; parent::__construct($plugin, $invoice, $request, $doFirst); } function getRequest() { return $this->payment->transaction_id; } function submitTransaction($request) { return \Braintree\Transaction::void($request); } function processValidated() { $this->invoice->addVoid($this, $this->payment->transaction_id); } } lib/Braintree/UsBankAccountGateway.php000064400000005712152101632460013765 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. */ class UsBankAccountGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } /** * find a usBankAccount by token * * @access public * @param string $token paypal accountunique id * @return UsBankAccount * @throws Exception\NotFound */ public function find($token) { try { $path = $this->_config->merchantPath() . '/payment_methods/us_bank_account/' . $token; $response = $this->_http->get($path); return UsBankAccount::factory($response['usBankAccount']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'US bank account with token ' . $token . ' not found' ); } } /** * create a new sale for the current UsBank account * * @param string $token * @param array $transactionAttribs * @return Result\Successful|Result\Error * @see Transaction::sale() */ public function sale($token, $transactionAttribs) { return Transaction::sale( array_merge( $transactionAttribs, ['paymentMethodToken' => $token] ) ); } /** * generic method for validating incoming gateway responses * * creates a new UsBankAccount object and encapsulates * it inside a Result\Successful object, or * encapsulates a Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid. * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['usBankAccount'])) { // return a populated instance of UsBankAccount return new Result\Successful( UsBankAccount::factory($response['usBankAccount']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( 'Expected US bank account or apiErrorResponse' ); } } } class_alias('Braintree\UsBankAccountGateway', 'Braintree_UsBankAccountGateway'); lib/Braintree/TransparentRedirect.php000064400000006043152101632460013724 0ustar00 * $trData = TransparentRedirect::createCustomerData(array( * 'redirectUrl => 'http://example.com/redirect_back_to_merchant_site', * )); * * * In addition to the redirectUrl, any data that needs to be protected * from user tampering should be included in the trData. * For example, to prevent the user from tampering with the transaction * amount, include the amount in the trData. * * * $trData = TransparentRedirect::transactionData(array( * 'redirectUrl' => 'http://example.com/complete_transaction', * 'transaction' => array('amount' => '100.00'), * )); * * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. */ class TransparentRedirect { // Request Kinds const CREATE_TRANSACTION = 'create_transaction'; const CREATE_PAYMENT_METHOD = 'create_payment_method'; const UPDATE_PAYMENT_METHOD = 'update_payment_method'; const CREATE_CUSTOMER = 'create_customer'; const UPDATE_CUSTOMER = 'update_customer'; /** * @ignore * don't permit an explicit call of the constructor! * (like $t = new TransparentRedirect()) */ protected function __construct() { } // static methods redirecting to gateway public static function confirm($queryString) { return Configuration::gateway()->transparentRedirect()->confirm($queryString); } public static function createCreditCardData($params) { return Configuration::gateway()->transparentRedirect()->createCreditCardData($params); } public static function createCustomerData($params) { return Configuration::gateway()->transparentRedirect()->createCustomerData($params); } public static function url() { return Configuration::gateway()->transparentRedirect()->url(); } public static function transactionData($params) { return Configuration::gateway()->transparentRedirect()->transactionData($params); } public static function updateCreditCardData($params) { return Configuration::gateway()->transparentRedirect()->updateCreditCardData($params); } public static function updateCustomerData($params) { return Configuration::gateway()->transparentRedirect()->updateCustomerData($params); } public static function parseAndValidateQueryString($queryString) { return Configuration::gateway()->transparentRedirect()->parseAndValidateQueryString($queryString); } } class_alias('Braintree\TransparentRedirect', 'Braintree_TransparentRedirect'); lib/Braintree/Digest.php000064400000003200152101632460011150 0ustar00disbursementDate); } } class_alias('Braintree\DisbursementDetails', 'Braintree_DisbursementDetails'); lib/Braintree/ResourceCollection.php000064400000006621152101632460013546 0ustar00 * $result = Customer::all(); * * foreach($result as $transaction) { * print_r($transaction->id); * } * * * @package Braintree * @subpackage Utility * @copyright 2015 Braintree, a division of PayPal, Inc. */ class ResourceCollection implements Iterator { private $_batchIndex; private $_ids; private $_index; private $_items; private $_pageSize; private $_pager; /** * set up the resource collection * * expects an array of attributes with literal keys * * @param array $response * @param array $pager */ public function __construct($response, $pager) { $this->_pageSize = $response["searchResults"]["pageSize"]; $this->_ids = $response["searchResults"]["ids"]; $this->_pager = $pager; } /** * returns the current item when iterating with foreach */ public function current() { return $this->_items[$this->_index]; } /** * returns the first item in the collection * * @return mixed */ public function firstItem() { $ids = $this->_ids; $page = $this->_getPage([$ids[0]]); return $page[0]; } public function key() { return null; } /** * advances to the next item in the collection when iterating with foreach */ public function next() { ++$this->_index; } /** * rewinds the testIterateOverResults collection to the first item when iterating with foreach */ public function rewind() { $this->_batchIndex = 0; $this->_getNextPage(); } /** * returns whether the current item is valid when iterating with foreach */ public function valid() { if ($this->_index == count($this->_items) && $this->_batchIndex < count($this->_ids)) { $this->_getNextPage(); } if ($this->_index < count($this->_items)) { return true; } else { return false; } } public function maximumCount() { return count($this->_ids); } private function _getNextPage() { if (empty($this->_ids)) { $this->_items = []; } else { $this->_items = $this->_getPage(array_slice($this->_ids, $this->_batchIndex, $this->_pageSize)); $this->_batchIndex += $this->_pageSize; $this->_index = 0; } } /** * requests the next page of results for the collection * * @return void */ private function _getPage($ids) { $object = $this->_pager['object']; $method = $this->_pager['method']; $methodArgs = []; foreach ($this->_pager['methodArgs'] as $arg) { array_push($methodArgs, $arg); } array_push($methodArgs, $ids); return call_user_func_array( [$object, $method], $methodArgs ); } /** * returns all IDs in the collection * * @return array */ public function getIds() { return $this->_ids; } } class_alias('Braintree\ResourceCollection', 'Braintree_ResourceCollection'); lib/Braintree/Util.php000064400000035063152101632460010662 0ustar00success) { return $resultObj->$resultObjName; } else { throw new Exception\ValidationsFailed(); } } /** * removes the header from a classname * * @param string $name ClassName * @return camelCased classname minus header */ public static function cleanClassName($name) { $classNamesToResponseKeys = [ 'Braintree\CreditCard' => 'creditCard', 'Braintree_CreditCard' => 'creditCard', 'Braintree\CreditCardGateway' => 'creditCard', 'Braintree_CreditCardGateway' => 'creditCard', 'Braintree\Customer' => 'customer', 'Braintree_Customer' => 'customer', 'Braintree\CustomerGateway' => 'customer', 'Braintree_CustomerGateway' => 'customer', 'Braintree\Subscription' => 'subscription', 'Braintree_Subscription' => 'subscription', 'Braintree\SubscriptionGateway' => 'subscription', 'Braintree_SubscriptionGateway' => 'subscription', 'Braintree\Transaction' => 'transaction', 'Braintree_Transaction' => 'transaction', 'Braintree\TransactionGateway' => 'transaction', 'Braintree_TransactionGateway' => 'transaction', 'Braintree\CreditCardVerification' => 'verification', 'Braintree_CreditCardVerification' => 'verification', 'Braintree\CreditCardVerificationGateway' => 'verification', 'Braintree_CreditCardVerificationGateway' => 'verification', 'Braintree\AddOn' => 'addOn', 'Braintree_AddOn' => 'addOn', 'Braintree\AddOnGateway' => 'addOn', 'Braintree_AddOnGateway' => 'addOn', 'Braintree\Discount' => 'discount', 'Braintree_Discount' => 'discount', 'Braintree\DiscountGateway' => 'discount', 'Braintree_DiscountGateway' => 'discount', 'Braintree\Plan' => 'plan', 'Braintree_Plan' => 'plan', 'Braintree\PlanGateway' => 'plan', 'Braintree_PlanGateway' => 'plan', 'Braintree\Address' => 'address', 'Braintree_Address' => 'address', 'Braintree\AddressGateway' => 'address', 'Braintree_AddressGateway' => 'address', 'Braintree\SettlementBatchSummary' => 'settlementBatchSummary', 'Braintree_SettlementBatchSummary' => 'settlementBatchSummary', 'Braintree\SettlementBatchSummaryGateway' => 'settlementBatchSummary', 'Braintree_SettlementBatchSummaryGateway' => 'settlementBatchSummary', 'Braintree\Merchant' => 'merchant', 'Braintree_Merchant' => 'merchant', 'Braintree\MerchantGateway' => 'merchant', 'Braintree_MerchantGateway' => 'merchant', 'Braintree\MerchantAccount' => 'merchantAccount', 'Braintree_MerchantAccount' => 'merchantAccount', 'Braintree\MerchantAccountGateway' => 'merchantAccount', 'Braintree_MerchantAccountGateway' => 'merchantAccount', 'Braintree\OAuthCredentials' => 'credentials', 'Braintree_OAuthCredentials' => 'credentials', 'Braintree\OAuthResult' => 'result', 'Braintree_OAuthResult' => 'result', 'Braintree\PayPalAccount' => 'paypalAccount', 'Braintree_PayPalAccount' => 'paypalAccount', 'Braintree\PayPalAccountGateway' => 'paypalAccount', 'Braintree_PayPalAccountGateway' => 'paypalAccount', ]; return $classNamesToResponseKeys[$name]; } /** * * @param string $name className * @return string ClassName */ public static function buildClassName($name) { $responseKeysToClassNames = [ 'creditCard' => 'Braintree\CreditCard', 'customer' => 'Braintree\Customer', 'subscription' => 'Braintree\Subscription', 'transaction' => 'Braintree\Transaction', 'verification' => 'Braintree\CreditCardVerification', 'addOn' => 'Braintree\AddOn', 'discount' => 'Braintree\Discount', 'plan' => 'Braintree\Plan', 'address' => 'Braintree\Address', 'settlementBatchSummary' => 'Braintree\SettlementBatchSummary', 'merchantAccount' => 'Braintree\MerchantAccount', ]; return (string) $responseKeysToClassNames[$name]; } /** * convert alpha-beta-gamma to alphaBetaGamma * * @access public * @param string $string * @param null|string $delimiter * @return string modified string */ public static function delimiterToCamelCase($string, $delimiter = '[\-\_]') { // php doesn't garbage collect functions created by create_function() // so use a static variable to avoid adding a new function to memory // every time this function is called. static $callback = null; if ($callback === null) { $callback = create_function('$matches', 'return strtoupper($matches[1]);'); } return preg_replace_callback('/' . $delimiter . '(\w)/', $callback, $string); } /** * convert alpha-beta-gamma to alpha_beta_gamma * * @access public * @param string $string * @return string modified string */ public static function delimiterToUnderscore($string) { return preg_replace('/-/', '_', $string); } /** * find capitals and convert to delimiter + lowercase * * @access public * @param string $string * @param null|string $delimiter * @return string modified string */ public static function camelCaseToDelimiter($string, $delimiter = '-') { return strtolower(preg_replace('/([A-Z])/', "$delimiter\\1", $string)); } public static function delimiterToCamelCaseArray($array, $delimiter = '[\-\_]') { $converted = []; foreach ($array as $key => $value) { if (is_string($key)) { $key = self::delimiterToCamelCase($key, $delimiter); } if (is_array($value)) { // Make an exception for custom fields, which must be underscore (can't be // camelCase). if ($key === 'customFields') { $value = self::delimiterToUnderscoreArray($value); } else { $value = self::delimiterToCamelCaseArray($value, $delimiter); } } $converted[$key] = $value; } return $converted; } public static function camelCaseToDelimiterArray($array, $delimiter = '-') { $converted = []; foreach ($array as $key => $value) { if (is_string($key)) { $key = self::camelCaseToDelimiter($key, $delimiter); } if (is_array($value)) { $value = self::camelCaseToDelimiterArray($value, $delimiter); } $converted[$key] = $value; } return $converted; } public static function delimiterToUnderscoreArray($array) { $converted = []; foreach ($array as $key => $value) { $key = self::delimiterToUnderscore($key); $converted[$key] = $value; } return $converted; } /** * * @param array $array associative array to implode * @param string $separator (optional, defaults to =) * @param string $glue (optional, defaults to ', ') * @return bool */ public static function implodeAssociativeArray($array, $separator = '=', $glue = ', ') { // build a new array with joined keys and values $tmpArray = null; foreach ($array AS $key => $value) { if ($value instanceof DateTime) { $value = $value->format('r'); } $tmpArray[] = $key . $separator . $value; } // implode and return the new array return (is_array($tmpArray)) ? implode($glue, $tmpArray) : false; } public static function attributesToString($attributes) { $printableAttribs = []; foreach ($attributes AS $key => $value) { if (is_array($value)) { $pAttrib = self::attributesToString($value); } else if ($value instanceof DateTime) { $pAttrib = $value->format(DateTime::RFC850); } else { $pAttrib = $value; } $printableAttribs[$key] = sprintf('%s', $pAttrib); } return self::implodeAssociativeArray($printableAttribs); } /** * verify user request structure * * compares the expected signature of a gateway request * against the actual structure sent by the user * * @param array $signature * @param array $attributes */ public static function verifyKeys($signature, $attributes) { $validKeys = self::_flattenArray($signature); $userKeys = self::_flattenUserKeys($attributes); $invalidKeys = array_diff($userKeys, $validKeys); $invalidKeys = self::_removeWildcardKeys($validKeys, $invalidKeys); if(!empty($invalidKeys)) { asort($invalidKeys); $sortedList = join(', ', $invalidKeys); throw new InvalidArgumentException('invalid keys: ' . $sortedList); } } /** * flattens a numerically indexed nested array to a single level * @param array $keys * @param string $namespace * @return array */ private static function _flattenArray($keys, $namespace = null) { $flattenedArray = []; foreach($keys AS $key) { if(is_array($key)) { $theKeys = array_keys($key); $theValues = array_values($key); $scope = $theKeys[0]; $fullKey = empty($namespace) ? $scope : $namespace . '[' . $scope . ']'; $flattenedArray = array_merge($flattenedArray, self::_flattenArray($theValues[0], $fullKey)); } else { $fullKey = empty($namespace) ? $key : $namespace . '[' . $key . ']'; $flattenedArray[] = $fullKey; } } sort($flattenedArray); return $flattenedArray; } private static function _flattenUserKeys($keys, $namespace = null) { $flattenedArray = []; foreach($keys AS $key => $value) { $fullKey = empty($namespace) ? $key : $namespace; if (!is_numeric($key) && $namespace != null) { $fullKey .= '[' . $key . ']'; } if (is_numeric($key) && is_string($value)) { $fullKey .= '[' . $value . ']'; } if(is_array($value)) { $more = self::_flattenUserKeys($value, $fullKey); $flattenedArray = array_merge($flattenedArray, $more); } else { $flattenedArray[] = $fullKey; } } sort($flattenedArray); return $flattenedArray; } /** * removes wildcard entries from the invalid keys array * @param array $validKeys * @param $invalidKey) { if (stristr($invalidKey, $wildcardKey)) { unset($invalidKeys[$index]); } } } } return $invalidKeys; } } class_alias('Braintree\Util', 'Braintree_Util'); lib/Braintree/DiscountGateway.php000064400000001350152101632460013047 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function all() { $path = $this->_config->merchantPath() . '/discounts'; $response = $this->_http->get($path); $discounts = ["discount" => $response['discounts']]; return Util::extractAttributeAsArray( $discounts, 'discount' ); } } class_alias('Braintree\DiscountGateway', 'Braintree_DiscountGateway'); lib/Braintree/OAuthResult.php000064400000001416152101632460012157 0ustar00_attributes = $attribs; } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /** * returns a string representation of the result * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } } class_alias('Braintree\OAuthResult', 'Braintree_OAuthResult'); lib/Braintree/RiskData.php000064400000001161152101632460011437 0ustar00_initialize($attributes); return $instance; } protected function _initialize($attributes) { $this->_attributes = $attributes; } /** * returns a string representation of the risk data * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } } class_alias('Braintree\RiskData', 'Braintree_RiskData'); lib/Braintree/Exception/SSLCaFileNotFound.php000064400000000561152101632460015060 0ustar00== More information == * * For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api} * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read array $addresses * @property-read array $paymentMethods * @property-read string $company * @property-read string $createdAt * @property-read array $creditCards * @property-read array $paypalAccounts * @property-read array $applePayCards * @property-read array $androidPayCards * @property-read array $amexExpressCheckoutCards * @property-read array $venmoAccounts * @property-read array $coinbaseAccounts * @property-read array $customFields custom fields passed with the request * @property-read string $email * @property-read string $fax * @property-read string $firstName * @property-read string $id * @property-read string $lastName * @property-read string $phone * @property-read string $updatedAt * @property-read string $website */ class Customer extends Base { /** * * @return Customer[] */ public static function all() { return Configuration::gateway()->customer()->all(); } /** * * @param string $query * @param int[] $ids * @return Customer|Customer[] */ public static function fetch($query, $ids) { return Configuration::gateway()->customer()->fetch($query, $ids); } /** * * @param array $attribs * @return Result\Successful|Result\Error */ public static function create($attribs = []) { return Configuration::gateway()->customer()->create($attribs); } /** * * @param array $attribs * @return Customer */ public static function createNoValidate($attribs = []) { return Configuration::gateway()->customer()->createNoValidate($attribs); } /** * @deprecated since version 2.3.0 * @param string $queryString * @return Result\Successful */ public static function createFromTransparentRedirect($queryString) { return Configuration::gateway()->customer()->createFromTransparentRedirect($queryString); } /** * @deprecated since version 2.3.0 * @return string */ public static function createCustomerUrl() { return Configuration::gateway()->customer()->createCustomerUrl(); } /** * * @throws Exception\NotFound * @param string $id customer id * @return Customer */ public static function find($id) { return Configuration::gateway()->customer()->find($id); } /** * * @param int $customerId * @param array $transactionAttribs * @return Result\Successful|Result\Error */ public static function credit($customerId, $transactionAttribs) { return Configuration::gateway()->customer()->credit($customerId, $transactionAttribs); } /** * * @throws Exception\ValidationError * @param type $customerId * @param type $transactionAttribs * @return Transaction */ public static function creditNoValidate($customerId, $transactionAttribs) { return Configuration::gateway()->customer()->creditNoValidate($customerId, $transactionAttribs); } /** * * @throws Exception on invalid id or non-200 http response code * @param int $customerId * @return Result\Successful */ public static function delete($customerId) { return Configuration::gateway()->customer()->delete($customerId); } /** * * @param int $customerId * @param array $transactionAttribs * @return Transaction */ public static function sale($customerId, $transactionAttribs) { return Configuration::gateway()->customer()->sale($customerId, $transactionAttribs); } /** * * @param int $customerId * @param array $transactionAttribs * @return Transaction */ public static function saleNoValidate($customerId, $transactionAttribs) { return Configuration::gateway()->customer()->saleNoValidate($customerId, $transactionAttribs); } /** * * @throws InvalidArgumentException * @param string $query * @return ResourceCollection */ public static function search($query) { return Configuration::gateway()->customer()->search($query); } /** * * @throws Exception\Unexpected * @param int $customerId * @param array $attributes * @return Result\Successful|Result\Error */ public static function update($customerId, $attributes) { return Configuration::gateway()->customer()->update($customerId, $attributes); } /** * * @throws Exception\Unexpected * @param int $customerId * @param array $attributes * @return CustomerGateway */ public static function updateNoValidate($customerId, $attributes) { return Configuration::gateway()->customer()->updateNoValidate($customerId, $attributes); } /** * * @deprecated since version 2.3.0 * @return string */ public static function updateCustomerUrl() { return Configuration::gateway()->customer()->updateCustomerUrl(); } /** * * @deprecated since version 2.3.0 * @param string $queryString * @return Result\Successful|Result\Error */ public static function updateFromTransparentRedirect($queryString) { return Configuration::gateway()->customer()->updateFromTransparentRedirect($queryString); } /* instance methods */ /** * sets instance properties from an array of values * * @ignore * @access protected * @param array $customerAttribs array of customer data */ protected function _initialize($customerAttribs) { $this->_attributes = $customerAttribs; $addressArray = []; if (isset($customerAttribs['addresses'])) { foreach ($customerAttribs['addresses'] AS $address) { $addressArray[] = Address::factory($address); } } $this->_set('addresses', $addressArray); $creditCardArray = []; if (isset($customerAttribs['creditCards'])) { foreach ($customerAttribs['creditCards'] AS $creditCard) { $creditCardArray[] = CreditCard::factory($creditCard); } } $this->_set('creditCards', $creditCardArray); $coinbaseAccountArray = []; if (isset($customerAttribs['coinbaseAccounts'])) { foreach ($customerAttribs['coinbaseAccounts'] AS $coinbaseAccount) { $coinbaseAccountArray[] = CoinbaseAccount::factory($coinbaseAccount); } } $this->_set('coinbaseAccounts', $coinbaseAccountArray); $paypalAccountArray = []; if (isset($customerAttribs['paypalAccounts'])) { foreach ($customerAttribs['paypalAccounts'] AS $paypalAccount) { $paypalAccountArray[] = PayPalAccount::factory($paypalAccount); } } $this->_set('paypalAccounts', $paypalAccountArray); $applePayCardArray = []; if (isset($customerAttribs['applePayCards'])) { foreach ($customerAttribs['applePayCards'] AS $applePayCard) { $applePayCardArray[] = ApplePayCard::factory($applePayCard); } } $this->_set('applePayCards', $applePayCardArray); $androidPayCardArray = []; if (isset($customerAttribs['androidPayCards'])) { foreach ($customerAttribs['androidPayCards'] AS $androidPayCard) { $androidPayCardArray[] = AndroidPayCard::factory($androidPayCard); } } $this->_set('androidPayCards', $androidPayCardArray); $amexExpressCheckoutCardArray = []; if (isset($customerAttribs['amexExpressCheckoutCards'])) { foreach ($customerAttribs['amexExpressCheckoutCards'] AS $amexExpressCheckoutCard) { $amexExpressCheckoutCardArray[] = AmexExpressCheckoutCard::factory($amexExpressCheckoutCard); } } $this->_set('amexExpressCheckoutCards', $amexExpressCheckoutCardArray); $venmoAccountArray = array(); if (isset($customerAttribs['venmoAccounts'])) { foreach ($customerAttribs['venmoAccounts'] AS $venmoAccount) { $venmoAccountArray[] = VenmoAccount::factory($venmoAccount); } } $this->_set('venmoAccounts', $venmoAccountArray); $usBankAccountArray = array(); if (isset($customerAttribs['usBankAccounts'])) { foreach ($customerAttribs['usBankAccounts'] AS $usBankAccount) { $usBankAccountArray[] = UsBankAccount::factory($usBankAccount); } } $this->_set('usBankAccounts', $usBankAccountArray); $this->_set('paymentMethods', array_merge( $this->creditCards, $this->paypalAccounts, $this->applePayCards, $this->coinbaseAccounts, $this->androidPayCards, $this->amexExpressCheckoutCards, $this->venmoAccounts, $this->usBankAccounts )); } /** * returns a string representation of the customer * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } /** * returns false if comparing object is not a Customer, * or is a Customer with a different id * * @param object $otherCust customer to compare against * @return boolean */ public function isEqual($otherCust) { return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id; } /** * returns an array containt all of the customer's payment methods * * @deprecated since version 3.1.0 - use the paymentMethods property directly * * @return array */ public function paymentMethods() { return $this->paymentMethods; } /** * returns the customer's default payment method * * @return CreditCard|PayPalAccount */ public function defaultPaymentMethod() { $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\Customer::_defaultPaymentMethodFilter'); return current($defaultPaymentMethods); } public static function _defaultPaymentMethodFilter($paymentMethod) { return $paymentMethod->isDefault(); } /* private class properties */ /** * @access protected * @var array registry of customer data */ protected $_attributes = [ 'addresses' => '', 'company' => '', 'creditCards' => '', 'email' => '', 'fax' => '', 'firstName' => '', 'id' => '', 'lastName' => '', 'phone' => '', 'createdAt' => '', 'updatedAt' => '', 'website' => '', ]; /** * factory method: returns an instance of Customer * to the requesting method, with populated properties * * @ignore * @param array $attributes * @return Customer */ public static function factory($attributes) { $instance = new Customer(); $instance->_initialize($attributes); return $instance; } } class_alias('Braintree\Customer', 'Braintree_Customer'); lib/Braintree/Subscription.php000064400000007656152101632460012440 0ustar00== More information == * * For more detailed information on Subscriptions, see {@link http://www.braintreepayments.com/gateway/subscription-api http://www.braintreepaymentsolutions.com/gateway/subscription-api} * * PHP Version 5 * * @package Braintree * @copyright 2015 Braintree, a division of PayPal, Inc. */ class Subscription extends Base { const ACTIVE = 'Active'; const CANCELED = 'Canceled'; const EXPIRED = 'Expired'; const PAST_DUE = 'Past Due'; const PENDING = 'Pending'; // Subscription Sources const API = 'api'; const CONTROL_PANEL = 'control_panel'; const RECURRING = 'recurring'; /** * @ignore */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /** * @ignore */ protected function _initialize($attributes) { $this->_attributes = $attributes; $addOnArray = []; if (isset($attributes['addOns'])) { foreach ($attributes['addOns'] AS $addOn) { $addOnArray[] = AddOn::factory($addOn); } } $this->_attributes['addOns'] = $addOnArray; $discountArray = []; if (isset($attributes['discounts'])) { foreach ($attributes['discounts'] AS $discount) { $discountArray[] = Discount::factory($discount); } } $this->_attributes['discounts'] = $discountArray; if (isset($attributes['descriptor'])) { $this->_set('descriptor', new Descriptor($attributes['descriptor'])); } $statusHistory = []; if (isset($attributes['statusHistory'])) { foreach ($attributes['statusHistory'] AS $history) { $statusHistory[] = new Subscription\StatusDetails($history); } } $this->_attributes['statusHistory'] = $statusHistory; $transactionArray = []; if (isset($attributes['transactions'])) { foreach ($attributes['transactions'] AS $transaction) { $transactionArray[] = Transaction::factory($transaction); } } $this->_attributes['transactions'] = $transactionArray; } /** * returns a string representation of the customer * @return string */ public function __toString() { $excludedAttributes = ['statusHistory']; $displayAttributes = []; foreach($this->_attributes as $key => $val) { if (!in_array($key, $excludedAttributes)) { $displayAttributes[$key] = $val; } } return __CLASS__ . '[' . Util::attributesToString($displayAttributes) .']'; } // static methods redirecting to gateway public static function create($attributes) { return Configuration::gateway()->subscription()->create($attributes); } public static function find($id) { return Configuration::gateway()->subscription()->find($id); } public static function search($query) { return Configuration::gateway()->subscription()->search($query); } public static function fetch($query, $ids) { return Configuration::gateway()->subscription()->fetch($query, $ids); } public static function update($subscriptionId, $attributes) { return Configuration::gateway()->subscription()->update($subscriptionId, $attributes); } public static function retryCharge($subscriptionId, $amount = null) { return Configuration::gateway()->subscription()->retryCharge($subscriptionId, $amount); } public static function cancel($subscriptionId) { return Configuration::gateway()->subscription()->cancel($subscriptionId); } } class_alias('Braintree\Subscription', 'Braintree_Subscription'); lib/Braintree/Plan.php000064400000002444152101632460010634 0ustar00_initialize($attributes); return $instance; } protected function _initialize($attributes) { $this->_attributes = $attributes; $addOnArray = []; if (isset($attributes['addOns'])) { foreach ($attributes['addOns'] AS $addOn) { $addOnArray[] = AddOn::factory($addOn); } } $this->_attributes['addOns'] = $addOnArray; $discountArray = []; if (isset($attributes['discounts'])) { foreach ($attributes['discounts'] AS $discount) { $discountArray[] = Discount::factory($discount); } } $this->_attributes['discounts'] = $discountArray; $planArray = []; if (isset($attributes['plans'])) { foreach ($attributes['plans'] AS $plan) { $planArray[] = self::factory($plan); } } $this->_attributes['plans'] = $planArray; } // static methods redirecting to gateway public static function all() { return Configuration::gateway()->plan()->all(); } } class_alias('Braintree\Plan', 'Braintree_Plan'); lib/Braintree/SettlementBatchSummary.php000064400000002102152101632460014375 0ustar00_initialize($attributes); return $instance; } /** * @ignore * @param array $attributes */ protected function _initialize($attributes) { $this->_attributes = $attributes; } public function records() { return $this->_attributes['records']; } /** * static method redirecting to gateway * * @param string $settlement_date Date YYYY-MM-DD * @param string $groupByCustomField * @return Result\Successful|Result\Error */ public static function generate($settlement_date, $groupByCustomField = NULL) { return Configuration::gateway()->settlementBatchSummary()->generate($settlement_date, $groupByCustomField); } } class_alias('Braintree\SettlementBatchSummary', 'Braintree_SettlementBatchSummary'); lib/Braintree/VenmoAccount.php000064400000003675152101632460012352 0ustar00== More information == * * See {@link https://developers.braintreepayments.com/javascript+php}
* * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $createdAt * @property-read string $default * @property-read string $updatedAt * @property-read string $customerId * @property-read string $sourceDescription * @property-read string $token * @property-read string $imageUrl * @property-read string $username * @property-read string $venmoUserId */ class VenmoAccount extends Base { /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * factory method: returns an instance of VenmoAccount * to the requesting method, with populated properties * * @ignore * @return VenmoAccount */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /** * sets instance properties from an array of values * * @access protected * @param array $venmoAccountAttribs array of Venmo account properties * @return void */ protected function _initialize($venmoAccountAttribs) { $this->_attributes = $venmoAccountAttribs; $subscriptionArray = array(); if (isset($venmoAccountAttribs['subscriptions'])) { foreach ($venmoAccountAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = Subscription::factory($subscription); } } $this->_set('subscriptions', $subscriptionArray); } } class_alias('Braintree\VenmoAccount', 'Braintree_VenmoAccount'); lib/Braintree/Configuration.php000064400000033713152101632460012554 0ustar00 $value) { if ($kind == 'environment') { CredentialsParser::assertValidEnvironment($value); $this->_environment = $value; } if ($kind == 'merchantId') { $this->_merchantId = $value; } if ($kind == 'publicKey') { $this->_publicKey = $value; } if ($kind == 'privateKey') { $this->_privateKey = $value; } } if (isset($attribs['clientId']) || isset($attribs['accessToken'])) { if (isset($attribs['environment']) || isset($attribs['merchantId']) || isset($attribs['publicKey']) || isset($attribs['privateKey'])) { throw new Exception\Configuration('Cannot mix OAuth credentials (clientId, clientSecret, accessToken) with key credentials (publicKey, privateKey, environment, merchantId).'); } $parsedCredentials = new CredentialsParser($attribs); $this->_environment = $parsedCredentials->getEnvironment(); $this->_merchantId = $parsedCredentials->getMerchantId(); $this->_clientId = $parsedCredentials->getClientId(); $this->_clientSecret = $parsedCredentials->getClientSecret(); $this->_accessToken = $parsedCredentials->getAccessToken(); } } /** * resets configuration to default * @access public */ public static function reset() { self::$global = new Configuration(); } public static function gateway() { return new Gateway(self::$global); } public static function environment($value=null) { if (empty($value)) { return self::$global->getEnvironment(); } CredentialsParser::assertValidEnvironment($value); self::$global->setEnvironment($value); } public static function merchantId($value=null) { if (empty($value)) { return self::$global->getMerchantId(); } self::$global->setMerchantId($value); } public static function publicKey($value=null) { if (empty($value)) { return self::$global->getPublicKey(); } self::$global->setPublicKey($value); } public static function privateKey($value=null) { if (empty($value)) { return self::$global->getPrivateKey(); } self::$global->setPrivateKey($value); } /** * Sets or gets the read timeout to use for making requests. * * @param integer $value If provided, sets the read timeout * @return integer The read timeout used for connecting to Braintree */ public static function timeout($value=null) { if (empty($value)) { return self::$global->getTimeout(); } self::$global->setTimeout($value); } /** * Sets or gets the proxy host to use for connecting to Braintree * * @param string $value If provided, sets the proxy host * @return string The proxy host used for connecting to Braintree */ public static function proxyHost($value = null) { if (empty($value)) { return self::$global->getProxyHost(); } self::$global->setProxyHost($value); } /** * Sets or gets the port of the proxy to use for connecting to Braintree * * @param string $value If provided, sets the port of the proxy * @return string The port of the proxy used for connecting to Braintree */ public static function proxyPort($value = null) { if (empty($value)) { return self::$global->getProxyPort(); } self::$global->setProxyPort($value); } /** * Sets or gets the proxy type to use for connecting to Braintree. This value * can be any of the CURLOPT_PROXYTYPE options in PHP cURL. * * @param string $value If provided, sets the proxy type * @return string The proxy type used for connecting to Braintree */ public static function proxyType($value = null) { if (empty($value)) { return self::$global->getProxyType(); } self::$global->setProxyType($value); } /** * Specifies whether or not a proxy is properly configured * * @return bool true if a proxy is configured properly, false if not */ public static function isUsingProxy() { $proxyHost = self::$global->getProxyHost(); $proxyPort = self::$global->getProxyPort(); return !empty($proxyHost) && !empty($proxyPort); } public static function proxyUser($value = null) { if (empty($value)) { return self::$global->getProxyUser(); } self::$global->setProxyUser($value); } public static function proxyPassword($value = null) { if (empty($value)) { return self::$global->getProxyPassword(); } self::$global->setProxyPassword($value); } /** * Specified whether or not a username and password have been provided for * use with an authenticated proxy * * @return bool true if both proxyUser and proxyPassword are present */ public static function isAuthenticatedProxy() { $proxyUser = self::$global->getProxyUser(); $proxyPwd = self::$global->getProxyPassword(); return !empty($proxyUser) && !empty($proxyPwd); } public static function assertGlobalHasAccessTokenOrKeys() { self::$global->assertHasAccessTokenOrKeys(); } public function assertHasAccessTokenOrKeys() { if (empty($this->_accessToken)) { if (empty($this->_merchantId)) { throw new Exception\Configuration('Braintree\\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\\Gateway).'); } else if (empty($this->_environment)) { throw new Exception\Configuration('Braintree\\Configuration::environment needs to be set.'); } else if (empty($this->_publicKey)) { throw new Exception\Configuration('Braintree\\Configuration::publicKey needs to be set.'); } else if (empty($this->_privateKey)) { throw new Exception\Configuration('Braintree\\Configuration::privateKey needs to be set.'); } } } public function assertHasClientCredentials() { $this->assertHasClientId(); $this->assertHasClientSecret(); } public function assertHasClientId() { if (empty($this->_clientId)) { throw new Exception\Configuration('clientId needs to be passed to Braintree\\Gateway.'); } } public function assertHasClientSecret() { if (empty($this->_clientSecret)) { throw new Exception\Configuration('clientSecret needs to be passed to Braintree\\Gateway.'); } } public function getEnvironment() { return $this->_environment; } /** * Do not use this method directly. Pass in the environment to the constructor. */ public function setEnvironment($value) { $this->_environment = $value; } public function getMerchantId() { return $this->_merchantId; } /** * Do not use this method directly. Pass in the merchantId to the constructor. */ public function setMerchantId($value) { $this->_merchantId = $value; } public function getPublicKey() { return $this->_publicKey; } public function getClientId() { return $this->_clientId; } /** * Do not use this method directly. Pass in the publicKey to the constructor. */ public function setPublicKey($value) { $this->_publicKey = $value; } public function getPrivateKey() { return $this->_privateKey; } public function getClientSecret() { return $this->_clientSecret; } /** * Do not use this method directly. Pass in the privateKey to the constructor. */ public function setPrivateKey($value) { $this->_privateKey = $value; } private function setProxyHost($value) { $this->_proxyHost = $value; } public function getProxyHost() { return $this->_proxyHost; } private function setProxyPort($value) { $this->_proxyPort = $value; } public function getProxyPort() { return $this->_proxyPort; } private function setProxyType($value) { $this->_proxyType = $value; } public function getProxyType() { return $this->_proxyType; } private function setProxyUser($value) { $this->_proxyUser = $value; } public function getProxyUser() { return $this->_proxyUser; } private function setProxyPassword($value) { $this->_proxyPassword = $value; } public function getProxyPassword() { return $this->_proxyPassword; } private function setTimeout($value) { $this->_timeout = $value; } public function getTimeout() { return $this->_timeout; } public function getAccessToken() { return $this->_accessToken; } public function isAccessToken() { return !empty($this->_accessToken); } public function isClientCredentials() { return !empty($this->_clientId); } /** * returns the base braintree gateway URL based on config values * * @access public * @param none * @return string braintree gateway URL */ public function baseUrl() { return sprintf('%s://%s:%d', $this->protocol(), $this->serverName(), $this->portNumber()); } /** * sets the merchant path based on merchant ID * * @access protected * @param none * @return string merchant path uri */ public function merchantPath() { return '/merchants/' . $this->_merchantId; } /** * sets the physical path for the location of the CA certs * * @access public * @param none * @return string filepath */ public function caFile($sslPath = NULL) { $sslPath = $sslPath ? $sslPath : DIRECTORY_SEPARATOR . '..' . DIRECTORY_SEPARATOR . 'ssl' . DIRECTORY_SEPARATOR; $caPath = __DIR__ . $sslPath . 'api_braintreegateway_com.ca.crt'; if (!file_exists($caPath)) { throw new Exception\SSLCaFileNotFound(); } return $caPath; } /** * returns the port number depending on environment * * @access public * @param none * @return int portnumber */ public function portNumber() { if ($this->sslOn()) { return 443; } return getenv("GATEWAY_PORT") ? getenv("GATEWAY_PORT") : 3000; } /** * returns http protocol depending on environment * * @access public * @param none * @return string http || https */ public function protocol() { return $this->sslOn() ? 'https' : 'http'; } /** * returns gateway server name depending on environment * * @access public * @param none * @return string server domain name */ public function serverName() { switch($this->_environment) { case 'production': $serverName = 'api.braintreegateway.com'; break; case 'qa': $serverName = 'gateway.qa.braintreepayments.com'; break; case 'sandbox': $serverName = 'api.sandbox.braintreegateway.com'; break; case 'development': case 'integration': default: $serverName = 'localhost'; break; } return $serverName; } public function authUrl() { switch($this->_environment) { case 'production': $serverName = 'https://auth.venmo.com'; break; case 'qa': $serverName = 'https://auth.qa.venmo.com'; break; case 'sandbox': $serverName = 'https://auth.sandbox.venmo.com'; break; case 'development': case 'integration': default: $serverName = 'http://auth.venmo.dev:9292'; break; } return $serverName; } /** * returns boolean indicating SSL is on or off for this session, * depending on environment * * @access public * @param none * @return boolean */ public function sslOn() { switch($this->_environment) { case 'integration': case 'development': $ssl = false; break; case 'production': case 'qa': case 'sandbox': default: $ssl = true; break; } return $ssl; } /** * log message to default logger * * @param string $message * */ public function logMessage($message) { error_log('[Braintree] ' . $message); } } Configuration::reset(); class_alias('Braintree\Configuration', 'Braintree_Configuration'); lib/Braintree/KeyValueNode.php000064400000000631152101632460012271 0ustar00name = $name; $this->searchTerm = True; } public function is($value) { $this->searchTerm = $value; return $this; } public function toParam() { return $this->searchTerm; } } class_alias('Braintree\KeyValueNode', 'Braintree_KeyValueNode'); lib/Braintree/Subscription/StatusDetails.php000064400000001271152101632460015214 0ustar00== More information == * * For more detailed information on Customers, see {@link http://www.braintreepayments.com/gateway/customer-api http://www.braintreepaymentsolutions.com/gateway/customer-api} * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. */ class CustomerGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function all() { $path = $this->_config->merchantPath() . '/customers/advanced_search_ids'; $response = $this->_http->post($path); $pager = [ 'object' => $this, 'method' => 'fetch', 'methodArgs' => [[]] ]; return new ResourceCollection($response, $pager); } public function fetch($query, $ids) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $criteria["ids"] = CustomerSearch::ids()->in($ids)->toparam(); $path = $this->_config->merchantPath() . '/customers/advanced_search'; $response = $this->_http->post($path, ['search' => $criteria]); return Util::extractattributeasarray( $response['customers'], 'customer' ); } /** * Creates a customer using the given +attributes+. If :id is not passed, * the gateway will generate it. * * * $result = Customer::create(array( * 'first_name' => 'John', * 'last_name' => 'Smith', * 'company' => 'Smith Co.', * 'email' => 'john@smith.com', * 'website' => 'www.smithco.com', * 'fax' => '419-555-1234', * 'phone' => '614-555-1234' * )); * if($result->success) { * echo 'Created customer ' . $result->customer->id; * } else { * echo 'Could not create customer, see result->errors'; * } * * * @access public * @param array $attribs * @return Braintree_Result_Successful|Braintree_Result_Error */ public function create($attribs = []) { Util::verifyKeys(self::createSignature(), $attribs); return $this->_doCreate('/customers', ['customer' => $attribs]); } /** * attempts the create operation assuming all data will validate * returns a Customer object instead of a Result * * @access public * @param array $attribs * @return Customer * @throws Exception\ValidationError */ public function createNoValidate($attribs = []) { $result = $this->create($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * create a customer from a TransparentRedirect operation * * @deprecated since version 2.3.0 * @access public * @param array $attribs * @return Customer */ public function createFromTransparentRedirect($queryString) { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); $params = TransparentRedirect::parseAndValidateQueryString( $queryString ); return $this->_doCreate( '/customers/all/confirm_transparent_redirect_request', ['id' => $params['id']] ); } /** * * @deprecated since version 2.3.0 * @access public * @param none * @return string */ public function createCustomerUrl() { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); return $this->_config->baseUrl() . $this->_config->merchantPath() . '/customers/all/create_via_transparent_redirect_request'; } /** * creates a full array signature of a valid create request * @return array gateway create request format */ public static function createSignature() { $creditCardSignature = CreditCardGateway::createSignature(); unset($creditCardSignature[array_search('customerId', $creditCardSignature)]); $signature = [ 'id', 'company', 'email', 'fax', 'firstName', 'lastName', 'phone', 'website', 'deviceData', 'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce', ['riskData' => ['customerBrowser', 'customerIp', 'customer_browser', 'customer_ip'] ], ['creditCard' => $creditCardSignature], ['customFields' => ['_anyKey_']], ]; return $signature; } /** * creates a full array signature of a valid update request * @return array update request format */ public static function updateSignature() { $creditCardSignature = CreditCardGateway::updateSignature(); foreach($creditCardSignature AS $key => $value) { if(is_array($value) and array_key_exists('options', $value)) { array_push($creditCardSignature[$key]['options'], 'updateExistingToken'); } } $signature = [ 'id', 'company', 'email', 'fax', 'firstName', 'lastName', 'phone', 'website', 'deviceData', 'deviceSessionId', 'fraudMerchantId', 'paymentMethodNonce', 'defaultPaymentMethodToken', ['creditCard' => $creditCardSignature], ['customFields' => ['_anyKey_']], ]; return $signature; } /** * find a customer by id * * @access public * @param string id customer Id * @return Customer|boolean The customer object or false if the request fails. * @throws Exception\NotFound */ public function find($id) { $this->_validateId($id); try { $path = $this->_config->merchantPath() . '/customers/' . $id; $response = $this->_http->get($path); return Customer::factory($response['customer']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'customer with id ' . $id . ' not found' ); } } /** * credit a customer for the passed transaction * * @access public * @param int $customerId * @param array $transactionAttribs * @return Result\Successful|Result\Error */ public function credit($customerId, $transactionAttribs) { $this->_validateId($customerId); return Transaction::credit( array_merge($transactionAttribs, ['customerId' => $customerId] ) ); } /** * credit a customer, assuming validations will pass * * returns a Transaction object on success * * @access public * @param int $customerId * @param array $transactionAttribs * @return Transaction * @throws Exception\ValidationError */ public function creditNoValidate($customerId, $transactionAttribs) { $result = $this->credit($customerId, $transactionAttribs); return Util::returnObjectOrThrowException('Braintree\Transaction', $result); } /** * delete a customer by id * * @param string $customerId */ public function delete($customerId) { $this->_validateId($customerId); $path = $this->_config->merchantPath() . '/customers/' . $customerId; $this->_http->delete($path); return new Result\Successful(); } /** * create a new sale for a customer * * @param string $customerId * @param array $transactionAttribs * @return Result\Successful|Result\Error * @see Transaction::sale() */ public function sale($customerId, $transactionAttribs) { $this->_validateId($customerId); return Transaction::sale( array_merge($transactionAttribs, ['customerId' => $customerId] ) ); } /** * create a new sale for a customer, assuming validations will pass * * returns a Transaction object on success * @access public * @param string $customerId * @param array $transactionAttribs * @return Transaction * @throws Exception\ValidationsFailed * @see Transaction::sale() */ public function saleNoValidate($customerId, $transactionAttribs) { $result = $this->sale($customerId, $transactionAttribs); return Util::returnObjectOrThrowException('Braintree\Transaction', $result); } /** * Returns a ResourceCollection of customers matching the search query. * * If query is a string, the search will be a basic search. * If query is a hash, the search will be an advanced search. * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/customer-api#searching http://www.braintreepaymentsolutions.com/gateway/customer-api} * * @param mixed $query search query * @return ResourceCollection * @throws InvalidArgumentException */ public function search($query) { $criteria = []; foreach ($query as $term) { $result = $term->toparam(); if(is_null($result) || empty($result)) { throw new InvalidArgumentException('Operator must be provided'); } $criteria[$term->name] = $term->toparam(); } $path = $this->_config->merchantPath() . '/customers/advanced_search_ids'; $response = $this->_http->post($path, ['search' => $criteria]); $pager = [ 'object' => $this, 'method' => 'fetch', 'methodArgs' => [$query] ]; return new ResourceCollection($response, $pager); } /** * updates the customer record * * if calling this method in static context, customerId * is the 2nd attribute. customerId is not sent in object context. * * @access public * @param string $customerId (optional) * @param array $attributes * @return Result\Successful|Result\Error */ public function update($customerId, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); $this->_validateId($customerId); return $this->_doUpdate( 'put', '/customers/' . $customerId, ['customer' => $attributes] ); } /** * update a customer record, assuming validations will pass * * if calling this method in static context, customerId * is the 2nd attribute. customerId is not sent in object context. * returns a Customer object on success * * @access public * @param string $customerId * @param array $attributes * @return Customer * @throws Exception\ValidationsFailed */ public function updateNoValidate($customerId, $attributes) { $result = $this->update($customerId, $attributes); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * * @deprecated since version 2.3.0 * @access public * @return string */ public function updateCustomerUrl() { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); return $this->_config->baseUrl() . $this->_config->merchantPath() . '/customers/all/update_via_transparent_redirect_request'; } /** * update a customer from a TransparentRedirect operation * * @deprecated since version 2.3.0 * @access public * @param string $queryString * @return object */ public function updateFromTransparentRedirect($queryString) { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); $params = TransparentRedirect::parseAndValidateQueryString( $queryString ); return $this->_doUpdate( 'post', '/customers/all/confirm_transparent_redirect_request', ['id' => $params['id']] ); } /* instance methods */ /** * 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)); } /** * returns a string representation of the customer * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } /** * returns false if comparing object is not a Customer, * or is a Customer with a different id * * @param object $otherCust customer to compare against * @return boolean */ public function isEqual($otherCust) { return !($otherCust instanceof Customer) ? false : $this->id === $otherCust->id; } /** * returns an array containt all of the customer's payment methods * * @return array */ public function paymentMethods() { return $this->paymentMethods; } /** * returns the customer's default payment method * * @return CreditCard|PayPalAccount|ApplePayCard|AndroidPayCard */ public function defaultPaymentMethod() { $defaultPaymentMethods = array_filter($this->paymentMethods, 'Braintree\\Customer::_defaultPaymentMethodFilter'); return current($defaultPaymentMethods); } public static function _defaultPaymentMethodFilter($paymentMethod) { return $paymentMethod->isDefault(); } /* private class properties */ /** * @access protected * @var array registry of customer data */ protected $_attributes = [ 'addresses' => '', 'company' => '', 'creditCards' => '', 'email' => '', 'fax' => '', 'firstName' => '', 'id' => '', 'lastName' => '', 'phone' => '', 'createdAt' => '', 'updatedAt' => '', 'website' => '', ]; /** * sends the create request to the gateway * * @ignore * @param string $subPath * @param array $params * @return mixed */ public function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * verifies that a valid customer id is being used * @ignore * @param string customer id * @throws InvalidArgumentException */ private function _validateId($id = null) { if (is_null($id)) { throw new InvalidArgumentException( 'expected customer id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid customer id.' ); } } /* private class methods */ /** * sends the update request to the gateway * * @ignore * @param string $subPath * @param array $params * @return mixed */ private function _doUpdate($httpVerb, $subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->$httpVerb($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * generic method for validating incoming gateway responses * * creates a new Customer object and encapsulates * it inside a Result\Successful object, or * encapsulates a Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid. * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['customer'])) { // return a populated instance of Customer return new Result\Successful( Customer::factory($response['customer']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected customer or apiErrorResponse" ); } } } class_alias('Braintree\CustomerGateway', 'Braintree_CustomerGateway'); lib/Braintree/AddressGateway.php000064400000021652152101632460012653 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } /* public class methods */ /** * * @access public * @param array $attribs * @return Result\Successful|Result\Error */ public function create($attribs) { Util::verifyKeys(self::createSignature(), $attribs); $customerId = isset($attribs['customerId']) ? $attribs['customerId'] : null; $this->_validateCustomerId($customerId); unset($attribs['customerId']); try { return $this->_doCreate( '/customers/' . $customerId . '/addresses', ['address' => $attribs] ); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'Customer ' . $customerId . ' not found.' ); } } /** * attempts the create operation assuming all data will validate * returns a Address object instead of a Result * * @access public * @param array $attribs * @return self * @throws Exception\ValidationError */ public function createNoValidate($attribs) { $result = $this->create($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * delete an address by id * * @param mixed $customerOrId * @param string $addressId */ public function delete($customerOrId = null, $addressId = null) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $this->_http->delete($path); return new Result\Successful(); } /** * find an address by id * * Finds the address with the given addressId that is associated * to the given customerOrId. * If the address cannot be found, a NotFound exception will be thrown. * * * @access public * @param mixed $customerOrId * @param string $addressId * @return Address * @throws Exception\NotFound */ public function find($customerOrId, $addressId) { $customerId = $this->_determineCustomerId($customerOrId); $this->_validateId($addressId); try { $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->get($path); return Address::factory($response['address']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'address for customer ' . $customerId . ' with id ' . $addressId . ' not found.' ); } } /** * updates the address record * * if calling this method in context, * customerOrId is the 2nd attribute, addressId 3rd. * customerOrId & addressId are not sent in object context. * * * @access public * @param array $attributes * @param mixed $customerOrId (only used in call) * @param string $addressId (only used in call) * @return Result\Successful|Result\Error */ public function update($customerOrId, $addressId, $attributes) { $this->_validateId($addressId); $customerId = $this->_determineCustomerId($customerOrId); Util::verifyKeys(self::updateSignature(), $attributes); $path = $this->_config->merchantPath() . '/customers/' . $customerId . '/addresses/' . $addressId; $response = $this->_http->put($path, ['address' => $attributes]); return $this->_verifyGatewayResponse($response); } /** * update an address record, assuming validations will pass * * if calling this method in context, * customerOrId is the 2nd attribute, addressId 3rd. * customerOrId & addressId are not sent in object context. * * @access public * @param array $transactionAttribs * @param string $customerId * @return Transaction * @throws Exception\ValidationsFailed * @see Address::update() */ public function updateNoValidate($customerOrId, $addressId, $attributes) { $result = $this->update($customerOrId, $addressId, $attributes); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * creates a full array signature of a valid create request * @return array gateway create request format */ public static function createSignature() { return [ 'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', 'countryName', 'customerId', 'extendedAddress', 'firstName', 'lastName', 'locality', 'postalCode', 'region', 'streetAddress' ]; } /** * creates a full array signature of a valid update request * @return array gateway update request format */ public static function updateSignature() { // TODO: remove customerId from update signature return self::createSignature(); } /** * verifies that a valid address id is being used * @ignore * @param string $id address id * @throws InvalidArgumentException */ private function _validateId($id = null) { if (empty($id) || trim($id) == "") { throw new InvalidArgumentException( 'expected address id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid address id.' ); } } /** * verifies that a valid customer id is being used * @ignore * @param string $id customer id * @throws InvalidArgumentException */ private function _validateCustomerId($id = null) { if (empty($id) || trim($id) == "") { throw new InvalidArgumentException( 'expected customer id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid customer id.' ); } } /** * determines if a string id or Customer object was passed * @ignore * @param mixed $customerOrId * @return string customerId */ private function _determineCustomerId($customerOrId) { $customerId = ($customerOrId instanceof Customer) ? $customerOrId->id : $customerOrId; $this->_validateCustomerId($customerId); return $customerId; } /* private class methods */ /** * sends the create request to the gateway * @ignore * @param string $subPath * @param array $params * @return Result\Successful|Result\Error */ private function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * 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 Result\Successful|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" ); } } } class_alias('Braintree\AddressGateway', 'Braintree_AddressGateway'); lib/Braintree/CreditCardVerificationSearch.php000064400000002735152101632460015442 0ustar00_attributes = $disputeAttribs; if (isset($disputeAttribs['transaction'])) { $this->_set('transactionDetails', new Dispute\TransactionDetails($disputeAttribs['transaction']) ); } } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } public function __toString() { $display = [ 'amount', 'reason', 'status', 'replyByDate', 'receivedDate', 'currencyIsoCode' ]; $displayAttributes = []; foreach ($display AS $attrib) { $displayAttributes[$attrib] = $this->$attrib; } return __CLASS__ . '[' . Util::attributesToString($displayAttributes) .']'; } } class_alias('Braintree\Dispute', 'Braintree_Dispute'); lib/Braintree/Result/Successful.php000064400000005107152101632460013336 0ustar00customer like so: * * * $result = Customer::create(array('first_name' => "John")); * if ($result->success) { * // Successful * echo "Created customer {$result->customer->id}"; * } else { * // Error * } * * * * @package Braintree * @subpackage Result * @copyright 2015 Braintree, a division of PayPal, Inc. */ class Successful extends Instance { /** * * @var boolean always true */ public $success = true; /** * * @var string stores the internal name of the object providing access to */ private $_returnObjectNames; /** * @ignore * @param array|null $objsToReturn * @param array|null $propertyNames */ public function __construct($objsToReturn = [], $propertyNames = []) { // Sanitize arguments (preserves backwards compatibility) if (!is_array($objsToReturn)) { $objsToReturn = [$objsToReturn]; } if (!is_array($propertyNames)) { $propertyNames = [$propertyNames]; } $objects = $this->_mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn); $this->_attributes = []; $this->_returnObjectNames = []; foreach ($objects as $propertyName => $objToReturn) { // save the name for indirect access array_push($this->_returnObjectNames, $propertyName); // create the property! $this->$propertyName = $objToReturn; } } /** * * @ignore * @return string string representation of the object's structure */ public function __toString() { $objects = []; foreach ($this->_returnObjectNames as $returnObjectName) { array_push($objects, $this->$returnObjectName); } return __CLASS__ . '[' . implode(', ', $objects) . ']'; } private function _mapPropertyNamesToObjsToReturn($propertyNames, $objsToReturn) { if(count($objsToReturn) != count($propertyNames)) { $propertyNames = []; foreach ($objsToReturn as $obj) { array_push($propertyNames, Util::cleanClassName(get_class($obj))); } } return array_combine($propertyNames, $objsToReturn); } } class_alias('Braintree\Result\Successful', 'Braintree_Result_Successful'); lib/Braintree/Result/CreditCardVerification.php000064400000005133152101632460015565 0ustar00_initializeFromArray($attributes); } /** * initializes instance properties from the keys/values of an array * @ignore * @access protected * @param $aAttribs array of properties to set - single level * @return void */ private function _initializeFromArray($attributes) { if(isset($attributes['riskData'])) { $attributes['riskData'] = RiskData::factory($attributes['riskData']); } $this->_attributes = $attributes; foreach($attributes AS $name => $value) { $varName = "_$name"; $this->$varName = $value; } } /** * @ignore */ public function __get($name) { $varName = "_$name"; return isset($this->$varName) ? $this->$varName : null; } /** * returns a string representation of the customer * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) . ']'; } public static function allStatuses() { return [ CreditCardVerification::FAILED, CreditCardVerification::GATEWAY_REJECTED, CreditCardVerification::PROCESSOR_DECLINED, CreditCardVerification::VERIFIED ]; } } class_alias('Braintree\Result\CreditCardVerification', 'Braintree_Result_CreditCardVerification'); lib/Braintree/Result/Error.php000064400000007410152101632460012307 0ustar00 * $result = Transaction::void('abc123'); * if ($result->success) { * // Successful Result * } else { * // Result\Error * } * * * @package Braintree * @subpackage Result * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read array $params original passed params * @property-read \Braintree\Error\ErrorCollection $errors * @property-read \Braintree\Result\CreditCardVerification $creditCardVerification credit card verification data */ class Error extends Base { /** * @var bool always false */ public $success = false; /** * return original value for a field * For example, if a user tried to submit 'invalid-email' in the html field transaction[customer][email], * $result->valueForHtmlField("transaction[customer][email]") would yield "invalid-email" * * @param string $field * @return string */ public function valueForHtmlField($field) { $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY); $params = $this->params; foreach(array_slice($pieces, 0, -1) as $key) { $params = $params[Util::delimiterToCamelCase($key)]; } if ($key != 'custom_fields') { $finalKey = Util::delimiterToCamelCase(end($pieces)); } else { $finalKey = end($pieces); } $fieldValue = isset($params[$finalKey]) ? $params[$finalKey] : null; return $fieldValue; } /** * overrides default constructor * @ignore * @param array $response gateway response array */ public function __construct($response) { $this->_attributes = $response; $this->_set('errors', new ErrorCollection($response['errors'])); if(isset($response['verification'])) { $this->_set('creditCardVerification', new CreditCardVerification($response['verification'])); } else { $this->_set('creditCardVerification', null); } if(isset($response['transaction'])) { $this->_set('transaction', Transaction::factory($response['transaction'])); } else { $this->_set('transaction', null); } if(isset($response['subscription'])) { $this->_set('subscription', Subscription::factory($response['subscription'])); } else { $this->_set('subscription', null); } if(isset($response['merchantAccount'])) { $this->_set('merchantAccount', MerchantAccount::factory($response['merchantAccount'])); } else { $this->_set('merchantAccount', null); } if(isset($response['verification'])) { $this->_set('verification', new CreditCardVerification($response['verification'])); } else { $this->_set('verification', null); } } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @ignore * @return string */ public function __toString() { $output = Util::attributesToString($this->_attributes); if (isset($this->_creditCardVerification)) { $output .= sprintf('%s', $this->_creditCardVerification); } return __CLASS__ .'[' . $output . ']'; } } class_alias('Braintree\Result\Error', 'Braintree_Result_Error'); lib/Braintree/MerchantAccount/BusinessDetails.php000064400000001173152101632460016117 0ustar00_attributes = $businessAttribs; if (isset($businessAttribs['address'])) { $this->_set('addressDetails', new AddressDetails($businessAttribs['address'])); } } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } } class_alias('Braintree\MerchantAccount\BusinessDetails', 'Braintree_MerchantAccount_BusinessDetails'); lib/Braintree/MerchantAccount/FundingDetails.php000064400000000365152101632460015720 0ustar00_attributes = $individualAttribs; if (isset($individualAttribs['address'])) { $this->_set('addressDetails', new AddressDetails($individualAttribs['address'])); } } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } } class_alias('Braintree\MerchantAccount\IndividualDetails', 'Braintree_MerchantAccount_IndividualDetails'); lib/Braintree/TransactionSearch.php000064400000017253152101632460013361 0ustar00textNode = new TextNode($name); } public function contains($value) { $this->textNode->contains($value); return $this; } public function endsWith($value) { $this->textNode->endsWith($value); return $this; } public function is($value) { $this->textNode->is($value); return $this; } public function isNot($value) { $this->textNode->isNot($value); return $this; } public function startsWith($value) { $this->textNode->startsWith($value); return $this; } public function toParam() { return array_merge(parent::toParam(), $this->textNode->toParam()); } } class_alias('Braintree\MultipleValueOrTextNode', 'Braintree_MultipleValueOrTextNode'); lib/Braintree/PlanGateway.php000064400000001464152101632460012157 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function all() { $path = $this->_config->merchantPath() . '/plans'; $response = $this->_http->get($path); if (key_exists('plans', $response)){ $plans = ["plan" => $response['plans']]; } else { $plans = ["plan" => []]; } return Util::extractAttributeAsArray( $plans, 'plan' ); } } class_alias('Braintree\PlanGateway', 'Braintree_PlanGateway'); lib/Braintree/PayPalAccount.php000064400000005320152101632460012441 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $customerId * @property-read string $email * @property-read string $token * @property-read string $imageUrl */ class PayPalAccount extends Base { /** * factory method: returns an instance of PayPalAccount * to the requesting method, with populated properties * * @ignore * @return PayPalAccount */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * sets instance properties from an array of values * * @access protected * @param array $paypalAccountAttribs array of paypalAccount data * @return void */ protected function _initialize($paypalAccountAttribs) { // set the attributes $this->_attributes = $paypalAccountAttribs; $subscriptionArray = []; if (isset($paypalAccountAttribs['subscriptions'])) { foreach ($paypalAccountAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = Subscription::factory($subscription); } } $this->_set('subscriptions', $subscriptionArray); } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) . ']'; } // static methods redirecting to gateway public static function find($token) { return Configuration::gateway()->payPalAccount()->find($token); } public static function update($token, $attributes) { return Configuration::gateway()->payPalAccount()->update($token, $attributes); } public static function delete($token) { return Configuration::gateway()->payPalAccount()->delete($token); } public static function sale($token, $transactionAttribs) { return Configuration::gateway()->payPalAccount()->sale($token, $transactionAttribs); } } class_alias('Braintree\PayPalAccount', 'Braintree_PayPalAccount'); lib/Braintree/Disbursement.php000064400000002633152101632460012406 0ustar00_attributes = $disbursementAttribs; $this->merchantAccountDetails = $disbursementAttribs['merchantAccount']; if (isset($disbursementAttribs['merchantAccount'])) { $this->_set('merchantAccount', MerchantAccount::factory($disbursementAttribs['merchantAccount']) ); } } public function transactions() { $collection = Transaction::search([ TransactionSearch::ids()->in($this->transactionIds), ]); return $collection; } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } public function __toString() { $display = [ 'id', 'merchantAccountDetails', 'exceptionMessage', 'amount', 'disbursementDate', 'followUpAction', 'retry', 'success', 'transactionIds' ]; $displayAttributes = []; foreach ($display AS $attrib) { $displayAttributes[$attrib] = $this->$attrib; } return __CLASS__ . '[' . Util::attributesToString($displayAttributes) .']'; } } class_alias('Braintree\Disbursement', 'Braintree_Disbursement'); lib/Braintree/SubscriptionStatus.php000064400000000000152101632460013614 0ustar00lib/Braintree/Collection.php000064400000006462152101632460012041 0ustar00_collection[] = $value; } /** * Set index's value * @param integer $index * @param mixed $value * @throws OutOfRangeException */ public function set($index, $value) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); $this->_collection[$index] = $value; } /** * Remove a value from the collection * @param integer $index index to remove * @throws OutOfRangeException if index is out of range */ public function remove($index) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); array_splice($this->_collection, $index, 1); } /** * Return value at index * @param integer $index * @return mixed * @throws OutOfRangeException */ public function get($index) { if($index >= $this->count()) throw new OutOfRangeException('Index out of range'); return $this->_collection[$index]; } /** * Determine if index exists * @param integer $index * @return boolean */ public function exists($index) { if($index >= $this->count()) return false; return true; } /** * Return count of items in collection * Implements countable * @return integer */ public function count() { return count($this->_collection); } /** * Return an iterator * Implements IteratorAggregate * @return ArrayIterator */ public function getIterator() { return new ArrayIterator($this->_collection); } /** * Set offset to value * Implements ArrayAccess * @see set * @param integer $offset * @param mixed $value */ public function offsetSet($offset, $value) { $this->set($offset, $value); } /** * Unset offset * Implements ArrayAccess * @see remove * @param integer $offset */ public function offsetUnset($offset) { $this->remove($offset); } /** * get an offset's value * Implements ArrayAccess * @see get * @param integer $offset * @return mixed */ public function offsetGet($offset) { return $this->get($offset); } /** * Determine if offset exists * Implements ArrayAccess * @see exists * @param integer $offset * @return boolean */ public function offsetExists($offset) { return $this->exists($offset); } } class_alias('Braintree\Collection', 'Braintree_Collection'); lib/Braintree/ThreeDSecureInfo.php000064400000001224152101632460013073 0ustar00_initialize($attributes); return $instance; } protected function _initialize($attributes) { $this->_attributes = $attributes; } /** * returns a string representation of the three d secure info * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } } class_alias('Braintree\ThreeDSecureInfo', 'Braintree_ThreeDSecureInfo'); lib/Braintree/CreditCardVerification.php000064400000002460152101632460014307 0ustar00creditCardVerification()->create($attributes); } public static function fetch($query, $ids) { return Configuration::gateway()->creditCardVerification()->fetch($query, $ids); } public static function search($query) { return Configuration::gateway()->creditCardVerification()->search($query); } public static function createSignature() { return [ ['options' => ['amount', 'merchantAccountId']], ['creditCard' => [ 'cardholderName', 'cvv', 'number', 'expirationDate', 'expirationMonth', 'expirationYear', ['billingAddress' => CreditCardGateway::billingAddressSignature()] ] ]]; } } class_alias('Braintree\CreditCardVerification', 'Braintree_CreditCardVerification'); lib/Braintree/UsBankAccount.php000064400000004075152101632460012444 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2016 Braintree, a division of PayPal, Inc. * * @property-read string $customerId * @property-read string $email * @property-read string $token * @property-read string $imageUrl * @property-read string $bankName */ class UsBankAccount extends Base { /** * factory method: returns an instance of UsBankAccount * to the requesting method, with populated properties * * @ignore * @return UsBankAccount */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /* instance methods */ /** * sets instance properties from an array of values * * @access protected * @param array $usBankAccountAttribs array of usBankAccount data * @return void */ protected function _initialize($usBankAccountAttribs) { // set the attributes $this->_attributes = $usBankAccountAttribs; } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) . ']'; } // static methods redirecting to gateway public static function find($token) { return Configuration::gateway()->usBankAccount()->find($token); } public static function sale($token, $transactionAttribs) { $transactionAttribs['options'] = [ 'submitForSettlement' => true ]; return Configuration::gateway()->usBankAccount()->sale($token, $transactionAttribs); } } class_alias('Braintree\UsBankAccount', 'Braintree_UsBankAccount'); lib/Braintree/SettlementBatchSummaryGateway.php000064400000005430152101632460015726 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } /** * * @param string $settlement_date * @param string $groupByCustomField * @return SettlementBatchSummary|Result\Error */ public function generate($settlement_date, $groupByCustomField = NULL) { $criteria = ['settlement_date' => $settlement_date]; if (isset($groupByCustomField)) { $criteria['group_by_custom_field'] = $groupByCustomField; } $params = ['settlement_batch_summary' => $criteria]; $path = $this->_config->merchantPath() . '/settlement_batch_summary'; $response = $this->_http->post($path, $params); if (isset($groupByCustomField)) { $response['settlementBatchSummary']['records'] = $this->_underscoreCustomField( $groupByCustomField, $response['settlementBatchSummary']['records'] ); } return $this->_verifyGatewayResponse($response); } /** * * @param string $groupByCustomField * @param array $records * @return array */ private function _underscoreCustomField($groupByCustomField, $records) { $updatedRecords = []; foreach ($records as $record) { $camelized = Util::delimiterToCamelCase($groupByCustomField); $record[$groupByCustomField] = $record[$camelized]; unset($record[$camelized]); $updatedRecords[] = $record; } return $updatedRecords; } /** * * @param array $response * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['settlementBatchSummary'])) { return new Result\Successful( SettlementBatchSummary::factory($response['settlementBatchSummary']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected settlementBatchSummary or apiErrorResponse" ); } } } class_alias('Braintree\SettlementBatchSummaryGateway', 'Braintree_SettlementBatchSummaryGateway'); lib/Braintree/AccountUpdaterDailyReport.php000064400000002117152101632460015037 0ustar00_attributes = $disputeAttribs; } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } public function __toString() { $display = [ 'reportDate', 'reportUrl' ]; $displayAttributes = []; foreach ($display AS $attrib) { $displayAttributes[$attrib] = $this->$attrib; } return __CLASS__ . '[' . Util::attributesToString($displayAttributes) .']'; } } class_alias('Braintree\AccountUpdaterDailyReport', 'Braintree_AccountUpdaterDailyReport'); lib/Braintree/TextNode.php000064400000000401152101632460011463 0ustar00searchTerms["contains"] = strval($value); return $this; } } class_alias('Braintree\TextNode', 'Braintree_TextNode'); lib/Braintree/Merchant.php000064400000001670152101632460011503 0ustar00_attributes = $attribs; $merchantAccountArray = []; if (isset($attribs['merchantAccounts'])) { foreach ($attribs['merchantAccounts'] AS $merchantAccount) { $merchantAccountArray[] = MerchantAccount::factory($merchantAccount); } } $this->_set('merchantAccounts', $merchantAccountArray); } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /** * returns a string representation of the merchant * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } } class_alias('Braintree\Merchant', 'Braintree_Merchant'); lib/Braintree/TransparentRedirectGateway.php000064400000021533152101632460015247 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); } /** * * @ignore */ private static $_transparentRedirectKeys = 'redirectUrl'; private static $_createCustomerSignature; private static $_updateCustomerSignature; private static $_transactionSignature; private static $_createCreditCardSignature; private static $_updateCreditCardSignature; /** * create signatures for different call types * @ignore */ public static function init() { self::$_createCustomerSignature = [ self::$_transparentRedirectKeys, ['customer' => CustomerGateway::createSignature()], ]; self::$_updateCustomerSignature = [ self::$_transparentRedirectKeys, 'customerId', ['customer' => CustomerGateway::updateSignature()], ]; self::$_transactionSignature = [ self::$_transparentRedirectKeys, ['transaction' => TransactionGateway::createSignature()], ]; self::$_createCreditCardSignature = [ self::$_transparentRedirectKeys, ['creditCard' => CreditCardGateway::createSignature()], ]; self::$_updateCreditCardSignature = [ self::$_transparentRedirectKeys, 'paymentMethodToken', ['creditCard' => CreditCardGateway::updateSignature()], ]; } public function confirm($queryString) { $params = TransparentRedirect::parseAndValidateQueryString( $queryString ); $confirmationKlasses = [ TransparentRedirect::CREATE_TRANSACTION => 'Braintree\TransactionGateway', TransparentRedirect::CREATE_CUSTOMER => 'Braintree\CustomerGateway', TransparentRedirect::UPDATE_CUSTOMER => 'Braintree\CustomerGateway', TransparentRedirect::CREATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway', TransparentRedirect::UPDATE_PAYMENT_METHOD => 'Braintree\CreditCardGateway', ]; $confirmationGateway = new $confirmationKlasses[$params["kind"]]($this->_gateway); return $confirmationGateway->_doCreate('/transparent_redirect_requests/' . $params['id'] . '/confirm', []); } /** * returns the trData string for creating a credit card, * @param array $params * @return string */ public function createCreditCardData($params) { Util::verifyKeys( self::$_createCreditCardSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_PAYMENT_METHOD; return $this->_data($params); } /** * returns the trData string for creating a customer. * @param array $params * @return string */ public function createCustomerData($params) { Util::verifyKeys( self::$_createCustomerSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_CUSTOMER; return $this->_data($params); } public function url() { return $this->_config->baseUrl() . $this->_config->merchantPath() . '/transparent_redirect_requests'; } /** * returns the trData string for creating a transaction * @param array $params * @return string */ public function transactionData($params) { Util::verifyKeys( self::$_transactionSignature, $params ); $params["kind"] = TransparentRedirect::CREATE_TRANSACTION; $transactionType = isset($params['transaction']['type']) ? $params['transaction']['type'] : null; if ($transactionType != Transaction::SALE && $transactionType != Transaction::CREDIT) { throw new InvalidArgumentException( 'expected transaction[type] of sale or credit, was: ' . $transactionType ); } return $this->_data($params); } /** * Returns the trData string for updating a credit card. * * The paymentMethodToken of the credit card to update is required. * * * $trData = TransparentRedirect::updateCreditCardData(array( * 'redirectUrl' => 'http://example.com/redirect_here', * 'paymentMethodToken' => 'token123', * )); * * * @param array $params * @return string */ public function updateCreditCardData($params) { Util::verifyKeys( self::$_updateCreditCardSignature, $params ); if (!isset($params['paymentMethodToken'])) { throw new InvalidArgumentException( 'expected params to contain paymentMethodToken.' ); } $params["kind"] = TransparentRedirect::UPDATE_PAYMENT_METHOD; return $this->_data($params); } /** * Returns the trData string for updating a customer. * * The customerId of the customer to update is required. * * * $trData = TransparentRedirect::updateCustomerData(array( * 'redirectUrl' => 'http://example.com/redirect_here', * 'customerId' => 'customer123', * )); * * * @param array $params * @return string */ public function updateCustomerData($params) { Util::verifyKeys( self::$_updateCustomerSignature, $params ); if (!isset($params['customerId'])) { throw new InvalidArgumentException( 'expected params to contain customerId of customer to update' ); } $params["kind"] = TransparentRedirect::UPDATE_CUSTOMER; return $this->_data($params); } public function parseAndValidateQueryString($queryString) { // parse the params into an array parse_str($queryString, $params); // remove the hash $queryStringWithoutHash = null; if (preg_match('/^(.*)&hash=[a-f0-9]+$/', $queryString, $match)) { $queryStringWithoutHash = $match[1]; } if($params['http_status'] != '200') { $message = null; if(array_key_exists('bt_message', $params)) { $message = $params['bt_message']; } Util::throwStatusCodeException(isset($params['http_status']) ? $params['http_status'] : null, $message); } // recreate the hash and compare it if ($this->_hash($queryStringWithoutHash) == $params['hash']) { return $params; } else { throw new Exception\ForgedQueryString(); } } /** * * @ignore */ private function _data($params) { if (!isset($params['redirectUrl'])) { throw new InvalidArgumentException( 'expected params to contain redirectUrl' ); } $params = $this->_underscoreKeys($params); $now = new DateTime('now', new DateTimeZone('UTC')); $trDataParams = array_merge($params, [ 'api_version' => Configuration::API_VERSION, 'public_key' => $this->_config->publicKey(), 'time' => $now->format('YmdHis'), ] ); ksort($trDataParams); $urlEncodedData = http_build_query($trDataParams, null, "&"); $signatureService = new SignatureService( $this->_config->privateKey(), "Braintree\Digest::hexDigestSha1" ); return $signatureService->sign($urlEncodedData); } private function _underscoreKeys($array) { foreach($array as $key=>$value) { $newKey = Util::camelCaseToDelimiter($key, '_'); unset($array[$key]); if (is_array($value)) { $array[$newKey] = $this->_underscoreKeys($value); } else { $array[$newKey] = $value; } } return $array; } /** * @ignore */ private function _hash($string) { return Digest::hexDigestSha1($this->_config->privateKey(), $string); } } TransparentRedirectGateway::init(); class_alias('Braintree\TransparentRedirectGateway', 'Braintree_TransparentRedirectGateway'); lib/Braintree/UnknownPaymentMethod.php000064400000003215152101632460014075 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $token * @property-read string $imageUrl */ class UnknownPaymentMethod extends Base { /** * factory method: returns an instance of UnknownPaymentMethod * to the requesting method, with populated properties * * @ignore * @return UnknownPaymentMethod */ public static function factory($attributes) { $instance = new self(); $values = array_values($attributes); $instance->_initialize(array_shift($values)); return $instance; } /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * sets instance properties from an array of values * * @access protected * @param array $unknownPaymentMethodAttribs array of unknownPaymentMethod data * @return void */ protected function _initialize($unknownPaymentMethodAttribs) { // set the attributes $this->imageUrl = 'https://assets.braintreegateway.com/payment_method_logo/unknown.png'; $this->_attributes = $unknownPaymentMethodAttribs; } } class_alias('Braintree\UnknownPaymentMethod', 'Braintree_UnknownPaymentMethod'); lib/Braintree/Xml/Parser.php000064400000007535152101632460011744 0ustar00loadXML($xml); $root = $document->documentElement->nodeName; return Util::delimiterToCamelCaseArray([ $root => self::_nodeToValue($document->childNodes->item(0)), ]); } /** * Converts a node to an array of values or nodes * * @param DOMNode @node * @return mixed */ private static function _nodeToArray($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'array': $array = []; foreach ($node->childNodes as $child) { $value = self::_nodeToValue($child); if ($value !== null) { $array[] = $value; } } return $array; case 'collection': $collection = []; foreach ($node->childNodes as $child) { $value = self::_nodetoValue($child); if ($value !== null) { if (!isset($collection[$child->nodeName])) { $collection[$child->nodeName] = []; } $collection[$child->nodeName][] = self::_nodeToValue($child); } } return $collection; default: $values = []; if ($node->childNodes->length === 1 && $node->childNodes->item(0) instanceof DOMText) { return $node->childNodes->item(0)->nodeValue; } else { foreach ($node->childNodes as $child) { if (!$child instanceof DOMText) { $values[$child->nodeName] = self::_nodeToValue($child); } } return $values; } } } /** * Converts a node to a PHP value * * @param DOMNode $node * @return mixed */ private static function _nodeToValue($node) { $type = null; if ($node instanceof DOMElement) { $type = $node->getAttribute('type'); } switch($type) { case 'datetime': return self::_timestampToUTC((string) $node->nodeValue); case 'date': return new DateTime((string) $node->nodeValue); case 'integer': return (int) $node->nodeValue; case 'boolean': $value = (string) $node->nodeValue; if(is_numeric($value)) { return (bool) $value; } else { return ($value !== "true") ? false : true; } case 'array': case 'collection': return self::_nodeToArray($node); default: if ($node->hasChildNodes()) { return self::_nodeToArray($node); } elseif (trim($node->nodeValue) === '') { return null; } else { return $node->nodeValue; } } } /** * Converts XML timestamps into DateTime instances * * @param string $timestamp * @return DateTime */ private static function _timestampToUTC($timestamp) { $tz = new DateTimeZone('UTC'); $dateTime = new DateTime($timestamp, $tz); $dateTime->setTimezone($tz); return $dateTime; } } class_alias('Braintree\Xml\Parser', 'Braintree_Xml_Parser'); lib/Braintree/Xml/Generator.php000064400000011137152101632460012427 0ustar00openMemory(); $writer->setIndent(true); $writer->setIndentString(' '); $writer->startDocument('1.0', 'UTF-8'); // get the root element name $aKeys = array_keys($aData); $rootElementName = $aKeys[0]; // open the root element $writer->startElement($rootElementName); // create the body self::_createElementsFromArray($writer, $aData[$rootElementName], $rootElementName); // close the root element and document $writer->endElement(); $writer->endDocument(); // send the output as string return $writer->outputMemory(); } /** * Construct XML elements with attributes from an associative array. * * @access protected * @static * @param object $writer XMLWriter object * @param array $aData contains attributes and values * @return void */ private static function _createElementsFromArray(&$writer, $aData) { if (!is_array($aData)) { if (is_bool($aData)) { $writer->text($aData ? 'true' : 'false'); } else { $writer->text($aData); } return; } foreach ($aData AS $elementName => $element) { // handle child elements $writer->startElement($elementName); if (is_array($element)) { if (array_key_exists(0, $element) || empty($element)) { $writer->writeAttribute('type', 'array'); foreach ($element AS $ignored => $itemInArray) { $writer->startElement('item'); self::_createElementsFromArray($writer, $itemInArray); $writer->endElement(); } } else { self::_createElementsFromArray($writer, $element); } } else { // generate attributes as needed $attribute = self::_generateXmlAttribute($element); if (is_array($attribute)) { $writer->writeAttribute($attribute[0], $attribute[1]); $element = $attribute[2]; } $writer->text($element); } $writer->endElement(); } } /** * convert passed data into an array of attributeType, attributeName, and value * dates sent as DateTime objects will be converted to strings * @access protected * @param mixed $value * @return array attributes and element value */ private static function _generateXmlAttribute($value) { if ($value instanceof DateTime) { return ['type', 'datetime', self::_dateTimeToXmlTimestamp($value)]; } if (is_int($value)) { return ['type', 'integer', $value]; } if (is_bool($value)) { return ['type', 'boolean', ($value ? 'true' : 'false')]; } if ($value === NULL) { return ['nil', 'true', $value]; } } /** * converts datetime back to xml schema format * @access protected * @param object $dateTime * @return string XML schema formatted timestamp */ private static function _dateTimeToXmlTimestamp($dateTime) { $dateTimeForUTC = clone $dateTime; $dateTimeForUTC->setTimeZone(new DateTimeZone('UTC')); return ($dateTimeForUTC->format('Y-m-d\TH:i:s') . 'Z'); } private static function _castDateTime($string) { try { if (empty($string)) { return false; } $dateTime = new DateTime($string); return self::_dateTimeToXmlTimestamp($dateTime); } catch (Exception $e) { // not a datetime return false; } } } class_alias('Braintree\Xml\Generator', 'Braintree_Xml_Generator'); lib/Braintree/MerchantAccountGateway.php000064400000011747152101632460014350 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function create($attribs) { Util::verifyKeys(self::detectSignature($attribs), $attribs); return $this->_doCreate('/merchant_accounts/create_via_api', ['merchant_account' => $attribs]); } public function find($merchant_account_id) { try { $path = $this->_config->merchantPath() . '/merchant_accounts/' . $merchant_account_id; $response = $this->_http->get($path); return MerchantAccount::factory($response['merchantAccount']); } catch (Exception\NotFound $e) { throw new Exception\NotFound('merchant account with id ' . $merchant_account_id . ' not found'); } } public function update($merchant_account_id, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); return $this->_doUpdate('/merchant_accounts/' . $merchant_account_id . '/update_via_api', ['merchant_account' => $attributes]); } public static function detectSignature($attribs) { if (isset($attribs['applicantDetails'])) { trigger_error("DEPRECATED: Passing applicantDetails to create is deprecated. Please use individual, business, and funding", E_USER_NOTICE); return self::createDeprecatedSignature(); } else { return self::createSignature(); } } public static function updateSignature() { $signature = self::createSignature(); unset($signature['tosAccepted']); return $signature; } public function createForCurrency($attribs) { $response = $this->_http->post($this->_config->merchantPath() . '/merchant_accounts/create_for_currency', ['merchant_account' => $attribs]); return $this->_verifyGatewayResponse($response); } public static function createSignature() { $addressSignature = ['streetAddress', 'postalCode', 'locality', 'region']; $individualSignature = [ 'firstName', 'lastName', 'email', 'phone', 'dateOfBirth', 'ssn', ['address' => $addressSignature] ]; $businessSignature = [ 'dbaName', 'legalName', 'taxId', ['address' => $addressSignature] ]; $fundingSignature = [ 'routingNumber', 'accountNumber', 'destination', 'email', 'mobilePhone', 'descriptor', ]; return [ 'id', 'tosAccepted', 'masterMerchantAccountId', ['individual' => $individualSignature], ['funding' => $fundingSignature], ['business' => $businessSignature] ]; } public static function createDeprecatedSignature() { $applicantDetailsAddressSignature = ['streetAddress', 'postalCode', 'locality', 'region']; $applicantDetailsSignature = [ 'companyName', 'firstName', 'lastName', 'email', 'phone', 'dateOfBirth', 'ssn', 'taxId', 'routingNumber', 'accountNumber', ['address' => $applicantDetailsAddressSignature] ]; return [ ['applicantDetails' => $applicantDetailsSignature], 'id', 'tosAccepted', 'masterMerchantAccountId' ]; } public function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } private function _doUpdate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->put($fullPath, $params); return $this->_verifyGatewayResponse($response); } private function _verifyGatewayResponse($response) { if (isset($response['response'])) { $response = $response['response']; } if (isset($response['merchantAccount'])) { // return a populated instance of merchantAccount return new Result\Successful( MerchantAccount::factory($response['merchantAccount']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected merchant account or apiErrorResponse" ); } } } class_alias('Braintree\MerchantAccountGateway', 'Braintree_MerchantAccountGateway'); lib/Braintree/SubscriptionGateway.php000064400000015762152101632460013757 0ustar00== More information == * * For more detailed information on Subscriptions, see {@link http://www.braintreepayments.com/gateway/subscription-api http://www.braintreepaymentsolutions.com/gateway/subscription-api} * * PHP Version 5 * * @package Braintree * @copyright 2015 Braintree, a division of PayPal, Inc. */ class SubscriptionGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function create($attributes) { Util::verifyKeys(self::_createSignature(), $attributes); $path = $this->_config->merchantPath() . '/subscriptions'; $response = $this->_http->post($path, ['subscription' => $attributes]); return $this->_verifyGatewayResponse($response); } public function find($id) { $this->_validateId($id); try { $path = $this->_config->merchantPath() . '/subscriptions/' . $id; $response = $this->_http->get($path); return Subscription::factory($response['subscription']); } catch (Exception\NotFound $e) { throw new Exception\NotFound('subscription with id ' . $id . ' not found'); } } public function search($query) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $path = $this->_config->merchantPath() . '/subscriptions/advanced_search_ids'; $response = $this->_http->post($path, ['search' => $criteria]); $pager = [ 'object' => $this, 'method' => 'fetch', 'methodArgs' => [$query] ]; return new ResourceCollection($response, $pager); } public function fetch($query, $ids) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $criteria["ids"] = SubscriptionSearch::ids()->in($ids)->toparam(); $path = $this->_config->merchantPath() . '/subscriptions/advanced_search'; $response = $this->_http->post($path, ['search' => $criteria]); return Util::extractAttributeAsArray( $response['subscriptions'], 'subscription' ); } public function update($subscriptionId, $attributes) { Util::verifyKeys(self::_updateSignature(), $attributes); $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId; $response = $this->_http->put($path, ['subscription' => $attributes]); return $this->_verifyGatewayResponse($response); } public function retryCharge($subscriptionId, $amount = null) { $transaction_params = ['type' => Transaction::SALE, 'subscriptionId' => $subscriptionId]; if (isset($amount)) { $transaction_params['amount'] = $amount; } $path = $this->_config->merchantPath() . '/transactions'; $response = $this->_http->post($path, ['transaction' => $transaction_params]); return $this->_verifyGatewayResponse($response); } public function cancel($subscriptionId) { $path = $this->_config->merchantPath() . '/subscriptions/' . $subscriptionId . '/cancel'; $response = $this->_http->put($path); return $this->_verifyGatewayResponse($response); } private static function _createSignature() { return array_merge( [ 'billingDayOfMonth', 'firstBillingDate', 'createdAt', 'updatedAt', 'id', 'merchantAccountId', 'neverExpires', 'numberOfBillingCycles', 'paymentMethodToken', 'paymentMethodNonce', 'planId', 'price', 'trialDuration', 'trialDurationUnit', 'trialPeriod', ['descriptor' => ['name', 'phone', 'url']], ['options' => ['doNotInheritAddOnsOrDiscounts', 'startImmediately']], ], self::_addOnDiscountSignature() ); } private static function _updateSignature() { return array_merge( [ 'merchantAccountId', 'numberOfBillingCycles', 'paymentMethodToken', 'planId', 'paymentMethodNonce', 'id', 'neverExpires', 'price', ['descriptor' => ['name', 'phone', 'url']], ['options' => ['prorateCharges', 'replaceAllAddOnsAndDiscounts', 'revertSubscriptionOnProrationFailure']], ], self::_addOnDiscountSignature() ); } private static function _addOnDiscountSignature() { return [ [ 'addOns' => [ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], ['remove' => ['_anyKey_']], ] ], [ 'discounts' => [ ['add' => ['amount', 'inheritedFromId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], ['update' => ['amount', 'existingId', 'neverExpires', 'numberOfBillingCycles', 'quantity']], ['remove' => ['_anyKey_']], ] ] ]; } /** * @ignore */ private function _validateId($id = null) { if (empty($id)) { throw new InvalidArgumentException( 'expected subscription id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid subscription id.' ); } } /** * @ignore */ private function _verifyGatewayResponse($response) { if (isset($response['subscription'])) { return new Result\Successful( Subscription::factory($response['subscription']) ); } else if (isset($response['transaction'])) { // return a populated instance of Transaction, for subscription retryCharge return new Result\Successful( Transaction::factory($response['transaction']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected subscription, transaction, or apiErrorResponse" ); } } } class_alias('Braintree\SubscriptionGateway', 'Braintree_SubscriptionGateway'); lib/Braintree/PaymentMethodNonceGateway.php000064400000003205152101632460015021 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * */ class PaymentMethodNonceGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_http = new Http($gateway->config); } public function create($token) { $subPath = '/payment_methods/' . $token . '/nonces'; $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath); return new Result\Successful( PaymentMethodNonce::factory($response['paymentMethodNonce']), "paymentMethodNonce" ); } /** * @access public * */ public function find($nonce) { try { $path = $this->_config->merchantPath() . '/payment_method_nonces/' . $nonce; $response = $this->_http->get($path); return PaymentMethodNonce::factory($response['paymentMethodNonce']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'payment method nonce with id ' . $nonce . ' not found' ); } } } class_alias('Braintree\PaymentMethodNonceGateway', 'Braintree_PaymentMethodNonceGateway'); lib/Braintree/Http.php000064400000014246152101632460010664 0ustar00_config = $config; } public function delete($path) { $response = $this->_doRequest('DELETE', $path); if($response['status'] === 200) { return true; } else { Util::throwStatusCodeException($response['status']); } } public function get($path) { $response = $this->_doRequest('GET', $path); if ($response['status'] === 200) { return Xml::buildArrayFromXml($response['body']); } else { Util::throwStatusCodeException($response['status']); } } public function post($path, $params = null) { $response = $this->_doRequest('POST', $path, $this->_buildXml($params)); $responseCode = $response['status']; if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) { return Xml::buildArrayFromXml($response['body']); } else { Util::throwStatusCodeException($responseCode); } } public function put($path, $params = null) { $response = $this->_doRequest('PUT', $path, $this->_buildXml($params)); $responseCode = $response['status']; if($responseCode === 200 || $responseCode === 201 || $responseCode === 422 || $responseCode == 400) { return Xml::buildArrayFromXml($response['body']); } else { Util::throwStatusCodeException($responseCode); } } private function _buildXml($params) { return empty($params) ? null : Xml::buildXmlFromArray($params); } private function _getHeaders() { return [ 'Accept: application/xml', 'Content-Type: application/xml', ]; } private function _getAuthorization() { if ($this->_useClientCredentials) { return [ 'user' => $this->_config->getClientId(), 'password' => $this->_config->getClientSecret(), ]; } else if ($this->_config->isAccessToken()) { return [ 'token' => $this->_config->getAccessToken(), ]; } else { return [ 'user' => $this->_config->getPublicKey(), 'password' => $this->_config->getPrivateKey(), ]; } } public function useClientCredentials() { $this->_useClientCredentials = true; } private function _doRequest($httpVerb, $path, $requestBody = null) { return $this->_doUrlRequest($httpVerb, $this->_config->baseUrl() . $path, $requestBody); } public function _doUrlRequest($httpVerb, $url, $requestBody = null) { $curl = curl_init(); curl_setopt($curl, CURLOPT_TIMEOUT, $this->_config->timeout()); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $httpVerb); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_ENCODING, 'gzip'); $headers = $this->_getHeaders($curl); $headers[] = 'User-Agent: Braintree PHP Library ' . Version::get(); $headers[] = 'X-ApiVersion: ' . Configuration::API_VERSION; $authorization = $this->_getAuthorization(); if (isset($authorization['user'])) { curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC); curl_setopt($curl, CURLOPT_USERPWD, $authorization['user'] . ':' . $authorization['password']); } else if (isset($authorization['token'])) { $headers[] = 'Authorization: Bearer ' . $authorization['token']; } curl_setopt($curl, CURLOPT_HTTPHEADER, $headers); // curl_setopt($curl, CURLOPT_VERBOSE, true); if ($this->_config->sslOn()) { curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, 2); curl_setopt($curl, CURLOPT_CAINFO, $this->getCaFile()); } if(!empty($requestBody)) { curl_setopt($curl, CURLOPT_POSTFIELDS, $requestBody); } if($this->_config->isUsingProxy()) { $proxyHost = $this->_config->getProxyHost(); $proxyPort = $this->_config->getProxyPort(); $proxyType = $this->_config->getProxyType(); $proxyUser = $this->_config->getProxyUser(); $proxyPwd= $this->_config->getProxyPassword(); curl_setopt($curl, CURLOPT_PROXY, $proxyHost . ':' . $proxyPort); if(!empty($proxyType)) { curl_setopt($curl, CURLOPT_PROXYTYPE, $proxyType); } if($this->_config->isAuthenticatedProxy()) { curl_setopt($curl, CURLOPT_PROXYUSERPWD, $proxyUser . ':' . $proxyPwd); } } curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); $httpStatus = curl_getinfo($curl, CURLINFO_HTTP_CODE); $error_code = curl_errno($curl); if ($error_code == 28 && $httpStatus == 0) { throw new Exception\Timeout(); } curl_close($curl); if ($this->_config->sslOn()) { if ($httpStatus == 0) { throw new Exception\SSLCertificate(); } } return ['status' => $httpStatus, 'body' => $response]; } private function getCaFile() { static $memo; if ($memo === null) { $caFile = $this->_config->caFile(); if (substr($caFile, 0, 7) !== 'phar://') { return $caFile; } $extractedCaFile = sys_get_temp_dir() . '/api_braintreegateway_com.ca.crt'; if (!file_exists($extractedCaFile) || sha1_file($extractedCaFile) != sha1_file($caFile)) { if (!copy($caFile, $extractedCaFile)) { throw new Exception\SSLCaFileNotFound(); } } $memo = $extractedCaFile; } return $memo; } } class_alias('Braintree\Http', 'Braintree_Http'); lib/Braintree/OAuthGateway.php000064400000007611152101632460012305 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_http = new Http($gateway->config); $this->_http->useClientCredentials(); $this->_config->assertHasClientCredentials(); } public function createTokenFromCode($params) { $params['grantType'] = "authorization_code"; return $this->_createToken($params); } public function createTokenFromRefreshToken($params) { $params['grantType'] = "refresh_token"; return $this->_createToken($params); } public function revokeAccessToken($accessToken) { $params = ['token' => $accessToken]; $response = $this->_http->post('/oauth/revoke_access_token', $params); return $this->_verifyGatewayResponse($response); } private function _createToken($params) { $params = ['credentials' => $params]; $response = $this->_http->post('/oauth/access_tokens', $params); return $this->_verifyGatewayResponse($response); } private function _verifyGatewayResponse($response) { if (isset($response['credentials'])) { $result = new Result\Successful( OAuthCredentials::factory($response['credentials']) ); return $this->_mapSuccess($result); } else if (isset($response['result'])) { $result = new Result\Successful( OAuthResult::factory($response['result']) ); return $this->_mapAccessTokenRevokeSuccess($result); } else if (isset($response['apiErrorResponse'])) { $result = new Result\Error($response['apiErrorResponse']); return $this->_mapError($result); } else { throw new Exception\Unexpected( "Expected credentials or apiErrorResponse" ); } } public function _mapError($result) { $error = $result->errors->deepAll()[0]; if ($error->code == Error\Codes::OAUTH_INVALID_GRANT) { $result->error = 'invalid_grant'; } else if ($error->code == Error\Codes::OAUTH_INVALID_CREDENTIALS) { $result->error = 'invalid_credentials'; } else if ($error->code == Error\Codes::OAUTH_INVALID_SCOPE) { $result->error = 'invalid_scope'; } $result->errorDescription = explode(': ', $error->message)[1]; return $result; } public function _mapAccessTokenRevokeSuccess($result) { $result->revocationResult = $result->success; return $result; } public function _mapSuccess($result) { $credentials = $result->credentials; $result->accessToken = $credentials->accessToken; $result->refreshToken = $credentials->refreshToken; $result->tokenType = $credentials->tokenType; $result->expiresAt = $credentials->expiresAt; return $result; } public function connectUrl($params = []) { $query = Util::camelCaseToDelimiterArray($params, '_'); $query['client_id'] = $this->_config->getClientId(); $queryString = preg_replace('/\%5B\d+\%5D/', '%5B%5D', http_build_query($query)); $url = $this->_config->baseUrl() . '/oauth/connect?' . $queryString; return $url . '&signature=' . $this->computeSignature($url) . '&algorithm=SHA256'; } public function computeSignature($url) { $key = hash('sha256', $this->_config->getClientSecret(), true); return hash_hmac('sha256', $url, $key); } } class_alias('Braintree\OAuthGateway', 'Braintree_OAuthGateway'); lib/Braintree/PaymentMethodGateway.php000064400000024321152101632460014040 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * */ class PaymentMethodGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function create($attribs) { Util::verifyKeys(self::createSignature(), $attribs); return $this->_doCreate('/payment_methods', ['payment_method' => $attribs]); } /** * find a PaymentMethod by token * * @param string $token payment method unique id * @return CreditCard|PayPalAccount * @throws Exception\NotFound */ public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; $response = $this->_http->get($path); if (isset($response['creditCard'])) { return CreditCard::factory($response['creditCard']); } else if (isset($response['paypalAccount'])) { return PayPalAccount::factory($response['paypalAccount']); } else if (isset($response['coinbaseAccount'])) { return CoinbaseAccount::factory($response['coinbaseAccount']); } else if (isset($response['applePayCard'])) { return ApplePayCard::factory($response['applePayCard']); } else if (isset($response['androidPayCard'])) { return AndroidPayCard::factory($response['androidPayCard']); } else if (isset($response['amexExpressCheckoutCard'])) { return AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']); } else if (isset($response['europeBankAccount'])) { return EuropeBankAccount::factory($response['europeBankAccount']); } else if (isset($response['usBankAccount'])) { return UsBankAccount::factory($response['usBankAccount']); } else if (isset($response['venmoAccount'])) { return VenmoAccount::factory($response['venmoAccount']); } else if (is_array($response)) { return UnknownPaymentMethod::factory($response); } } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'payment method with token ' . $token . ' not found' ); } } public function update($token, $attribs) { Util::verifyKeys(self::updateSignature(), $attribs); return $this->_doUpdate('/payment_methods/any/' . $token, ['payment_method' => $attribs]); } public function delete($token) { $this->_validateId($token); $path = $this->_config->merchantPath() . '/payment_methods/any/' . $token; $this->_http->delete($path); return new Result\Successful(); } public function grant($sharedPaymentMethodToken, $attribs=[]) { if (is_bool($attribs) === true) { $attribs = ['allow_vaulting' => $attribs]; } $options = [ 'shared_payment_method_token' => $sharedPaymentMethodToken ]; return $this->_doCreate( '/payment_methods/grant', [ 'payment_method' => array_merge($attribs, $options) ] ); } public function revoke($sharedPaymentMethodToken) { return $this->_doCreate( '/payment_methods/revoke', [ 'payment_method' => [ 'shared_payment_method_token' => $sharedPaymentMethodToken ] ] ); } private static function baseSignature() { $billingAddressSignature = AddressGateway::createSignature(); $optionsSignature = [ 'failOnDuplicatePaymentMethod', 'makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount' ]; return [ 'billingAddressId', 'cardholderName', 'cvv', 'deviceData', 'expirationDate', 'expirationMonth', 'expirationYear', 'number', 'paymentMethodNonce', 'token', ['options' => $optionsSignature], ['billingAddress' => $billingAddressSignature] ]; } public static function createSignature() { $signature = array_merge(self::baseSignature(), ['customerId']); return $signature; } public static function updateSignature() { $billingAddressSignature = AddressGateway::updateSignature(); array_push($billingAddressSignature, [ 'options' => [ 'updateExisting' ] ]); $signature = array_merge(self::baseSignature(), [ 'deviceSessionId', 'venmoSdkPaymentMethodCode', 'fraudMerchantId', ['billingAddress' => $billingAddressSignature] ]); return $signature; } /** * sends the create request to the gateway * * @ignore * @param string $subPath * @param array $params * @return mixed */ public function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * sends the update request to the gateway * * @ignore * @param string $subPath * @param array $params * @return mixed */ public function _doUpdate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->put($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * generic method for validating incoming gateway responses * * creates a new CreditCard or PayPalAccount object * and encapsulates it inside a Result\Successful object, or * encapsulates a Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid. * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['creditCard'])) { return new Result\Successful( CreditCard::factory($response['creditCard']), 'paymentMethod' ); } else if (isset($response['paypalAccount'])) { return new Result\Successful( PayPalAccount::factory($response['paypalAccount']), "paymentMethod" ); } else if (isset($response['coinbaseAccount'])) { return new Result\Successful( CoinbaseAccount::factory($response['coinbaseAccount']), "paymentMethod" ); } else if (isset($response['applePayCard'])) { return new Result\Successful( ApplePayCard::factory($response['applePayCard']), "paymentMethod" ); } else if (isset($response['androidPayCard'])) { return new Result\Successful( AndroidPayCard::factory($response['androidPayCard']), "paymentMethod" ); } else if (isset($response['amexExpressCheckoutCard'])) { return new Result\Successful( AmexExpressCheckoutCard::factory($response['amexExpressCheckoutCard']), "paymentMethod" ); } else if (isset($response['europeBankAccount'])) { return new Result\Successful( EuropeBankAccount::factory($response['europeBankAccount']), "paymentMethod" ); } else if (isset($response['usBankAccount'])) { return new Result\Successful( UsBankAccount::factory($response['usBankAccount']), "paymentMethod" ); } else if (isset($response['venmoAccount'])) { return new Result\Successful( VenmoAccount::factory($response['venmoAccount']), "paymentMethod" ); } else if (isset($response['paymentMethodNonce'])) { return new Result\Successful( PaymentMethodNonce::factory($response['paymentMethodNonce']), "paymentMethodNonce" ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else if (is_array($response)) { return new Result\Successful( UnknownPaymentMethod::factory($response), "paymentMethod" ); } else { throw new Exception\Unexpected( 'Expected payment method or apiErrorResponse' ); } } /** * verifies that a valid payment method identifier is being used * @ignore * @param string $identifier * @param Optional $string $identifierType type of identifier supplied, default 'token' * @throws InvalidArgumentException */ private function _validateId($identifier = null, $identifierType = 'token') { if (empty($identifier)) { throw new InvalidArgumentException( 'expected payment method id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) { throw new InvalidArgumentException( $identifier . ' is an invalid payment method ' . $identifierType . '.' ); } } } class_alias('Braintree\PaymentMethodGateway', 'Braintree_PaymentMethodGateway'); lib/Braintree/AddOnGateway.php000064400000001670152101632460012251 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } /** * * @return AddOn[] */ public function all() { $path = $this->_config->merchantPath() . '/add_ons'; $response = $this->_http->get($path); $addOns = ["addOn" => $response['addOns']]; return Util::extractAttributeAsArray( $addOns, 'addOn' ); } } class_alias('Braintree\AddOnGateway', 'Braintree_AddOnGateway'); lib/Braintree/Test/Nonces.php000064400000007327152101632460012113 0ustar00 '378734493671000', 'Discover' => '6011000990139424', 'MasterCard' => '5105105105105100', 'Visa' => '4000111111111115', ]; public static $amexPayWithPoints = [ 'Success' => "371260714673002", 'IneligibleCard' => "378267515471109", 'InsufficientPoints' => "371544868764018", ]; public static function getAll() { return array_merge( self::$amExes, self::$discoverCards, self::$masterCards, self::$visas ); } } class_alias('Braintree\Test\CreditCardNumbers', 'Braintree_Test_CreditCardNumbers'); lib/Braintree/Test/Transaction.php000064400000003411152101632460013141 0ustar00testing()->settle($transactionId); } /** * settlement confirm a transaction by id in sandbox * * @param string $id transaction id * @param Configuration $config gateway config * @return Transaction */ public static function settlementConfirm($transactionId) { return Configuration::gateway()->testing()->settlementConfirm($transactionId); } /** * settlement decline a transaction by id in sandbox * * @param string $id transaction id * @param Configuration $config gateway config * @return Transaction */ public static function settlementDecline($transactionId) { return Configuration::gateway()->testing()->settlementDecline($transactionId); } /** * settlement pending a transaction by id in sandbox * * @param string $id transaction id * @param Configuration $config gateway config * @return Transaction */ public static function settlementPending($transactionId) { return Configuration::gateway()->testing()->settlementPending($transactionId); } } class_alias('Braintree\Test\Transaction', 'Braintree_Test_Transaction'); lib/Braintree/Test/TransactionAmounts.php000064400000001006152101632460014506 0ustar00_attributes = $attributes; } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } public function __toString() { return get_called_class() . '[' . Util::attributesToString($this->_attributes) . ']'; } } class_alias('Braintree\Modification', 'Braintree_Modification'); lib/Braintree/Xml.php000064400000001317152101632460010500 0ustar00key = $key; $this->digest = $digest; } public function sign($payload) { return $this->hash($payload) . "|" . $payload; } public function hash($data) { return call_user_func($this->digest, $this->key, $data); } } class_alias('Braintree\SignatureService', 'Braintree_SignatureService'); lib/Braintree/AddOn.php000064400000001046152101632460010724 0ustar00_initialize($attributes); return $instance; } /** * static methods redirecting to gateway * * @return AddOn[] */ public static function all() { return Configuration::gateway()->addOn()->all(); } } class_alias('Braintree\AddOn', 'Braintree_AddOn'); lib/Braintree/Address.php000064400000007714152101632460011334 0ustar00id === $other->id && $this->customerId === $other->customerId); } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @ignore * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) . ']'; } /** * sets instance properties from an array of values * * @ignore * @access protected * @param array $addressAttribs array of address data * @return void */ protected function _initialize($addressAttribs) { // set the attributes $this->_attributes = $addressAttribs; } /** * factory method: returns an instance of Address * to the requesting method, with populated properties * @ignore * @return Address */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } // static methods redirecting to gateway /** * * @param array $attribs * @return Address */ public static function create($attribs) { return Configuration::gateway()->address()->create($attribs); } /** * * @param array $attribs * @return Address */ public static function createNoValidate($attribs) { return Configuration::gateway()->address()->createNoValidate($attribs); } /** * * @param Customer|int $customerOrId * @param int $addressId * @throws InvalidArgumentException * @return Result\Successful */ public static function delete($customerOrId = null, $addressId = null) { return Configuration::gateway()->address()->delete($customerOrId, $addressId); } /** * * @param Customer|int $customerOrId * @param int $addressId * @throws Exception\NotFound * @return Address */ public static function find($customerOrId, $addressId) { return Configuration::gateway()->address()->find($customerOrId, $addressId); } /** * * @param Customer|int $customerOrId * @param int $addressId * @param array $attributes * @throws Exception\Unexpected * @return Result\Successful|Result\Error */ public static function update($customerOrId, $addressId, $attributes) { return Configuration::gateway()->address()->update($customerOrId, $addressId, $attributes); } public static function updateNoValidate($customerOrId, $addressId, $attributes) { return Configuration::gateway()->address()->updateNoValidate($customerOrId, $addressId, $attributes); } } class_alias('Braintree\Address', 'Braintree_Address'); lib/Braintree/AmexExpressCheckoutCard.php000064400000004461152101632460014467 0ustar00== More information == * * See {@link https://developers.braintreepayments.com/javascript+php}
* * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $createdAt * @property-read string $default * @property-read string $updatedAt * @property-read string $customerId * @property-read string $cardType * @property-read string $bin * @property-read string $cardMemberExpiryDate * @property-read string $cardMemberNumber * @property-read string $cardType * @property-read string $sourceDescription * @property-read string $token * @property-read string $imageUrl * @property-read string $expirationMonth * @property-read string $expirationYear */ class AmexExpressCheckoutCard extends Base { /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * factory method: returns an instance of AmexExpressCheckoutCard * to the requesting method, with populated properties * * @ignore * @return AmexExpressCheckoutCard */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /** * sets instance properties from an array of values * * @access protected * @param array $amexExpressCheckoutCardAttribs array of Amex Express Checkout card properties * @return void */ protected function _initialize($amexExpressCheckoutCardAttribs) { // set the attributes $this->_attributes = $amexExpressCheckoutCardAttribs; $subscriptionArray = []; if (isset($amexExpressCheckoutCardAttribs['subscriptions'])) { foreach ($amexExpressCheckoutCardAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = Subscription::factory($subscription); } } $this->_set('subscriptions', $subscriptionArray); } } class_alias('Braintree\AmexExpressCheckoutCard', 'Braintree_AmexExpressCheckoutCard'); lib/Braintree/PayPalAccountGateway.php000064400000012246152101632460013770 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. */ class PayPalAccountGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } /** * find a paypalAccount by token * * @access public * @param string $token paypal accountunique id * @return PayPalAccount * @throws Exception\NotFound */ public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; $response = $this->_http->get($path); return PayPalAccount::factory($response['paypalAccount']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'paypal account with token ' . $token . ' not found' ); } } /** * updates the paypalAccount record * * if calling this method in context, $token * is the 2nd attribute. $token is not sent in object context. * * @access public * @param array $attributes * @param string $token (optional) * @return Result\Successful or Result\Error */ public function update($token, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); $this->_validateId($token); return $this->_doUpdate('put', '/payment_methods/paypal_account/' . $token, ['paypalAccount' => $attributes]); } public function delete($token) { $this->_validateId($token); $path = $this->_config->merchantPath() . '/payment_methods/paypal_account/' . $token; $this->_http->delete($path); return new Result\Successful(); } /** * create a new sale for the current PayPal account * * @param string $token * @param array $transactionAttribs * @return Result\Successful|Result\Error * @see Transaction::sale() */ public function sale($token, $transactionAttribs) { $this->_validateId($token); return Transaction::sale( array_merge( $transactionAttribs, ['paymentMethodToken' => $token] ) ); } public static function updateSignature() { return [ 'token', ['options' => ['makeDefault']] ]; } /** * sends the update request to the gateway * * @ignore * @param string $subPath * @param array $params * @return mixed */ private function _doUpdate($httpVerb, $subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->$httpVerb($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * generic method for validating incoming gateway responses * * creates a new PayPalAccount object and encapsulates * it inside a Result\Successful object, or * encapsulates a Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid. * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['paypalAccount'])) { // return a populated instance of PayPalAccount return new Result\Successful( PayPalAccount::factory($response['paypalAccount']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( 'Expected paypal account or apiErrorResponse' ); } } /** * verifies that a valid paypal account identifier is being used * @ignore * @param string $identifier * @param Optional $string $identifierType type of identifier supplied, default 'token' * @throws InvalidArgumentException */ private function _validateId($identifier = null, $identifierType = 'token') { if (empty($identifier)) { throw new InvalidArgumentException( 'expected paypal account id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) { throw new InvalidArgumentException( $identifier . ' is an invalid paypal account ' . $identifierType . '.' ); } } } class_alias('Braintree\PayPalAccountGateway', 'Braintree_PayPalAccountGateway'); lib/Braintree/RangeNode.php000064400000001416152101632460011602 0ustar00name = $name; $this->searchTerms = []; } public function greaterThanOrEqualTo($value) { $this->searchTerms['min'] = $value; return $this; } public function lessThanOrEqualTo($value) { $this->searchTerms['max'] = $value; return $this; } public function is($value) { $this->searchTerms['is'] = $value; return $this; } public function between($min, $max) { return $this->greaterThanOrEqualTo($min)->lessThanOrEqualTo($max); } public function toParam() { return $this->searchTerms; } } class_alias('Braintree\RangeNode', 'Braintree_RangeNode'); lib/Braintree/CreditCardVerificationGateway.php000064400000004400152101632460015625 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function create($attributes) { $response = $this->_http->post($this->_config->merchantPath() . "/verifications", ['verification' => $attributes]); return $this->_verifyGatewayResponse($response); } private function _verifyGatewayResponse($response) { if(isset($response['verification'])){ return new Result\Successful( CreditCardVerification::factory($response['verification']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected transaction or apiErrorResponse" ); } } public function fetch($query, $ids) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $criteria["ids"] = CreditCardVerificationSearch::ids()->in($ids)->toparam(); $path = $this->_config->merchantPath() . '/verifications/advanced_search'; $response = $this->_http->post($path, ['search' => $criteria]); return Util::extractattributeasarray( $response['creditCardVerifications'], 'verification' ); } public function search($query) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $path = $this->_config->merchantPath() . '/verifications/advanced_search_ids'; $response = $this->_http->post($path, ['search' => $criteria]); $pager = [ 'object' => $this, 'method' => 'fetch', 'methodArgs' => [$query] ]; return new ResourceCollection($response, $pager); } } class_alias('Braintree\CreditCardVerificationGateway', 'Braintree_CreditCardVerificationGateway'); lib/Braintree/CoinbaseAccount.php000064400000005426152101632460013005 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $customerId * @property-read string $token * @property-read string $userId * @property-read string $userName * @property-read string $userEmail */ class CoinbaseAccount extends Base { /** * factory method: returns an instance of CoinbaseAccount * to the requesting method, with populated properties * * @ignore * @return CoinbaseAccount */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * sets instance properties from an array of values * * @access protected * @param array $coinbaseAccountAttribs array of coinbaseAccount data * @return void */ protected function _initialize($coinbaseAccountAttribs) { // set the attributes $this->_attributes = $coinbaseAccountAttribs; $subscriptionArray = []; if (isset($coinbaseAccountAttribs['subscriptions'])) { foreach ($coinbaseAccountAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = Subscription::factory($subscription); } } $this->_set('subscriptions', $subscriptionArray); } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } // static methods redirecting to gateway public static function find($token) { return Configuration::gateway()->coinbaseAccount()->find($token); } public static function update($token, $attributes) { return Configuration::gateway()->coinbaseAccount()->update($token, $attributes); } public static function delete($token) { return Configuration::gateway()->coinbaseAccount()->delete($token); } public static function sale($token, $transactionAttribs) { return Configuration::gateway()->coinbaseAccount()->sale($token, $transactionAttribs); } } class_alias('Braintree\CoinbaseAccount', 'Braintree_CoinbaseAccount'); lib/Braintree/MerchantAccount.php000064400000004161152101632460013016 0ustar00_initialize($attributes); return $instance; } protected function _initialize($merchantAccountAttribs) { $this->_attributes = $merchantAccountAttribs; if (isset($merchantAccountAttribs['individual'])) { $individual = $merchantAccountAttribs['individual']; $this->_set('individualDetails', MerchantAccount\IndividualDetails::Factory($individual)); } if (isset($merchantAccountAttribs['business'])) { $business = $merchantAccountAttribs['business']; $this->_set('businessDetails', MerchantAccount\BusinessDetails::Factory($business)); } if (isset($merchantAccountAttribs['funding'])) { $funding = $merchantAccountAttribs['funding']; $this->_set('fundingDetails', new MerchantAccount\FundingDetails($funding)); } if (isset($merchantAccountAttribs['masterMerchantAccount'])) { $masterMerchantAccount = $merchantAccountAttribs['masterMerchantAccount']; $this->_set('masterMerchantAccount', self::Factory($masterMerchantAccount)); } } // static methods redirecting to gateway public static function create($attribs) { return Configuration::gateway()->merchantAccount()->create($attribs); } public static function find($merchant_account_id) { return Configuration::gateway()->merchantAccount()->find($merchant_account_id); } public static function update($merchant_account_id, $attributes) { return Configuration::gateway()->merchantAccount()->update($merchant_account_id, $attributes); } } class_alias('Braintree\MerchantAccount', 'Braintree_MerchantAccount'); lib/Braintree/CreditCardGateway.php000064400000035644152101632460013300 0ustar00== More information == * * For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}
* For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api} * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. */ class CreditCardGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function create($attribs) { Util::verifyKeys(self::createSignature(), $attribs); return $this->_doCreate('/payment_methods', ['credit_card' => $attribs]); } /** * attempts the create operation assuming all data will validate * returns a CreditCard object instead of a Result * * @access public * @param array $attribs * @return CreditCard * @throws Exception\ValidationError */ public function createNoValidate($attribs) { $result = $this->create($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * create a customer from a TransparentRedirect operation * * @deprecated since version 2.3.0 * @access public * @param array $attribs * @return Result\Successful|Result\Error */ public function createFromTransparentRedirect($queryString) { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); $params = TransparentRedirect::parseAndValidateQueryString( $queryString ); return $this->_doCreate( '/payment_methods/all/confirm_transparent_redirect_request', ['id' => $params['id']] ); } /** * * @deprecated since version 2.3.0 * @access public * @param none * @return string */ public function createCreditCardUrl() { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); return $this->_config->baseUrl() . $this->_config->merchantPath(). '/payment_methods/all/create_via_transparent_redirect_request'; } /** * returns a ResourceCollection of expired credit cards * @return ResourceCollection */ public function expired() { $path = $this->_config->merchantPath() . '/payment_methods/all/expired_ids'; $response = $this->_http->post($path); $pager = [ 'object' => $this, 'method' => 'fetchExpired', 'methodArgs' => [] ]; return new ResourceCollection($response, $pager); } public function fetchExpired($ids) { $path = $this->_config->merchantPath() . "/payment_methods/all/expired"; $response = $this->_http->post($path, ['search' => ['ids' => $ids]]); return Util::extractattributeasarray( $response['paymentMethods'], 'creditCard' ); } /** * returns a ResourceCollection of credit cards expiring between start/end * * @return ResourceCollection */ public function expiringBetween($startDate, $endDate) { $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring_ids?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate); $response = $this->_http->post($queryPath); $pager = [ 'object' => $this, 'method' => 'fetchExpiring', 'methodArgs' => [$startDate, $endDate] ]; return new ResourceCollection($response, $pager); } public function fetchExpiring($startDate, $endDate, $ids) { $queryPath = $this->_config->merchantPath() . '/payment_methods/all/expiring?start=' . date('mY', $startDate) . '&end=' . date('mY', $endDate); $response = $this->_http->post($queryPath, ['search' => ['ids' => $ids]]); return Util::extractAttributeAsArray( $response['paymentMethods'], 'creditCard' ); } /** * find a creditcard by token * * @access public * @param string $token credit card unique id * @return CreditCard * @throws Exception\NotFound */ public function find($token) { $this->_validateId($token); try { $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token; $response = $this->_http->get($path); return CreditCard::factory($response['creditCard']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'credit card with token ' . $token . ' not found' ); } } /** * Convert a payment method nonce to a credit card * * @access public * @param string $nonce payment method nonce * @return CreditCard * @throws Exception\NotFound */ public function fromNonce($nonce) { $this->_validateId($nonce, "nonce"); try { $path = $this->_config->merchantPath() . '/payment_methods/from_nonce/' . $nonce; $response = $this->_http->get($path); return CreditCard::factory($response['creditCard']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'credit card with nonce ' . $nonce . ' locked, consumed or not found' ); } } /** * create a credit on the card for the passed transaction * * @access public * @param array $attribs * @return Result\Successful|Result\Error */ public function credit($token, $transactionAttribs) { $this->_validateId($token); return Transaction::credit( array_merge( $transactionAttribs, ['paymentMethodToken' => $token] ) ); } /** * create a credit on this card, assuming validations will pass * * returns a Transaction object on success * * @access public * @param array $attribs * @return Transaction * @throws Exception\ValidationError */ public function creditNoValidate($token, $transactionAttribs) { $result = $this->credit($token, $transactionAttribs); return Util::returnObjectOrThrowException('Braintree\Transaction', $result); } /** * create a new sale for the current card * * @param string $token * @param array $transactionAttribs * @return Result\Successful|Result\Error * @see Transaction::sale() */ public function sale($token, $transactionAttribs) { $this->_validateId($token); return Transaction::sale( array_merge( $transactionAttribs, ['paymentMethodToken' => $token] ) ); } /** * create a new sale using this card, assuming validations will pass * * returns a Transaction object on success * * @access public * @param array $transactionAttribs * @param string $token * @return Transaction * @throws Exception\ValidationsFailed * @see Transaction::sale() */ public function saleNoValidate($token, $transactionAttribs) { $result = $this->sale($token, $transactionAttribs); return Util::returnObjectOrThrowException('Braintree\Transaction', $result); } /** * updates the creditcard record * * if calling this method in context, $token * is the 2nd attribute. $token is not sent in object context. * * @access public * @param array $attributes * @param string $token (optional) * @return Result\Successful|Result\Error */ public function update($token, $attributes) { Util::verifyKeys(self::updateSignature(), $attributes); $this->_validateId($token); return $this->_doUpdate('put', '/payment_methods/credit_card/' . $token, ['creditCard' => $attributes]); } /** * update a creditcard record, assuming validations will pass * * if calling this method in context, $token * is the 2nd attribute. $token is not sent in object context. * returns a CreditCard object on success * * @access public * @param array $attributes * @param string $token * @return CreditCard * @throws Exception\ValidationsFailed */ public function updateNoValidate($token, $attributes) { $result = $this->update($token, $attributes); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * * @access public * @param none * @return string */ public function updateCreditCardUrl() { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); return $this->_config->baseUrl() . $this->_config->merchantPath() . '/payment_methods/all/update_via_transparent_redirect_request'; } /** * update a customer from a TransparentRedirect operation * * @deprecated since version 2.3.0 * @access public * @param array $attribs * @return object */ public function updateFromTransparentRedirect($queryString) { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); $params = TransparentRedirect::parseAndValidateQueryString( $queryString ); return $this->_doUpdate( 'post', '/payment_methods/all/confirm_transparent_redirect_request', ['id' => $params['id']] ); } public function delete($token) { $this->_validateId($token); $path = $this->_config->merchantPath() . '/payment_methods/credit_card/' . $token; $this->_http->delete($path); return new Result\Successful(); } private static function baseOptions() { return ['makeDefault', 'verificationMerchantAccountId', 'verifyCard', 'verificationAmount', 'venmoSdkSession']; } private static function baseSignature($options) { return [ 'billingAddressId', 'cardholderName', 'cvv', 'number', 'deviceSessionId', 'expirationDate', 'expirationMonth', 'expirationYear', 'token', 'venmoSdkPaymentMethodCode', 'deviceData', 'fraudMerchantId', 'paymentMethodNonce', ['options' => $options], [ 'billingAddress' => self::billingAddressSignature() ], ]; } public static function billingAddressSignature() { return [ 'firstName', 'lastName', 'company', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', 'countryName', 'extendedAddress', 'locality', 'region', 'postalCode', 'streetAddress' ]; } public static function createSignature() { $options = self::baseOptions(); $options[] = "failOnDuplicatePaymentMethod"; $signature = self::baseSignature($options); $signature[] = 'customerId'; return $signature; } public static function updateSignature() { $options = self::baseOptions(); $options[] = "failOnDuplicatePaymentMethod"; $signature = self::baseSignature($options); $updateExistingBillingSignature = [ [ 'options' => [ 'updateExisting' ] ] ]; foreach($signature AS $key => $value) { if(is_array($value) and array_key_exists('billingAddress', $value)) { $signature[$key]['billingAddress'] = array_merge_recursive($value['billingAddress'], $updateExistingBillingSignature); } } return $signature; } /** * sends the create request to the gateway * * @ignore * @param string $subPath * @param array $params * @return mixed */ public function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * verifies that a valid credit card identifier is being used * @ignore * @param string $identifier * @param Optional $string $identifierType type of identifier supplied, default "token" * @throws InvalidArgumentException */ private function _validateId($identifier = null, $identifierType = "token") { if (empty($identifier)) { throw new InvalidArgumentException( 'expected credit card id to be set' ); } if (!preg_match('/^[0-9A-Za-z_-]+$/', $identifier)) { throw new InvalidArgumentException( $identifier . ' is an invalid credit card ' . $identifierType . '.' ); } } /** * sends the update request to the gateway * * @ignore * @param string $url * @param array $params * @return mixed */ private function _doUpdate($httpVerb, $subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->$httpVerb($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * generic method for validating incoming gateway responses * * creates a new CreditCard object and encapsulates * it inside a Result\Successful object, or * encapsulates a Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['creditCard'])) { // return a populated instance of Address return new Result\Successful( CreditCard::factory($response['creditCard']) ); } elseif (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected address or apiErrorResponse" ); } } } class_alias('Braintree\CreditCardGateway', 'Braintree_CreditCardGateway'); lib/Braintree/MerchantGateway.php000064400000002463152101632460013026 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasClientCredentials(); $this->_http = new Http($gateway->config); $this->_http->useClientCredentials(); } public function create($attribs) { $response = $this->_http->post('/merchants/create_via_api', ['merchant' => $attribs]); return $this->_verifyGatewayResponse($response); } private function _verifyGatewayResponse($response) { if (isset($response['response']['merchant'])) { // return a populated instance of merchant return new Result\Successful([ Merchant::factory($response['response']['merchant']), OAuthCredentials::factory($response['response']['credentials']), ]); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected merchant or apiErrorResponse" ); } } } class_alias('Braintree\MerchantGateway', 'Braintree_MerchantGateway'); lib/Braintree/FacilitatorDetails.php000064400000001232152101632460013503 0ustar00_initialize($attributes); return $instance; } protected function _initialize($attributes) { $this->_attributes = $attributes; } /** * returns a string representation of the three d secure info * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } } class_alias('Braintree\FacilitatorDetails', 'Braintree_FacilitatorDetails'); lib/Braintree/Descriptor.php000064400000000177152101632460012061 0ustar00_initialize($attributes); return $instance; } // static methods redirecting to gateway public static function all() { return Configuration::gateway()->discount()->all(); } } class_alias('Braintree\Discount', 'Braintree_Discount'); lib/Braintree/WebhookTesting.php000064400000032420152101632460012673 0ustar00 $signature, 'bt_payload' => $payload ]; } private static function _sampleXml($kind, $id) { switch ($kind) { case WebhookNotification::SUB_MERCHANT_ACCOUNT_APPROVED: $subjectXml = self::_merchantAccountApprovedSampleXml($id); break; case WebhookNotification::SUB_MERCHANT_ACCOUNT_DECLINED: $subjectXml = self::_merchantAccountDeclinedSampleXml($id); break; case WebhookNotification::TRANSACTION_DISBURSED: $subjectXml = self::_transactionDisbursedSampleXml($id); break; case WebhookNotification::TRANSACTION_SETTLED: $subjectXml = self::_transactionSettledSampleXml($id); break; case WebhookNotification::TRANSACTION_SETTLEMENT_DECLINED: $subjectXml = self::_transactionSettlementDeclinedSampleXml($id); break; case WebhookNotification::DISBURSEMENT_EXCEPTION: $subjectXml = self::_disbursementExceptionSampleXml($id); break; case WebhookNotification::DISBURSEMENT: $subjectXml = self::_disbursementSampleXml($id); break; case WebhookNotification::PARTNER_MERCHANT_CONNECTED: $subjectXml = self::_partnerMerchantConnectedSampleXml($id); break; case WebhookNotification::PARTNER_MERCHANT_DISCONNECTED: $subjectXml = self::_partnerMerchantDisconnectedSampleXml($id); break; case WebhookNotification::PARTNER_MERCHANT_DECLINED: $subjectXml = self::_partnerMerchantDeclinedSampleXml($id); break; case WebhookNotification::DISPUTE_OPENED: $subjectXml = self::_disputeOpenedSampleXml($id); break; case WebhookNotification::DISPUTE_LOST: $subjectXml = self::_disputeLostSampleXml($id); break; case WebhookNotification::DISPUTE_WON: $subjectXml = self::_disputeWonSampleXml($id); break; case WebhookNotification::SUBSCRIPTION_CHARGED_SUCCESSFULLY: $subjectXml = self::_subscriptionChargedSuccessfullySampleXml($id); break; case WebhookNotification::CHECK: $subjectXml = self::_checkSampleXml(); break; case WebhookNotification::ACCOUNT_UPDATER_DAILY_REPORT: $subjectXml = self::_accountUpdaterDailyReportSampleXml($id); break; default: $subjectXml = self::_subscriptionSampleXml($id); break; } $timestamp = self::_timestamp(); return " {$timestamp} {$kind} {$subjectXml} "; } private static function _merchantAccountApprovedSampleXml($id) { return " {$id} master_ma_for_{$id} active active "; } private static function _merchantAccountDeclinedSampleXml($id) { return " Credit score is too low 82621 Credit score is too low base {$id} suspended master_ma_for_{$id} suspended "; } private static function _transactionDisbursedSampleXml($id) { return " ${id} 100 2013-07-09 "; } private static function _transactionSettledSampleXml($id) { return " ${id} settled sale USD 100.00 ogaotkivejpfayqfeaimuktty us_bank_account 123456789 1234 checking PayPal Checking - 1234 Dan Schulman "; } private static function _transactionSettlementDeclinedSampleXml($id) { return " ${id} settlement_declined sale USD 100.00 ogaotkivejpfayqfeaimuktty us_bank_account 123456789 1234 checking PayPal Checking - 1234 Dan Schulman "; } private static function _disbursementExceptionSampleXml($id) { return " ${id} asdfg qwert false false merchant_account_token USD false active 100.00 2014-02-10 bank_rejected update_funding_information "; } private static function _disbursementSampleXml($id) { return " ${id} asdfg qwert true false merchant_account_token USD false active 100.00 2014-02-10 "; } private static function _disputeOpenedSampleXml($id) { return " 250.00 USD 2014-03-01 2014-03-21 chargeback open fraud ${id} ${id} 250.00 2014-03-21 "; } private static function _disputeLostSampleXml($id) { return " 250.00 USD 2014-03-01 2014-03-21 chargeback lost fraud ${id} ${id} 250.00 2020-02-10 2014-03-21 "; } private static function _disputeWonSampleXml($id) { return " 250.00 USD 2014-03-01 2014-03-21 chargeback won fraud ${id} ${id} 250.00 2014-03-21 2014-03-22 "; } private static function _subscriptionSampleXml($id) { return " {$id} "; } private static function _subscriptionChargedSuccessfullySampleXml($id) { return " {$id} 2016-03-21 2017-03-31 submitted_for_settlement 49.99 "; } private static function _checkSampleXml() { return " true "; } private static function _partnerMerchantConnectedSampleXml($id) { return " public_id public_key private_key abc123 cse_key "; } private static function _partnerMerchantDisconnectedSampleXml($id) { return " abc123 "; } private static function _partnerMerchantDeclinedSampleXml($id) { return " abc123 "; } private static function _accountUpdaterDailyReportSampleXml($id) { return " 2016-01-14 link-to-csv-report "; } private static function _timestamp() { $originalZone = date_default_timezone_get(); date_default_timezone_set('UTC'); $timestamp = strftime('%Y-%m-%dT%TZ'); date_default_timezone_set($originalZone); return $timestamp; } } class_alias('Braintree\WebhookTesting', 'Braintree_WebhookTesting'); lib/Braintree/AndroidPayCard.php000064400000005101152101632460012557 0ustar00== More information == * * See {@link https://developers.braintreepayments.com/javascript+php}
* * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $bin * @property-read string $cardType * @property-read string $createdAt * @property-read string $customerId * @property-read string $default * @property-read string $expirationMonth * @property-read string $expirationYear * @property-read string $googleTransactionId * @property-read string $imageUrl * @property-read string $last4 * @property-read string $sourceCardLast4 * @property-read string $sourceCardType * @property-read string $sourceDescription * @property-read string $token * @property-read string $updatedAt * @property-read string $virtualCardLast4 * @property-read string $virtualCardType */ class AndroidPayCard extends Base { /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * factory method: returns an instance of AndroidPayCard * to the requesting method, with populated properties * * @ignore * @return AndroidPayCard */ public static function factory($attributes) { $defaultAttributes = [ 'expirationMonth' => '', 'expirationYear' => '', 'last4' => $attributes['virtualCardLast4'], 'cardType' => $attributes['virtualCardType'], ]; $instance = new self(); $instance->_initialize(array_merge($defaultAttributes, $attributes)); return $instance; } /** * sets instance properties from an array of values * * @access protected * @param array $androidPayCardAttribs array of Android Pay card properties * @return void */ protected function _initialize($androidPayCardAttribs) { // set the attributes $this->_attributes = $androidPayCardAttribs; $subscriptionArray = []; if (isset($androidPayCardAttribs['subscriptions'])) { foreach ($androidPayCardAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = Subscription::factory($subscription); } } $this->_set('subscriptions', $subscriptionArray); } } class_alias('Braintree\AndroidPayCard', 'Braintree_AndroidPayCard'); lib/Braintree/PartnerMerchant.php000064400000001707152101632460013040 0ustar00_initialize($attributes); return $instance; } /** * @ignore */ protected function _initialize($attributes) { $this->_attributes = $attributes; } } class_alias('Braintree\PartnerMerchant', 'Braintree_PartnerMerchant'); lib/Braintree/OAuthCredentials.php000064400000001443152101632460013136 0ustar00_attributes = $attribs; } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } /** * returns a string representation of the access token * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } } class_alias('Braintree\OAuthCredentials', 'Braintree_OAuthCredentials'); lib/Braintree/Version.php000064400000001214152101632460011361 0ustar00_attributes['cardType'] = $this->virtualCardType; $this->_attributes['last4'] = $this->virtualCardLast4; } } class_alias('Braintree\Transaction\AndroidPayCardDetails', 'Braintree_Transaction_AndroidPayCardDetails'); lib/Braintree/Transaction/AmexExpressCheckoutCardDetails.php000064400000002251152101632460020255 0ustar00_attributes['expirationDate'] = $this->expirationMonth . '/' . $this->expirationYear; $this->_attributes['maskedNumber'] = $this->bin . '******' . $this->last4; } } class_alias('Braintree\Transaction\CreditCardDetails', 'Braintree_Transaction_CreditCardDetails'); lib/Braintree/Transaction/UsBankAccountDetails.php000064400000001600152101632460016226 0ustar00Minimalistic example: * * Transaction::saleNoValidate(array( * 'amount' => '100.00', * 'creditCard' => array( * 'number' => '5105105105105100', * 'expirationDate' => '05/12', * ), * )); * * * Full example: * * Transaction::saleNoValidate(array( * 'amount' => '100.00', * 'orderId' => '123', * 'channel' => 'MyShoppingCardProvider', * 'creditCard' => array( * // if token is omitted, the gateway will generate a token * 'token' => 'credit_card_123', * 'number' => '5105105105105100', * 'expirationDate' => '05/2011', * 'cvv' => '123', * ), * 'customer' => array( * // if id is omitted, the gateway will generate an id * 'id' => 'customer_123', * 'firstName' => 'Dan', * 'lastName' => 'Smith', * 'company' => 'Braintree', * 'email' => 'dan@example.com', * 'phone' => '419-555-1234', * 'fax' => '419-555-1235', * 'website' => 'http://braintreepayments.com' * ), * 'billing' => array( * 'firstName' => 'Carl', * 'lastName' => 'Jones', * 'company' => 'Braintree', * 'streetAddress' => '123 E Main St', * 'extendedAddress' => 'Suite 403', * 'locality' => 'Chicago', * 'region' => 'IL', * 'postalCode' => '60622', * 'countryName' => 'United States of America' * ), * 'shipping' => array( * 'firstName' => 'Andrew', * 'lastName' => 'Mason', * 'company' => 'Braintree', * 'streetAddress' => '456 W Main St', * 'extendedAddress' => 'Apt 2F', * 'locality' => 'Bartlett', * 'region' => 'IL', * 'postalCode' => '60103', * 'countryName' => 'United States of America' * ), * 'customFields' => array( * 'birthdate' => '11/13/1954' * ) * ) * * * == Storing in the Vault == * * The customer and credit card information used for * a transaction can be stored in the vault by setting * transaction[options][storeInVault] to true. * * $transaction = Transaction::saleNoValidate(array( * 'customer' => array( * 'firstName' => 'Adam', * 'lastName' => 'Williams' * ), * 'creditCard' => array( * 'number' => '5105105105105100', * 'expirationDate' => '05/2012' * ), * 'options' => array( * 'storeInVault' => true * ) * )); * * echo $transaction->customerDetails->id * // '865534' * echo $transaction->creditCardDetails->token * // '6b6m' * * * To also store the billing address in the vault, pass the * addBillingAddressToPaymentMethod option. * * Transaction.saleNoValidate(array( * ... * 'options' => array( * 'storeInVault' => true * 'addBillingAddressToPaymentMethod' => true * ) * )); * * * == Submitting for Settlement== * * This can only be done when the transction's * status is authorized. If amount is not specified, * the full authorized amount will be settled. If you would like to settle * less than the full authorized amount, pass the desired amount. * You cannot settle more than the authorized amount. * * A transaction can be submitted for settlement when created by setting * $transaction[options][submitForSettlement] to true. * * * $transaction = Transaction::saleNoValidate(array( * 'amount' => '100.00', * 'creditCard' => array( * 'number' => '5105105105105100', * 'expirationDate' => '05/2012' * ), * 'options' => array( * 'submitForSettlement' => true * ) * )); * * * == More information == * * For more detailed information on Transactions, see {@link http://www.braintreepayments.com/gateway/transaction-api http://www.braintreepaymentsolutions.com/gateway/transaction-api} * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * * @property-read string $avsErrorResponseCode * @property-read string $avsPostalCodeResponseCode * @property-read string $avsStreetAddressResponseCode * @property-read string $cvvResponseCode * @property-read string $id transaction id * @property-read string $amount transaction amount * @property-read Braintree\Transaction\AddressDetails $billingDetails transaction billing address * @property-read string $createdAt transaction created timestamp * @property-read Braintree\ApplePayCardDetails $applePayCardDetails transaction Apple Pay card info * @property-read Braintree\AndroidPayCardDetails $androidPayCardDetails transaction Android Pay card info * @property-read Braintree\AmexExpressCheckoutCardDetails $amexExpressCheckoutCardDetails transaction Amex Express Checkout card info * @property-read Braintree\CreditCardDetails $creditCardDetails transaction credit card info * @property-read Braintree\CoinbaseDetails $coinbaseDetails transaction Coinbase account info * @property-read Braintree\PayPalDetails $paypalDetails transaction paypal account info * @property-read Braintree\Transaction\CustomerDetails $customerDetails transaction customer info * @property-read Braintree\VenmoAccount $venmoAccountDetails transaction Venmo Account info * @property-read array $customFields custom fields passed with the request * @property-read string $processorResponseCode gateway response code * @property-read string $additionalProcessorResponse raw response from processor * @property-read Braintree\Transaction\AddressDetails $shippingDetails transaction shipping address * @property-read string $status transaction status * @property-read array $statusHistory array of StatusDetails objects * @property-read string $type transaction type * @property-read string $updatedAt transaction updated timestamp * @property-read Braintree\Disbursement $disbursementDetails populated when transaction is disbursed * @property-read Braintree\Dispute $disputes populated when transaction is disputed * */ class Transaction extends Base { // Transaction Status const AUTHORIZATION_EXPIRED = 'authorization_expired'; const AUTHORIZING = 'authorizing'; const AUTHORIZED = 'authorized'; const GATEWAY_REJECTED = 'gateway_rejected'; const FAILED = 'failed'; const PROCESSOR_DECLINED = 'processor_declined'; const SETTLED = 'settled'; const SETTLING = 'settling'; const SUBMITTED_FOR_SETTLEMENT = 'submitted_for_settlement'; const VOIDED = 'voided'; const UNRECOGNIZED = 'unrecognized'; const SETTLEMENT_DECLINED = 'settlement_declined'; const SETTLEMENT_PENDING = 'settlement_pending'; const SETTLEMENT_CONFIRMED = 'settlement_confirmed'; // Transaction Escrow Status const ESCROW_HOLD_PENDING = 'hold_pending'; const ESCROW_HELD = 'held'; const ESCROW_RELEASE_PENDING = 'release_pending'; const ESCROW_RELEASED = 'released'; const ESCROW_REFUNDED = 'refunded'; // Transaction Types const SALE = 'sale'; const CREDIT = 'credit'; // Transaction Created Using const FULL_INFORMATION = 'full_information'; const TOKEN = 'token'; // Transaction Sources const API = 'api'; const CONTROL_PANEL = 'control_panel'; const RECURRING = 'recurring'; // Gateway Rejection Reason const AVS = 'avs'; const AVS_AND_CVV = 'avs_and_cvv'; const CVV = 'cvv'; const DUPLICATE = 'duplicate'; const FRAUD = 'fraud'; const THREE_D_SECURE = 'three_d_secure'; const APPLICATION_INCOMPLETE = 'application_incomplete'; // Industry Types const LODGING_INDUSTRY = 'lodging'; const TRAVEL_AND_CRUISE_INDUSTRY = 'travel_cruise'; /** * sets instance properties from an array of values * * @ignore * @access protected * @param array $transactionAttribs array of transaction data * @return void */ protected function _initialize($transactionAttribs) { $this->_attributes = $transactionAttribs; if (isset($transactionAttribs['applePay'])) { $this->_set('applePayCardDetails', new Transaction\ApplePayCardDetails( $transactionAttribs['applePay'] ) ); } if (isset($transactionAttribs['androidPayCard'])) { $this->_set('androidPayCardDetails', new Transaction\AndroidPayCardDetails( $transactionAttribs['androidPayCard'] ) ); } if (isset($transactionAttribs['amexExpressCheckoutCard'])) { $this->_set('amexExpressCheckoutCardDetails', new Transaction\AmexExpressCheckoutCardDetails( $transactionAttribs['amexExpressCheckoutCard'] ) ); } if (isset($transactionAttribs['venmoAccount'])) { $this->_set('venmoAccountDetails', new Transaction\VenmoAccountDetails( $transactionAttribs['venmoAccount'] ) ); } if (isset($transactionAttribs['creditCard'])) { $this->_set('creditCardDetails', new Transaction\CreditCardDetails( $transactionAttribs['creditCard'] ) ); } if (isset($transactionAttribs['coinbaseAccount'])) { $this->_set('coinbaseDetails', new Transaction\CoinbaseDetails( $transactionAttribs['coinbaseAccount'] ) ); } if (isset($transactionAttribs['europeBankAccount'])) { $this->_set('europeBankAccount', new Transaction\EuropeBankAccountDetails( $transactionAttribs['europeBankAccount'] ) ); } if (isset($transactionAttribs['usBankAccount'])) { $this->_set('usBankAccount', new Transaction\UsBankAccountDetails( $transactionAttribs['usBankAccount'] ) ); } if (isset($transactionAttribs['paypal'])) { $this->_set('paypalDetails', new Transaction\PayPalDetails( $transactionAttribs['paypal'] ) ); } if (isset($transactionAttribs['customer'])) { $this->_set('customerDetails', new Transaction\CustomerDetails( $transactionAttribs['customer'] ) ); } if (isset($transactionAttribs['billing'])) { $this->_set('billingDetails', new Transaction\AddressDetails( $transactionAttribs['billing'] ) ); } if (isset($transactionAttribs['shipping'])) { $this->_set('shippingDetails', new Transaction\AddressDetails( $transactionAttribs['shipping'] ) ); } if (isset($transactionAttribs['subscription'])) { $this->_set('subscriptionDetails', new Transaction\SubscriptionDetails( $transactionAttribs['subscription'] ) ); } if (isset($transactionAttribs['descriptor'])) { $this->_set('descriptor', new Descriptor( $transactionAttribs['descriptor'] ) ); } if (isset($transactionAttribs['disbursementDetails'])) { $this->_set('disbursementDetails', new DisbursementDetails($transactionAttribs['disbursementDetails']) ); } $disputes = []; if (isset($transactionAttribs['disputes'])) { foreach ($transactionAttribs['disputes'] AS $dispute) { $disputes[] = Dispute::factory($dispute); } } $this->_set('disputes', $disputes); $statusHistory = []; if (isset($transactionAttribs['statusHistory'])) { foreach ($transactionAttribs['statusHistory'] AS $history) { $statusHistory[] = new Transaction\StatusDetails($history); } } $this->_set('statusHistory', $statusHistory); $addOnArray = []; if (isset($transactionAttribs['addOns'])) { foreach ($transactionAttribs['addOns'] AS $addOn) { $addOnArray[] = AddOn::factory($addOn); } } $this->_set('addOns', $addOnArray); $discountArray = []; if (isset($transactionAttribs['discounts'])) { foreach ($transactionAttribs['discounts'] AS $discount) { $discountArray[] = Discount::factory($discount); } } $this->_set('discounts', $discountArray); if(isset($transactionAttribs['riskData'])) { $this->_set('riskData', RiskData::factory($transactionAttribs['riskData'])); } if(isset($transactionAttribs['threeDSecureInfo'])) { $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($transactionAttribs['threeDSecureInfo'])); } if(isset($transactionAttribs['facilitatorDetails'])) { $this->_set('facilitatorDetails', FacilitatorDetails::factory($transactionAttribs['facilitatorDetails'])); } } /** * returns a string representation of the transaction * @return string */ public function __toString() { // array of attributes to print $display = [ 'id', 'type', 'amount', 'status', 'createdAt', 'creditCardDetails', 'customerDetails' ]; $displayAttributes = []; foreach ($display AS $attrib) { $displayAttributes[$attrib] = $this->$attrib; } return __CLASS__ . '[' . Util::attributesToString($displayAttributes) .']'; } public function isEqual($otherTx) { return $this->id === $otherTx->id; } public function vaultCreditCard() { $token = $this->creditCardDetails->token; if (empty($token)) { return null; } else { return CreditCard::find($token); } } /** @return void|Braintree\Customer */ public function vaultCustomer() { $customerId = $this->customerDetails->id; if (empty($customerId)) { return null; } else { return Customer::find($customerId); } } /** @return bool */ public function isDisbursed() { return $this->disbursementDetails->isValid(); } /** * factory method: returns an instance of Transaction * to the requesting method, with populated properties * * @ignore * @return Transaction */ public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } // static methods redirecting to gateway public static function cloneTransaction($transactionId, $attribs) { return Configuration::gateway()->transaction()->cloneTransaction($transactionId, $attribs); } public static function createFromTransparentRedirect($queryString) { return Configuration::gateway()->transaction()->createFromTransparentRedirect($queryString); } public static function createTransactionUrl() { return Configuration::gateway()->transaction()->createTransactionUrl(); } public static function credit($attribs) { return Configuration::gateway()->transaction()->credit($attribs); } public static function creditNoValidate($attribs) { return Configuration::gateway()->transaction()->creditNoValidate($attribs); } public static function find($id) { return Configuration::gateway()->transaction()->find($id); } public static function sale($attribs) { return Configuration::gateway()->transaction()->sale($attribs); } public static function saleNoValidate($attribs) { return Configuration::gateway()->transaction()->saleNoValidate($attribs); } public static function search($query) { return Configuration::gateway()->transaction()->search($query); } public static function fetch($query, $ids) { return Configuration::gateway()->transaction()->fetch($query, $ids); } public static function void($transactionId) { return Configuration::gateway()->transaction()->void($transactionId); } public static function voidNoValidate($transactionId) { return Configuration::gateway()->transaction()->voidNoValidate($transactionId); } public static function submitForSettlement($transactionId, $amount = null, $attribs = []) { return Configuration::gateway()->transaction()->submitForSettlement($transactionId, $amount, $attribs); } public static function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = []) { return Configuration::gateway()->transaction()->submitForSettlementNoValidate($transactionId, $amount, $attribs); } public static function updateDetails($transactionId, $attribs = []) { return Configuration::gateway()->transaction()->updateDetails($transactionId, $attribs); } public static function submitForPartialSettlement($transactionId, $amount, $attribs = []) { return Configuration::gateway()->transaction()->submitForPartialSettlement($transactionId, $amount, $attribs); } public static function holdInEscrow($transactionId) { return Configuration::gateway()->transaction()->holdInEscrow($transactionId); } public static function releaseFromEscrow($transactionId) { return Configuration::gateway()->transaction()->releaseFromEscrow($transactionId); } public static function cancelRelease($transactionId) { return Configuration::gateway()->transaction()->cancelRelease($transactionId); } public static function refund($transactionId, $amount = null) { return Configuration::gateway()->transaction()->refund($transactionId, $amount); } } class_alias('Braintree\Transaction', 'Braintree_Transaction'); lib/Braintree/WebhookNotification.php000064400000012516152101632460013710 0ustar00_initialize($attributes); return $instance; } private static function _matchingSignature($signaturePairs) { foreach ($signaturePairs as $pair) { $components = preg_split("/\|/", $pair); if ($components[0] == Configuration::publicKey()) { return $components[1]; } } return null; } private static function _payloadMatches($signature, $payload) { $payloadSignature = Digest::hexDigestSha1(Configuration::privateKey(), $payload); return Digest::secureCompare($signature, $payloadSignature); } private static function _validateSignature($signatureString, $payload) { $signaturePairs = preg_split("/&/", $signatureString); $signature = self::_matchingSignature($signaturePairs); if (!$signature) { throw new Exception\InvalidSignature("no matching public key"); } if (!(self::_payloadMatches($signature, $payload) || self::_payloadMatches($signature, $payload . "\n"))) { throw new Exception\InvalidSignature("signature does not match payload - one has been modified"); } } 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', Subscription::factory($attributes['subject']['subscription'])); } if (isset($wrapperNode['merchantAccount'])) { $this->_set('merchantAccount', MerchantAccount::factory($wrapperNode['merchantAccount'])); } if (isset($wrapperNode['transaction'])) { $this->_set('transaction', Transaction::factory($wrapperNode['transaction'])); } if (isset($wrapperNode['disbursement'])) { $this->_set('disbursement', Disbursement::factory($wrapperNode['disbursement'])); } if (isset($wrapperNode['partnerMerchant'])) { $this->_set('partnerMerchant', PartnerMerchant::factory($wrapperNode['partnerMerchant'])); } if (isset($wrapperNode['dispute'])) { $this->_set('dispute', Dispute::factory($wrapperNode['dispute'])); } if (isset($wrapperNode['accountUpdaterDailyReport'])) { $this->_set('accountUpdaterDailyReport', AccountUpdaterDailyReport::factory($wrapperNode['accountUpdaterDailyReport'])); } if (isset($wrapperNode['errors'])) { $this->_set('errors', new Error\ValidationErrorCollection($wrapperNode['errors'])); $this->_set('message', $wrapperNode['message']); } } } class_alias('Braintree\WebhookNotification', 'Braintree_WebhookNotification'); lib/Braintree/Instance.php000064400000003514152101632460011505 0ustar00_initializeFromArray($attributes); } } /** * returns private/nonexistent instance properties * @access public * @param string $name property name * @return mixed contents of instance properties */ public function __get($name) { if (array_key_exists($name, $this->_attributes)) { return $this->_attributes[$name]; } else { trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE); return null; } } /** * used by isset() and empty() * @access public * @param string $name property name * @return boolean */ public function __isset($name) { return array_key_exists($name, $this->_attributes); } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @return string */ public function __toString() { $objOutput = Util::implodeAssociativeArray($this->_attributes); return get_class($this) .'[' . $objOutput . ']'; } /** * initializes instance properties from the keys/values of an array * @ignore * @access protected * @param $aAttribs array of properties to set - single level * @return void */ private function _initializeFromArray($attributes) { $this->_attributes = $attributes; } } class_alias('Braintree\Instance', 'Braintree_Instance'); lib/Braintree/ApplePayCard.php000064400000005307152101632460012250 0ustar00== More information == * * See {@link https://developers.braintreepayments.com/javascript+php}
* * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $cardType * @property-read string $createdAt * @property-read string $customerId * @property-read string $expirationDate * @property-read string $expirationMonth * @property-read string $expirationYear * @property-read string $imageUrl * @property-read string $last4 * @property-read string $token * @property-read string $paymentInstrumentName * @property-read string $sourceDescription * @property-read string $updatedAt */ class ApplePayCard extends Base { // Card Type const AMEX = 'Apple Pay - American Express'; const MASTER_CARD = 'Apple Pay - MasterCard'; const VISA = 'Apple Pay - Visa'; /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * checks whether the card is expired based on the current date * * @return boolean */ public function isExpired() { return $this->expired; } /** * factory method: returns an instance of ApplePayCard * to the requesting method, with populated properties * * @ignore * @return ApplePayCard */ public static function factory($attributes) { $defaultAttributes = [ 'expirationMonth' => '', 'expirationYear' => '', 'last4' => '', ]; $instance = new self(); $instance->_initialize(array_merge($defaultAttributes, $attributes)); return $instance; } /** * sets instance properties from an array of values * * @access protected * @param array $applePayCardAttribs array of Apple Pay card properties * @return void */ protected function _initialize($applePayCardAttribs) { // set the attributes $this->_attributes = $applePayCardAttribs; $subscriptionArray = []; if (isset($applePayCardAttribs['subscriptions'])) { foreach ($applePayCardAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = Subscription::factory($subscription); } } $this->_set('subscriptions', $subscriptionArray); $this->_set('expirationDate', $this->expirationMonth . '/' . $this->expirationYear); } } class_alias('Braintree\ApplePayCard', 'Braintree_ApplePayCard'); lib/Braintree/IsNode.php000064400000000627152101632460011124 0ustar00name = $name; $this->searchTerms = []; } public function is($value) { $this->searchTerms['is'] = strval($value); return $this; } public function toParam() { return $this->searchTerms; } } class_alias('Braintree\IsNode', 'Braintree_IsNode'); lib/Braintree/ClientTokenGateway.php000064400000006402152101632460013501 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function generate($params=[]) { if (!array_key_exists("version", $params)) { $params["version"] = ClientToken::DEFAULT_VERSION; } $this->conditionallyVerifyKeys($params); $generateParams = ["client_token" => $params]; return $this->_doGenerate('/client_token', $generateParams); } /** * sends the generate request to the gateway * * @ignore * @param var $url * @param array $params * @return mixed */ public function _doGenerate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * * @param array $params * @throws InvalidArgumentException */ public function conditionallyVerifyKeys($params) { if (array_key_exists("customerId", $params)) { Util::verifyKeys($this->generateWithCustomerIdSignature(), $params); } else { Util::verifyKeys($this->generateWithoutCustomerIdSignature(), $params); } } /** * * @return mixed[] */ public function generateWithCustomerIdSignature() { return [ "version", "customerId", "proxyMerchantId", ["options" => ["makeDefault", "verifyCard", "failOnDuplicatePaymentMethod"]], "merchantAccountId", "sepaMandateType", "sepaMandateAcceptanceLocation"]; } /** * * @return string[] */ public function generateWithoutCustomerIdSignature() { return ["version", "proxyMerchantId", "merchantAccountId"]; } /** * generic method for validating incoming gateway responses * * If the request is successful, returns a client token string. * Otherwise, throws an InvalidArgumentException with the error * response from the Gateway or an HTTP status code exception. * * @ignore * @param array $response gateway response values * @return string client token * @throws InvalidArgumentException | HTTP status code exception */ private function _verifyGatewayResponse($response) { if (isset($response['clientToken'])) { return $response['clientToken']['value']; } elseif (isset($response['apiErrorResponse'])) { throw new InvalidArgumentException( $response['apiErrorResponse']['message'] ); } else { throw new Exception\Unexpected( "Expected clientToken or apiErrorResponse" ); } } } class_alias('Braintree\ClientTokenGateway', 'Braintree_ClientTokenGateway'); lib/Braintree/CreditCard.php000064400000022661152101632460011751 0ustar00== More information == * * For more detailed information on CreditCards, see {@link http://www.braintreepayments.com/gateway/credit-card-api http://www.braintreepaymentsolutions.com/gateway/credit-card-api}
* For more detailed information on CreditCard verifications, see {@link http://www.braintreepayments.com/gateway/credit-card-verification-api http://www.braintreepaymentsolutions.com/gateway/credit-card-verification-api} * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $billingAddress * @property-read string $bin * @property-read string $cardType * @property-read string $cardholderName * @property-read string $createdAt * @property-read string $customerId * @property-read string $expirationDate * @property-read string $expirationMonth * @property-read string $expirationYear * @property-read string $imageUrl * @property-read string $last4 * @property-read string $maskedNumber * @property-read string $token * @property-read string $updatedAt */ class CreditCard extends Base { // Card Type const AMEX = 'American Express'; const CARTE_BLANCHE = 'Carte Blanche'; const CHINA_UNION_PAY = 'China UnionPay'; const DINERS_CLUB_INTERNATIONAL = 'Diners Club'; const DISCOVER = 'Discover'; const JCB = 'JCB'; const LASER = 'Laser'; const MAESTRO = 'Maestro'; const MASTER_CARD = 'MasterCard'; const SOLO = 'Solo'; const SWITCH_TYPE = 'Switch'; const VISA = 'Visa'; const UNKNOWN = 'Unknown'; // Credit card origination location const INTERNATIONAL = "international"; const US = "us"; const PREPAID_YES = 'Yes'; const PREPAID_NO = 'No'; const PREPAID_UNKNOWN = 'Unknown'; const PAYROLL_YES = 'Yes'; const PAYROLL_NO = 'No'; const PAYROLL_UNKNOWN = 'Unknown'; const HEALTHCARE_YES = 'Yes'; const HEALTHCARE_NO = 'No'; const HEALTHCARE_UNKNOWN = 'Unknown'; const DURBIN_REGULATED_YES = 'Yes'; const DURBIN_REGULATED_NO = 'No'; const DURBIN_REGULATED_UNKNOWN = 'Unknown'; const DEBIT_YES = 'Yes'; const DEBIT_NO = 'No'; const DEBIT_UNKNOWN = 'Unknown'; const COMMERCIAL_YES = 'Yes'; const COMMERCIAL_NO = 'No'; const COMMERCIAL_UNKNOWN = 'Unknown'; const COUNTRY_OF_ISSUANCE_UNKNOWN = "Unknown"; const ISSUING_BANK_UNKNOWN = "Unknown"; const PRODUCT_ID_UNKNOWN = "Unknown"; /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * checks whether the card is expired based on the current date * * @return boolean */ public function isExpired() { return $this->expired; } /** * checks whether the card is associated with venmo sdk * * @return boolean */ public function isVenmoSdk() { return $this->venmoSdk; } /** * sets instance properties from an array of values * * @access protected * @param array $creditCardAttribs array of creditcard data * @return void */ protected function _initialize($creditCardAttribs) { // set the attributes $this->_attributes = $creditCardAttribs; // map each address into its own object $billingAddress = isset($creditCardAttribs['billingAddress']) ? Address::factory($creditCardAttribs['billingAddress']) : null; $subscriptionArray = []; if (isset($creditCardAttribs['subscriptions'])) { foreach ($creditCardAttribs['subscriptions'] AS $subscription) { $subscriptionArray[] = 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); if(isset($creditCardAttribs['verifications']) && count($creditCardAttribs['verifications']) > 0) { $verifications = $creditCardAttribs['verifications']; usort($verifications, [$this, '_compareCreatedAtOnVerifications']); $this->_set('verification', CreditCardVerification::factory($verifications[0])); } } private function _compareCreatedAtOnVerifications($verificationAttrib1, $verificationAttrib2) { return ($verificationAttrib2['createdAt'] < $verificationAttrib1['createdAt']) ? -1 : 1; } /** * returns false if comparing object is not a CreditCard, * or is a CreditCard with a different id * * @param object $otherCreditCard customer to compare against * @return boolean */ public function isEqual($otherCreditCard) { return !($otherCreditCard instanceof self) ? false : $this->token === $otherCreditCard->token; } /** * create a printable representation of the object as: * ClassName[property=value, property=value] * @return string */ public function __toString() { return __CLASS__ . '[' . Util::attributesToString($this->_attributes) .']'; } /** * factory method: returns an instance of CreditCard * to the requesting method, with populated properties * * @ignore * @return CreditCard */ public static function factory($attributes) { $defaultAttributes = [ 'bin' => '', 'expirationMonth' => '', 'expirationYear' => '', 'last4' => '', ]; $instance = new self(); $instance->_initialize(array_merge($defaultAttributes, $attributes)); return $instance; } // static methods redirecting to gateway public static function create($attribs) { return Configuration::gateway()->creditCard()->create($attribs); } public static function createNoValidate($attribs) { return Configuration::gateway()->creditCard()->createNoValidate($attribs); } public static function createFromTransparentRedirect($queryString) { return Configuration::gateway()->creditCard()->createFromTransparentRedirect($queryString); } public static function createCreditCardUrl() { return Configuration::gateway()->creditCard()->createCreditCardUrl(); } public static function expired() { return Configuration::gateway()->creditCard()->expired(); } public static function fetchExpired($ids) { return Configuration::gateway()->creditCard()->fetchExpired($ids); } public static function expiringBetween($startDate, $endDate) { return Configuration::gateway()->creditCard()->expiringBetween($startDate, $endDate); } public static function fetchExpiring($startDate, $endDate, $ids) { return Configuration::gateway()->creditCard()->fetchExpiring($startDate, $endDate, $ids); } public static function find($token) { return Configuration::gateway()->creditCard()->find($token); } public static function fromNonce($nonce) { return Configuration::gateway()->creditCard()->fromNonce($nonce); } public static function credit($token, $transactionAttribs) { return Configuration::gateway()->creditCard()->credit($token, $transactionAttribs); } public static function creditNoValidate($token, $transactionAttribs) { return Configuration::gateway()->creditCard()->creditNoValidate($token, $transactionAttribs); } public static function sale($token, $transactionAttribs) { return Configuration::gateway()->creditCard()->sale($token, $transactionAttribs); } public static function saleNoValidate($token, $transactionAttribs) { return Configuration::gateway()->creditCard()->saleNoValidate($token, $transactionAttribs); } public static function update($token, $attributes) { return Configuration::gateway()->creditCard()->update($token, $attributes); } public static function updateNoValidate($token, $attributes) { return Configuration::gateway()->creditCard()->updateNoValidate($token, $attributes); } public static function updateCreditCardUrl() { return Configuration::gateway()->creditCard()->updateCreditCardUrl(); } public static function updateFromTransparentRedirect($queryString) { return Configuration::gateway()->creditCard()->updateFromTransparentRedirect($queryString); } public static function delete($token) { return Configuration::gateway()->creditCard()->delete($token); } /** @return array */ public static function allCardTypes() { return [ CreditCard::AMEX, CreditCard::CARTE_BLANCHE, CreditCard::CHINA_UNION_PAY, CreditCard::DINERS_CLUB_INTERNATIONAL, CreditCard::DISCOVER, CreditCard::JCB, CreditCard::LASER, CreditCard::MAESTRO, CreditCard::MASTER_CARD, CreditCard::SOLO, CreditCard::SWITCH_TYPE, CreditCard::VISA, CreditCard::UNKNOWN ]; } } class_alias('Braintree\CreditCard', 'Braintree_CreditCard'); lib/Braintree/EuropeBankAccount.php000064400000003327152101632460013313 0ustar00== More information == * * See {@link https://developers.braintreepayments.com/javascript+php}
* * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $account-holder-name * @property-read string $bic * @property-read string $customerId * @property-read string $default * @property-read string $image-url * @property-read string $mandate-reference-number * @property-read string $masked-iban * @property-read string $token */ class EuropeBankAccount extends Base { /* instance methods */ /** * returns false if default is null or false * * @return boolean */ public function isDefault() { return $this->default; } /** * factory method: returns an instance of EuropeBankAccount * to the requesting method, with populated properties * * @ignore * @return EuropeBankAccount */ public static function factory($attributes) { $defaultAttributes = [ ]; $instance = new self(); $instance->_initialize(array_merge($defaultAttributes, $attributes)); return $instance; } /** * sets instance properties from an array of values * * @access protected * @param array $europeBankAccountAttribs array of EuropeBankAccount properties * @return void */ protected function _initialize($europeBankAccountAttribs) { $this->_attributes = $europeBankAccountAttribs; } } class_alias('Braintree\EuropeBankAccount', 'Braintree_EuropeBankAccount'); lib/Braintree/ClientToken.php000064400000002174152101632460012161 0ustar00clientToken()->generate($params); } /** * * @param type $params * @throws InvalidArgumentException */ public static function conditionallyVerifyKeys($params) { return Configuration::gateway()->clientToken()->conditionallyVerifyKeys($params); } /** * * @return string client token retrieved from server */ public static function generateWithCustomerIdSignature() { return Configuration::gateway()->clientToken()->generateWithCustomerIdSignature(); } /** * * @return string client token retrieved from server */ public static function generateWithoutCustomerIdSignature() { return Configuration::gateway()->clientToken()->generateWithoutCustomerIdSignature(); } } class_alias('Braintree\ClientToken', 'Braintree_ClientToken'); lib/Braintree/MultipleValueNode.php000064400000001611152101632460013333 0ustar00name = $name; $this->items = []; $this->allowedValues = $allowedValues; } public function in($values) { $bad_values = array_diff($values, $this->allowedValues); if (count($this->allowedValues) > 0 && count($bad_values) > 0) { $message = 'Invalid argument(s) for ' . $this->name . ':'; foreach ($bad_values AS $bad_value) { $message .= ' ' . $bad_value; } throw new InvalidArgumentException($message); } $this->items = $values; return $this; } public function is($value) { return $this->in([$value]); } public function toParam() { return $this->items; } } class_alias('Braintree\MultipleValueNode', 'Braintree_MultipleValueNode'); lib/Braintree/PaymentMethod.php000064400000002064152101632460012516 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * */ class PaymentMethod extends Base { // static methods redirecting to gateway public static function create($attribs) { return Configuration::gateway()->paymentMethod()->create($attribs); } public static function find($token) { return Configuration::gateway()->paymentMethod()->find($token); } public static function update($token, $attribs) { return Configuration::gateway()->paymentMethod()->update($token, $attribs); } public static function delete($token) { return Configuration::gateway()->paymentMethod()->delete($token); } } class_alias('Braintree\PaymentMethod', 'Braintree_PaymentMethod'); lib/Braintree/TestingGateway.php000064400000002642152101632460012701 0ustar00_gateway = $gateway; $this->_config = $gateway->config; $this->_http = new Http($this->_config); } public function settle($transactionId) { return self::_doTestRequest('/settle', $transactionId); } public function settlementPending($transactionId) { return self::_doTestRequest('/settlement_pending', $transactionId); } public function settlementConfirm($transactionId) { return self::_doTestRequest('/settlement_confirm', $transactionId); } public function settlementDecline($transactionId) { return self::_doTestRequest('/settlement_decline', $transactionId); } private function _doTestRequest($testPath, $transactionId) { self::_checkEnvironment(); $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . $testPath; $response = $this->_http->put($path); return Transaction::factory($response['transaction']); } private function _checkEnvironment() { if (Configuration::$global->getEnvironment() === 'production') { throw new Exception\TestOperationPerformedInProduction(); } } } class_alias('Braintree\TestingGateway', 'Braintree_TestingGateway'); lib/Braintree/Base.php000064400000003163152101632460010613 0ustar00_attributes)) { return $this->_attributes[$name]; } else { trigger_error('Undefined property on ' . get_class($this) . ': ' . $name, E_USER_NOTICE); return null; } } /** * Checks for the existance of a property stored in the private $_attributes property * * @ignore * @param string $name * @return boolean */ public function __isset($name) { return array_key_exists($name, $this->_attributes); } /** * Mutator for instance properties stored in the private $_attributes property * * @ignore * @param string $key * @param mixed $value */ public function _set($key, $value) { $this->_attributes[$key] = $value; } } lib/Braintree/Exception.php000064400000000441152101632460011673 0ustar00config = $config; } /** * * @return AddOnGateway */ public function addOn() { return new AddOnGateway($this); } /** * * @return AddressGateway */ public function address() { return new AddressGateway($this); } /** * * @return ClientTokenGateway */ public function clientToken() { return new ClientTokenGateway($this); } /** * * @return CreditCardGateway */ public function creditCard() { return new CreditCardGateway($this); } /** * * @return CreditCardVerificationGateway */ public function creditCardVerification() { return new CreditCardVerificationGateway($this); } /** * * @return CustomerGateway */ public function customer() { return new CustomerGateway($this); } /** * * @return DiscountGateway */ public function discount() { return new DiscountGateway($this); } /** * * @return MerchantGateway */ public function merchant() { return new MerchantGateway($this); } /** * * @return MerchantAccountGateway */ public function merchantAccount() { return new MerchantAccountGateway($this); } /** * * @return OAuthGateway */ public function oauth() { return new OAuthGateway($this); } /** * * @return PaymentMethodGateway */ public function paymentMethod() { return new PaymentMethodGateway($this); } /** * * @return PaymentMethodNonceGateway */ public function paymentMethodNonce() { return new PaymentMethodNonceGateway($this); } /** * * @return PayPalAccountGateway */ public function payPalAccount() { return new PayPalAccountGateway($this); } /** * * @return PlanGateway */ public function plan() { return new PlanGateway($this); } /** * * @return SettlementBatchSummaryGateway */ public function settlementBatchSummary() { return new SettlementBatchSummaryGateway($this); } /** * * @return SubscriptionGateway */ public function subscription() { return new SubscriptionGateway($this); } /** * * @return TestingGateway */ public function testing() { return new TestingGateway($this); } /** * * @return TransactionGateway */ public function transaction() { return new TransactionGateway($this); } /** * * @return TransparentRedirectGateway */ public function transparentRedirect() { return new TransparentRedirectGateway($this); } /** * * @return UsBankAccountGateway */ public function usBankAccount() { return new UsBankAccountGateway($this); } } class_alias('Braintree\Gateway', 'Braintree_Gateway'); lib/Braintree/PartialMatchNode.php000064400000000634152101632460013120 0ustar00searchTerms["starts_with"] = strval($value); return $this; } public function endsWith($value) { $this->searchTerms["ends_with"] = strval($value); return $this; } } class_alias('Braintree\PartialMatchNode', 'Braintree_PartialMatchNode'); lib/Braintree/CredentialsParser.php000064400000010301152101632460013343 0ustar00 $value) { if ($kind == 'clientId') { $this->_clientId = $value; } if ($kind == 'clientSecret') { $this->_clientSecret = $value; } if ($kind == 'accessToken') { $this->_accessToken = $value; } } $this->parse(); } /** * * @access protected * @static * @var array valid environments, used for validation */ private static $_validEnvironments = [ 'development', 'integration', 'sandbox', 'production', 'qa', ]; public function parse() { $environments = []; if (!empty($this->_clientId)) { $environments[] = ['clientId', $this->_parseClientCredential('clientId', $this->_clientId, 'client_id')]; } if (!empty($this->_clientSecret)) { $environments[] = ['clientSecret', $this->_parseClientCredential('clientSecret', $this->_clientSecret, 'client_secret')]; } if (!empty($this->_accessToken)) { $environments[] = ['accessToken', $this->_parseAccessToken()]; } $checkEnv = $environments[0]; foreach ($environments as $env) { if ($env[1] !== $checkEnv[1]) { throw new Exception\Configuration( 'Mismatched credential environments: ' . $checkEnv[0] . ' environment is ' . $checkEnv[1] . ' and ' . $env[0] . ' environment is ' . $env[1]); } } self::assertValidEnvironment($checkEnv[1]); $this->_environment = $checkEnv[1]; } public static function assertValidEnvironment($environment) { if (!in_array($environment, self::$_validEnvironments)) { throw new Exception\Configuration('"' . $environment . '" is not a valid environment.'); } } private function _parseClientCredential($credentialType, $value, $expectedValuePrefix) { $explodedCredential = explode('$', $value); if (sizeof($explodedCredential) != 3) { throw new Exception\Configuration('Incorrect ' . $credentialType . ' format. Expected: type$environment$token'); } $gotValuePrefix = $explodedCredential[0]; $environment = $explodedCredential[1]; $token = $explodedCredential[2]; if ($gotValuePrefix != $expectedValuePrefix) { throw new Exception\Configuration('Value passed for ' . $credentialType . ' is not a ' . $credentialType); } return $environment; } private function _parseAccessToken() { $accessTokenExploded = explode('$', $this->_accessToken); if (sizeof($accessTokenExploded) != 4) { throw new Exception\Configuration('Incorrect accessToken syntax. Expected: type$environment$merchant_id$token'); } $gotValuePrefix = $accessTokenExploded[0]; $environment = $accessTokenExploded[1]; $merchantId = $accessTokenExploded[2]; $token = $accessTokenExploded[3]; if ($gotValuePrefix != 'access_token') { throw new Exception\Configuration('Value passed for accessToken is not an accessToken'); } $this->_merchantId = $merchantId; return $environment; } public function getClientId() { return $this->_clientId; } public function getClientSecret() { return $this->_clientSecret; } public function getAccessToken() { return $this->_accessToken; } public function getEnvironment() { return $this->_environment; } public function getMerchantId() { return $this->_merchantId; } } class_alias('Braintree\CredentialsParser', 'Braintree_CredentialsParser'); lib/Braintree/Error/ErrorCollection.php000064400000005654152101632460014146 0ustar00_errors = new ValidationErrorCollection($errorData); } /** * Return count of items in collection * Implements countable * * @return integer */ public function count() { return $this->deepSize(); } /** * Returns all of the validation errors at all levels of nesting in a single, flat array. */ public function deepAll() { return $this->_errors->deepAll(); } /** * Returns the total number of validation errors at all levels of nesting. For example, *if creating a customer with a credit card and a billing address, and each of the customer, * credit card, and billing address has 1 error, this method will return 3. * * @return int size */ public function deepSize() { $size = $this->_errors->deepSize(); return $size; } /** * return errors for the passed key name * * @param string $key * @return mixed */ public function forKey($key) { return $this->_errors->forKey($key); } /** * return errors for the passed html field. * For example, $result->errors->onHtmlField("transaction[customer][last_name]") * * @param string $field * @return array */ public function onHtmlField($field) { $pieces = preg_split("/[\[\]]+/", $field, 0, PREG_SPLIT_NO_EMPTY); $errors = $this; foreach(array_slice($pieces, 0, -1) as $key) { $errors = $errors->forKey(Util::delimiterToCamelCase($key)); if (!isset($errors)) { return []; } } $finalKey = Util::delimiterToCamelCase(end($pieces)); return $errors->onAttribute($finalKey); } /** * Returns the errors at the given nesting level (see forKey) in a single, flat array: * * * $result = Customer::create(...); * $customerErrors = $result->errors->forKey('customer')->shallowAll(); * */ public function shallowAll() { return $this->_errors->shallowAll(); } /** * * @ignore */ public function __get($name) { $varName = "_$name"; return isset($this->$varName) ? $this->$varName : null; } /** * * @ignore */ public function __toString() { return sprintf('%s', $this->_errors); } } class_alias('Braintree\Error\ErrorCollection', 'Braintree_Error_ErrorCollection'); lib/Braintree/Error/Codes.php000064400000124544152101632460012076 0ustar00== More information == * * For more detailed information on Validation errors, see {@link http://www.braintreepayments.com/gateway/validation-errors http://www.braintreepaymentsolutions.com/gateway/validation-errors} * * @package Braintree * @subpackage Error * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read array $errors * @property-read array $nested */ class ValidationErrorCollection extends Collection { private $_errors = []; private $_nested = []; /** * @ignore */ public function __construct($data) { foreach($data AS $key => $errorData) // map errors to new collections recursively if ($key == 'errors') { foreach ($errorData AS $error) { $this->_errors[] = new Validation($error); } } else { $this->_nested[$key] = new ValidationErrorCollection($errorData); } } public function deepAll() { $validationErrors = array_merge([], $this->_errors); foreach($this->_nested as $nestedErrors) { $validationErrors = array_merge($validationErrors, $nestedErrors->deepAll()); } return $validationErrors; } public function deepSize() { $total = sizeof($this->_errors); foreach($this->_nested as $_nestedErrors) { $total = $total + $_nestedErrors->deepSize(); } return $total; } public function forIndex($index) { return $this->forKey("index" . $index); } public function forKey($key) { return isset($this->_nested[$key]) ? $this->_nested[$key] : null; } public function onAttribute($attribute) { $matches = []; foreach ($this->_errors AS $key => $error) { if($error->attribute == $attribute) { $matches[] = $error; } } return $matches; } public function shallowAll() { return $this->_errors; } /** * * @ignore */ public function __get($name) { $varName = "_$name"; return isset($this->$varName) ? $this->$varName : null; } /** * @ignore */ public function __toString() { $output = []; // TODO: implement scope if (!empty($this->_errors)) { $output[] = $this->_inspect($this->_errors); } if (!empty($this->_nested)) { foreach ($this->_nested AS $key => $values) { $output[] = $this->_inspect($this->_nested); } } return join(', ', $output); } /** * @ignore */ private function _inspect($errors, $scope = null) { $eOutput = '[' . __CLASS__ . '/errors:['; foreach($errors AS $error => $errorObj) { $outputErrs[] = "({$errorObj->error['code']} {$errorObj->error['message']})"; } $eOutput .= join(', ', $outputErrs) . ']]'; return $eOutput; } } class_alias('Braintree\Error\ValidationErrorCollection', 'Braintree_Error_ValidationErrorCollection'); lib/Braintree/Error/Validation.php000064400000003101152101632460013114 0ustar00== More information == * * For more detailed information on Validation errors, see {@link http://www.braintreepayments.com/gateway/validation-errors http://www.braintreepaymentsolutions.com/gateway/validation-errors} * * @package Braintree * @subpackage Error * @copyright 2015 Braintree, a division of PayPal, Inc. * * @property-read string $attribute * @property-read string $code * @property-read string $message */ class Validation { private $_attribute; private $_code; private $_message; /** * @ignore * @param array $attributes */ public function __construct($attributes) { $this->_initializeFromArray($attributes); } /** * initializes instance properties from the keys/values of an array * @ignore * @access protected * @param array $attributes array of properties to set - single level * @return void */ private function _initializeFromArray($attributes) { foreach($attributes AS $name => $value) { $varName = "_$name"; $this->$varName = Util::delimiterToCamelCase($value, '_'); } } /** * * @ignore */ public function __get($name) { $varName = "_$name"; return isset($this->$varName) ? $this->$varName : null; } } class_alias('Braintree\Error\Validation', 'Braintree_Error_Validation'); lib/Braintree/EqualityNode.php000064400000000367152101632460012347 0ustar00searchTerms['is_not'] = strval($value); return $this; } } class_alias('Braintree\EqualityNode', 'Braintree_EqualityNode'); lib/Braintree/Dispute/TransactionDetails.php000064400000001050152101632460015142 0ustar00== More information == * * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. * */ class PaymentMethodNonce extends Base { // static methods redirecting to gateway public static function create($token) { return Configuration::gateway()->paymentMethodNonce()->create($token); } public static function find($nonce) { return Configuration::gateway()->paymentMethodNonce()->find($nonce); } public static function factory($attributes) { $instance = new self(); $instance->_initialize($attributes); return $instance; } protected function _initialize($nonceAttributes) { $this->_attributes = $nonceAttributes; $this->_set('nonce', $nonceAttributes['nonce']); $this->_set('type', $nonceAttributes['type']); if(isset($nonceAttributes['threeDSecureInfo'])) { $this->_set('threeDSecureInfo', ThreeDSecureInfo::factory($nonceAttributes['threeDSecureInfo'])); } } } class_alias('Braintree\PaymentMethodNonce', 'Braintree_PaymentMethodNonce'); lib/Braintree/TransactionGateway.php000064400000041711152101632460013551 0ustar00== More information == * * For more detailed information on Transactions, see {@link http://www.braintreepayments.com/gateway/transaction-api http://www.braintreepaymentsolutions.com/gateway/transaction-api} * * @package Braintree * @category Resources * @copyright 2015 Braintree, a division of PayPal, Inc. */ class TransactionGateway { private $_gateway; private $_config; private $_http; public function __construct($gateway) { $this->_gateway = $gateway; $this->_config = $gateway->config; $this->_config->assertHasAccessTokenOrKeys(); $this->_http = new Http($gateway->config); } public function cloneTransaction($transactionId, $attribs) { Util::verifyKeys(self::cloneSignature(), $attribs); return $this->_doCreate('/transactions/' . $transactionId . '/clone', ['transactionClone' => $attribs]); } /** * @ignore * @access private * @param array $attribs * @return object */ private function create($attribs) { Util::verifyKeys(self::createSignature(), $attribs); return $this->_doCreate('/transactions', ['transaction' => $attribs]); } /** * @ignore * @access private * @param array $attribs * @return object * @throws Exception\ValidationError */ private function createNoValidate($attribs) { $result = $this->create($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * * @deprecated since version 2.3.0 * @access public * @param array $attribs * @return object */ public function createFromTransparentRedirect($queryString) { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::confirm", E_USER_NOTICE); $params = TransparentRedirect::parseAndValidateQueryString( $queryString ); return $this->_doCreate( '/transactions/all/confirm_transparent_redirect_request', ['id' => $params['id']] ); } /** * * @deprecated since version 2.3.0 * @access public * @param none * @return string */ public function createTransactionUrl() { trigger_error("DEPRECATED: Please use TransparentRedirectRequest::url", E_USER_NOTICE); return $this->_config->baseUrl() . $this->_config->merchantPath() . '/transactions/all/create_via_transparent_redirect_request'; } public static function cloneSignature() { return ['amount', 'channel', ['options' => ['submitForSettlement']]]; } /** * creates a full array signature of a valid gateway request * @return array gateway request signature format */ public static function createSignature() { return [ 'amount', 'billingAddressId', 'channel', 'customerId', 'deviceData', 'deviceSessionId', 'fraudMerchantId', 'merchantAccountId', 'orderId', 'paymentMethodNonce', 'paymentMethodToken', 'purchaseOrderNumber', 'recurring', 'serviceFeeAmount', 'sharedPaymentMethodToken', 'sharedCustomerId', 'sharedShippingAddressId', 'sharedBillingAddressId', 'shippingAddressId', 'taxAmount', 'taxExempt', 'threeDSecureToken', 'transactionSource', 'type', 'venmoSdkPaymentMethodCode', ['riskData' => ['customerBrowser', 'customerIp', 'customer_browser', 'customer_ip'] ], ['creditCard' => ['token', 'cardholderName', 'cvv', 'expirationDate', 'expirationMonth', 'expirationYear', 'number'], ], ['customer' => [ 'id', 'company', 'email', 'fax', 'firstName', 'lastName', 'phone', 'website'], ], ['billing' => [ 'firstName', 'lastName', 'company', 'countryName', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', 'extendedAddress', 'locality', 'postalCode', 'region', 'streetAddress'], ], ['shipping' => [ 'firstName', 'lastName', 'company', 'countryName', 'countryCodeAlpha2', 'countryCodeAlpha3', 'countryCodeNumeric', 'extendedAddress', 'locality', 'postalCode', 'region', 'streetAddress'], ], ['threeDSecurePassThru' => [ 'eciFlag', 'cavv', 'xid'], ], ['options' => [ 'holdInEscrow', 'storeInVault', 'storeInVaultOnSuccess', 'submitForSettlement', 'addBillingAddressToPaymentMethod', 'venmoSdkSession', 'storeShippingAddressInVault', 'payeeEmail', ['threeDSecure' => ['required'] ], ['paypal' => [ 'payeeEmail', 'customField', 'description', ['supplementaryData' => ['_anyKey_']], ] ], ['amexRewards' => [ 'requestId', 'points', 'currencyAmount', 'currencyIsoCode' ] ] ], ], ['customFields' => ['_anyKey_']], ['descriptor' => ['name', 'phone', 'url']], ['paypalAccount' => ['payeeEmail']], ['apple_pay_card' => ['number', 'cardholder_name', 'cryptogram', 'expiration_month', 'expiration_year']], #backwards compatibility ['applePayCard' => ['number', 'cardholderName', 'cryptogram', 'expirationMonth', 'expirationYear']], ['industry' => ['industryType', ['data' => [ 'folioNumber', 'checkInDate', 'checkOutDate', 'travelPackage', 'departureDate', 'lodgingCheckInDate', 'lodgingCheckOutDate', 'lodgingName', 'roomRate' ] ] ] ] ]; } public static function submitForSettlementSignature() { return ['orderId', ['descriptor' => ['name', 'phone', 'url']]]; } public static function updateDetailsSignature() { return ['amount', 'orderId', ['descriptor' => ['name', 'phone', 'url']]]; } public static function refundSignature() { return ['amount', 'orderId']; } /** * * @access public * @param array $attribs * @return Result\Successful|Result\Error */ public function credit($attribs) { return $this->create(array_merge($attribs, ['type' => Transaction::CREDIT])); } /** * * @access public * @param array $attribs * @return Result\Successful|Result\Error * @throws Exception\ValidationError */ public function creditNoValidate($attribs) { $result = $this->credit($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * @access public * @param string id * @return Transaction */ public function find($id) { $this->_validateId($id); try { $path = $this->_config->merchantPath() . '/transactions/' . $id; $response = $this->_http->get($path); return Transaction::factory($response['transaction']); } catch (Exception\NotFound $e) { throw new Exception\NotFound( 'transaction with id ' . $id . ' not found' ); } } /** * new sale * @param array $attribs * @return array */ public function sale($attribs) { return $this->create(array_merge(['type' => Transaction::SALE], $attribs)); } /** * roughly equivalent to the ruby bang method * @access public * @param array $attribs * @return array * @throws Exception\ValidationsFailed */ public function saleNoValidate($attribs) { $result = $this->sale($attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } /** * Returns a ResourceCollection of transactions matching the search query. * * If query is a string, the search will be a basic search. * If query is a hash, the search will be an advanced search. * For more detailed information and examples, see {@link http://www.braintreepayments.com/gateway/transaction-api#searching http://www.braintreepaymentsolutions.com/gateway/transaction-api} * * @param mixed $query search query * @param array $options options such as page number * @return ResourceCollection * @throws InvalidArgumentException */ public function search($query) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $path = $this->_config->merchantPath() . '/transactions/advanced_search_ids'; $response = $this->_http->post($path, ['search' => $criteria]); if (array_key_exists('searchResults', $response)) { $pager = [ 'object' => $this, 'method' => 'fetch', 'methodArgs' => [$query] ]; return new ResourceCollection($response, $pager); } else { throw new Exception\DownForMaintenance(); } } public function fetch($query, $ids) { $criteria = []; foreach ($query as $term) { $criteria[$term->name] = $term->toparam(); } $criteria["ids"] = TransactionSearch::ids()->in($ids)->toparam(); $path = $this->_config->merchantPath() . '/transactions/advanced_search'; $response = $this->_http->post($path, ['search' => $criteria]); if (array_key_exists('creditCardTransactions', $response)) { return Util::extractattributeasarray( $response['creditCardTransactions'], 'transaction' ); } else { throw new Exception\DownForMaintenance(); } } /** * void a transaction by id * * @param string $id transaction id * @return Result\Successful|Result\Error */ public function void($transactionId) { $this->_validateId($transactionId); $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/void'; $response = $this->_http->put($path); return $this->_verifyGatewayResponse($response); } /** * */ public function voidNoValidate($transactionId) { $result = $this->void($transactionId); return Util::returnObjectOrThrowException(__CLASS__, $result); } public function submitForSettlement($transactionId, $amount = null, $attribs = []) { $this->_validateId($transactionId); Util::verifyKeys(self::submitForSettlementSignature(), $attribs); $attribs['amount'] = $amount; $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_settlement'; $response = $this->_http->put($path, ['transaction' => $attribs]); return $this->_verifyGatewayResponse($response); } public function submitForSettlementNoValidate($transactionId, $amount = null, $attribs = []) { $result = $this->submitForSettlement($transactionId, $amount, $attribs); return Util::returnObjectOrThrowException(__CLASS__, $result); } public function updateDetails($transactionId, $attribs = []) { $this->_validateId($transactionId); Util::verifyKeys(self::updateDetailsSignature(), $attribs); $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/update_details'; $response = $this->_http->put($path, ['transaction' => $attribs]); return $this->_verifyGatewayResponse($response); } public function submitForPartialSettlement($transactionId, $amount, $attribs = []) { $this->_validateId($transactionId); Util::verifyKeys(self::submitForSettlementSignature(), $attribs); $attribs['amount'] = $amount; $path = $this->_config->merchantPath() . '/transactions/'. $transactionId . '/submit_for_partial_settlement'; $response = $this->_http->post($path, ['transaction' => $attribs]); return $this->_verifyGatewayResponse($response); } public function holdInEscrow($transactionId) { $this->_validateId($transactionId); $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/hold_in_escrow'; $response = $this->_http->put($path, []); return $this->_verifyGatewayResponse($response); } public function releaseFromEscrow($transactionId) { $this->_validateId($transactionId); $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/release_from_escrow'; $response = $this->_http->put($path, []); return $this->_verifyGatewayResponse($response); } public function cancelRelease($transactionId) { $this->_validateId($transactionId); $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/cancel_release'; $response = $this->_http->put($path, []); return $this->_verifyGatewayResponse($response); } public function refund($transactionId, $amount_or_options = null) { self::_validateId($transactionId); if(gettype($amount_or_options) == "array") { $options = $amount_or_options; } else { $options = [ "amount" => $amount_or_options ]; } Util::verifyKeys(self::refundSignature(), $options); $params = ['transaction' => $options]; $path = $this->_config->merchantPath() . '/transactions/' . $transactionId . '/refund'; $response = $this->_http->post($path, $params); return $this->_verifyGatewayResponse($response); } /** * sends the create request to the gateway * * @ignore * @param var $subPath * @param array $params * @return mixed */ public function _doCreate($subPath, $params) { $fullPath = $this->_config->merchantPath() . $subPath; $response = $this->_http->post($fullPath, $params); return $this->_verifyGatewayResponse($response); } /** * verifies that a valid transaction id is being used * @ignore * @param string transaction id * @throws InvalidArgumentException */ private function _validateId($id = null) { if (empty($id)) { throw new InvalidArgumentException( 'expected transaction id to be set' ); } if (!preg_match('/^[0-9a-z]+$/', $id)) { throw new InvalidArgumentException( $id . ' is an invalid transaction id.' ); } } /** * generic method for validating incoming gateway responses * * creates a new Transaction object and encapsulates * it inside a Result\Successful object, or * encapsulates a Errors object inside a Result\Error * alternatively, throws an Unexpected exception if the response is invalid. * * @ignore * @param array $response gateway response values * @return Result\Successful|Result\Error * @throws Exception\Unexpected */ private function _verifyGatewayResponse($response) { if (isset($response['transaction'])) { // return a populated instance of Transaction return new Result\Successful( Transaction::factory($response['transaction']) ); } else if (isset($response['apiErrorResponse'])) { return new Result\Error($response['apiErrorResponse']); } else { throw new Exception\Unexpected( "Expected transaction or apiErrorResponse" ); } } } class_alias('Braintree\TransactionGateway', 'Braintree_TransactionGateway'); lib/ssl/sandbox_braintreegateway_com.ca.crt000064400000002321152101632460015116 0ustar00Subject: L=ValiCert Validation Network, O=ValiCert, Inc., OU=ValiCert Class 2 Policy Validation Authority, CN=http://www.valicert.com//emailAddress=info@valicert.com -----BEGIN CERTIFICATE----- MIIC5zCCAlACAQEwDQYJKoZIhvcNAQEFBQAwgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0 IFZhbGlkYXRpb24gTmV0d29yazEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAz BgNVBAsTLFZhbGlDZXJ0IENsYXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9y aXR5MSEwHwYDVQQDExhodHRwOi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG 9w0BCQEWEWluZm9AdmFsaWNlcnQuY29tMB4XDTk5MDYyNjAwMTk1NFoXDTE5MDYy NjAwMTk1NFowgbsxJDAiBgNVBAcTG1ZhbGlDZXJ0IFZhbGlkYXRpb24gTmV0d29y azEXMBUGA1UEChMOVmFsaUNlcnQsIEluYy4xNTAzBgNVBAsTLFZhbGlDZXJ0IENs YXNzIDIgUG9saWN5IFZhbGlkYXRpb24gQXV0aG9yaXR5MSEwHwYDVQQDExhodHRw Oi8vd3d3LnZhbGljZXJ0LmNvbS8xIDAeBgkqhkiG9w0BCQEWEWluZm9AdmFsaWNl cnQuY29tMIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQKBgQDOOnHK5avIWZJV16vY dA757tn2VUdZZUcOBVXc65g2PFxTXdMwzzjsvUGJ7SVCCSRrCl6zfN1SLUzm1NZ9 WlmpZdRJEy0kTRxQb7XBhVQ7/nHk01xC+YDgkRoKWzk2Z/M/VXwbP7RfZHM047QS v4dk+NoS/zcnwbNDu+97bi5p9wIDAQABMA0GCSqGSIb3DQEBBQUAA4GBADt/UG9v UJSZSWI4OB9L+KXIPqeCgfYrx+jFzug6EILLGACOTb2oWH+heQC1u+mNr0HZDzTu IYEZoDJJKPTEjlbVUjP9UNV+mWwD5MlM/Mtsq2azSiGM5bUMMj4QssxsodyamEwC W/POuZ6lcg5Ktz885hZo+L7tdEy8W9ViH0Pd -----END CERTIFICATE----- lib/ssl/www_braintreegateway_com.ca.crt000064400000027415152101632460014317 0ustar00Subject: O=Entrust.net, OU=www.entrust.net/GCCA_CPS incorp. by ref. (limits liab.), OU=(c) 2000 Entrust.net Limited, CN=Entrust.net Client Certification Authority -----BEGIN CERTIFICATE----- MIIEgzCCA+ygAwIBAgIEOJ725DANBgkqhkiG9w0BAQQFADCBtDEUMBIGA1UE ChMLRW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC9HQ0NB X0NQUyBpbmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsT HChjKSAyMDAwIEVudHJ1c3QubmV0IExpbWl0ZWQxMzAxBgNVBAMTKkVudHJ1 c3QubmV0IENsaWVudCBDZXJ0aWZpY2F0aW9uIE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A6NC4wAwIEkDANBgkqhkiG9w0BAQQFAAOBgQBObzWA O9GK9Q6nIMstZVXQkvTnhLUGJoMShAusO7JE7r3PQNsgDrpuFOow4DtifH+L a3xKp9U1PL6oXOpLu5OOgGarDyn9TS2/GpsKkMWr2tGzhtQvJFJcem3G8v7l TRowjJDyutdKPkN+1MhQGof4T4HHdguEOnKdzmVml64mXg== -----END CERTIFICATE----- Subject: O=Entrust.net, OU=www.entrust.net/SSL_CPS incorp. by ref. (limits liab.), OU=(c) 2000 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority -----BEGIN CERTIFICATE----- MIIElTCCA/6gAwIBAgIEOJsRPDANBgkqhkiG9w0BAQQFADCBujEUMBIGA1UE ChMLRW50cnVzdC5uZXQxPzA9BgNVBAsUNnd3dy5lbnRydXN0Lm5ldC9TU0xf Q1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTElMCMGA1UECxMc KGMpIDIwMDAgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UEAxMxRW50cnVz dC5uZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1dGhvcml0eTAe Fw0wMDAyMDQxNzIwMDBaFw0yMDAyMDQxNzUwMDBaMIG6MRQwEgYDVQQKEwtF bnRydXN0Lm5ldDE/MD0GA1UECxQ2d3d3LmVudHJ1c3QubmV0L1NTTF9DUFMg aW5jb3JwLiBieSByZWYuIChsaW1pdHMgbGlhYi4pMSUwIwYDVQQLExwoYykg MjAwMCBFbnRydXN0Lm5ldCBMaW1pdGVkMTowOAYDVQQDEzFFbnRydXN0Lm5l dCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRpb24gQXV0aG9yaXR5MIGfMA0G CSqGSIb3DQEBAQUAA4GNADCBiQKBgQDHwV9OcfHO8GCGD9JYf9Mzly0XonUw tZZkJi9ow0SrqHXmAGc0V55lxyKbc+bT3QgON1WqJUaBbL3+qPZ1V1eMkGxK wz6LS0MKyRFWmponIpnPVZ5h2QLifLZ8OAfc439PmrkDQYC2dWcTC5/oVzbI XQA23mYU2m52H083jIITiQIDAQABo4IBpDCCAaAwEQYJYIZIAYb4QgEBBAQD AgAHMIHjBgNVHR8EgdswgdgwgdWggdKggc+kgcwwgckxFDASBgNVBAoTC0Vu dHJ1c3QubmV0MT8wPQYDVQQLFDZ3d3cuZW50cnVzdC5uZXQvU1NMX0NQUyBp bmNvcnAuIGJ5IHJlZi4gKGxpbWl0cyBsaWFiLikxJTAjBgNVBAsTHChjKSAy MDAwIEVudHJ1c3QubmV0IExpbWl0ZWQxOjA4BgNVBAMTMUVudHJ1c3QubmV0 IFNlY3VyZSBTZXJ2ZXIgQ2VydGlmaWNhdGlvbiBBdXRob3JpdHkxDTALBgNV BAMTBENSTDEwKwYDVR0QBCQwIoAPMjAwMDAyMDQxNzIwMDBagQ8yMDIwMDIw NDE3NTAwMFowCwYDVR0PBAQDAgEGMB8GA1UdIwQYMBaAFMtswGvjuz7L/CKc /vuLkpyw8m4iMB0GA1UdDgQWBBTLbMBr47s+y/winP77i5KcsPJuIjAMBgNV HRMEBTADAQH/MB0GCSqGSIb2fQdBAAQQMA4bCFY1LjA6NC4wAwIEkDANBgkq hkiG9w0BAQQFAAOBgQBi24GRzsiad0Iv7L0no1MPUBvqTpLwqa+poLpIYcvv yQbvH9X07t9WLebKahlzqlO+krNQAraFJnJj2HVQYnUUt7NQGj/KEQALhUVp bbalrlHhStyCP2yMNLJ3a9kC9n8O6mUE8c1UyrrJzOCE98g+EZfTYAkYvAX/ bIkz8OwVDw== -----END CERTIFICATE----- Subject: O=Entrust.net, OU=www.entrust.net/CPS_2048 incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Certification Authority (2048) -----BEGIN CERTIFICATE----- MIIEXDCCA0SgAwIBAgIEOGO5ZjANBgkqhkiG9w0BAQUFADCBtDEUMBIGA1UE ChMLRW50cnVzdC5uZXQxQDA+BgNVBAsUN3d3dy5lbnRydXN0Lm5ldC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tj6xnLZ8xpJdGGQC49MGCBFh fGPjK50xA3B20qMooPS7mmNz7W3lKtvtFKkrxjYR0CvrB4ul2p5cGZ1WEvVU KcgF7bISKo30Axv/55IQh7A6tcOdBTcSo8f0FbnVpDkWm1M6I5HxqIKiaoho wXkCIryqptau37AUX7iH0N18f3v/rxzP5tsHrV7bhZ3QKw0z2wTR5klAEyt2 +z7pnIkPFc4YsIV4IU9rTw76NmfNB/L/CNDi3tm/Kq+4h4YhPATKt5Rof888 6ZjXOP/swNlQ8C5LWK5Gb9Auw2DaclVyvUxFnmG6v4SBkgPR0ml8xQ== -----END CERTIFICATE----- Subject: C=US, O=Entrust.net, OU=www.entrust.net/Client_CA_Info/CPS incorp. by ref. limits liab., OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Client Certification Authority -----BEGIN CERTIFICATE----- MIIE7TCCBFagAwIBAgIEOAOR7jANBgkqhkiG9w0BAQQFADCByTELMAkGA1UE BhMCVVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MUgwRgYDVQQLFD93d3cuZW50 cnVzdC5uZXQvQ2xpZW50X0NBX0luZm8vQ1BTIGluY29ycC4gYnkgcmVmLiBs aW1pdHMgbGlhYi4xJTAjBgNVBAsTHChjKSAxOTk5IEVudHJ1c3QubmV0IExp bWl0ZWQxMzAxBgNVBAMTKkVudHJ1c3QubmV0IENsaWVudCBDZXJ0aWZpY2F0 aW9uIEF1dGhvcml0eTAeFw05OTEwMTIxOTI0MzBaFw0xOTEwMTIxOTU0MzBa MIHJMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxSDBGBgNV BAsUP3d3dy5lbnRydXN0Lm5ldC9DbGllbnRfQ0FfSW5mby9DUFMgaW5jb3Jw LiBieSByZWYuIGxpbWl0cyBsaWFiLjElMCMGA1UECxMcKGMpIDE5OTkgRW50 cnVzdC5uZXQgTGltaXRlZDEzMDEGA1UEAxMqRW50cnVzdC5uZXQgQ2xpZW50 IENlcnRpZmljYXRpb24gQ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ERTIFICATE----- Subject: C=US, O=Entrust.net, OU=www.entrust.net/CPS incorp. by ref. (limits liab.), OU=(c) 1999 Entrust.net Limited, CN=Entrust.net Secure Server Certification Authority -----BEGIN CERTIFICATE----- MIIE2DCCBEGgAwIBAgIEN0rSQzANBgkqhkiG9w0BAQUFADCBwzELMAkGA1UE BhMCVVMxFDASBgNVBAoTC0VudHJ1c3QubmV0MTswOQYDVQQLEzJ3d3cuZW50 cnVzdC5uZXQvQ1BTIGluY29ycC4gYnkgcmVmLiAobGltaXRzIGxpYWIuKTEl MCMGA1UECxMcKGMpIDE5OTkgRW50cnVzdC5uZXQgTGltaXRlZDE6MDgGA1UE AxMxRW50cnVzdC5uZXQgU2VjdXJlIFNlcnZlciBDZXJ0aWZpY2F0aW9uIEF1 dGhvcml0eTAeFw05OTA1MjUxNjA5NDBaFw0xOTA1MjUxNjM5NDBaMIHDMQsw CQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVzdC5uZXQxOzA5BgNVBAsTMnd3 dy5lbnRydXN0Lm5ldC9DUFMgaW5jb3JwLiBieSByZWYuIChsaW1pdHMgbGlh Yi4pMSUwIwYDVQQLExwoYykgMTk5OSBFbnRydXN0Lm5ldCBMaW1pdGVkMTow OAYDVQQDEzFFbnRydXN0Lm5ldCBTZWN1cmUgU2VydmVyIENlcnRpZmljYXRp b24gQXV0aG9yaXR5MIGdMA0GCSqGSIb3DQEBAQUAA4GLADCBhwKBgQDNKIM0 VBuJ8w+vN5Ex/68xYMmo6LIQaO2f55M28Qpku0f1BBc/I0dNxScZgSYMVHIN iC3ZH5oSn7yzcdOAGT9HZnuMNSjSuQrfJNqc1lB5gXpa0zf3wkrYKZImZNHk mGw6AIr1NJtl+O3jEP/9uElY3KDegjlrgbEWGWG5VLbmQwIBA6OCAdcwggHT MBEGCWCGSAGG+EIBAQQEAwIABzCCARkGA1UdHwSCARAwggEMMIHeoIHboIHY pIHVMIHSMQswCQYDVQQGEwJVUzEUMBIGA1UEChMLRW50cnVz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RGDBezUqXbpZGRzzfTb+cnCDpOGR86p1hcF895P4vkp9Mm I50mD1hp/Ed+stCNi5O/KU9DaXR2Z0vPB4zmAve14bRDtUstFJ/53CYNv6ZHdAbY iNE6KTCEztI5gGIbqMdXSbxqVVFnFUq+NQfk1XWYN3kwFNspnWzFacxHVaIw98xc f8LDmBxrThaA63p4ZUWiABqvDA1VZDRIuJK58bRQKfJPIx/abKwfROHdI3hRW8cW -----END CERTIFICATE----- lib/ssl/api_braintreegateway_com.ca.crt000064400000026607152101632460014246 0ustar00-----BEGIN CERTIFICATE----- MIIE0zCCA7ugAwIBAgIQGNrRniZ96LtKIVjNzGs7SjANBgkqhkiG9w0BAQUFADCB yjELMAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQL ExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJp U2lnbiwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxW ZXJpU2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0 aG9yaXR5IC0gRzUwHhcNMDYxMTA4MDAwMDAwWhcNMzYwNzE2MjM1OTU5WjCByjEL MAkGA1UEBhMCVVMxFzAVBgNVBAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZW ZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTowOAYDVQQLEzEoYykgMjAwNiBWZXJpU2ln biwgSW5jLiAtIEZvciBhdXRob3JpemVkIHVzZSBvbmx5MUUwQwYDVQQDEzxWZXJp U2lnbiBDbGFzcyAzIFB1YmxpYyBQcmltYXJ5IENlcnRpZmljYXRpb24gQXV0aG9y aXR5IC0gRzUwggEiMA0GCSqGSIb3DQEBAQUAA4IBDwAwggEKAoIBAQCvJAgIKXo1 nmAMqudLO07cfLw8RRy7K+D+KQL5VwijZIUVJ/XxrcgxiV0i6C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gSW5jLjEbMBkGA1UEAxMSR2VvVHJ1c3Qg R2xvYmFsIENBMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2swYYzD9 9BcjGlZ+W988bDjkcbd4kdS8odhM+KhDtgPpTSEHCIjaWC9mOSm9BXiLnTjoBbdq fnGk5sRgprDvgOSJKA+eJdbtg/OtppHHmMlCGDUUna2YRpIuT8rxh0PBFpVXLVDv iS2Aelet8u5fa9IAjbkU+BQVNdnARqN7csiRv8lVK83Qlz6cJmTM386DGXHKTubU 1XupGc1V3sjs0l44U+VcT4wt/lAjNvxm5suOpDkZALeVAjmRCw7+OC7RHQWa9k0+ bw8HHa8sHo9gOeL6NlMTOdReJivbPagUvTLrGAMoUgRx5aszPeE4uwc2hGKceeoW MPRfwCvocWvk+QIDAQABo1MwUTAPBgNVHRMBAf8EBTADAQH/MB0GA1UdDgQWBBTA ephojYn7qwVkDBF9qn1luMrMTjAfBgNVHSMEGDAWgBTAephojYn7qwVkDBF9qn1l uMrMTjANBgkqhkiG9w0BAQUFAAOCAQEANeMpauUvXVSOKVCUn5kaFOSPeCpilKIn Z57QzxpeR+nBsqTP3UEaBU6bS+5Kb1VSsyShNwrrZHYqLizz/Tt1kL/6cdjHPTfS tQWVYrmm3ok9Nns4d0iXrKYgjy6myQzCsplFAMfOEVEiIuCl6rYVSAlk6l5PdPcF PseKUgzbFbS9bZvlxrFUaKnjaZC2mqUPuLk/IH2uSrW4nOQdtqvmlKXBx4Ot2/Un hw4EbNX/3aBd7YdStysVAq45pmp06drE57xNNB6pXE0zX5IJL4hmXXeXxx12E6nV 5fEWCRE11azbJHFwLJhWC9kXtNHjUStedejV0NxPNO3CBWaAocvmMw== -----END CERTIFICATE----- lib/autoload.php000064400000001113152101632460007627 0ustar00= 5.4.0 required'); } function requireDependencies() { $requiredExtensions = ['xmlwriter', 'openssl', 'dom', 'hash', 'curl']; foreach ($requiredExtensions AS $ext) { if (!extension_loaded($ext)) { throw new Braintree_Exception('The Braintree library requires the ' . $ext . ' extension.'); } } } requireDependencies();