当前位置: 首页>>代码示例>>PHP>>正文


PHP Braintree_Customer::find方法代码示例

本文整理汇总了PHP中Braintree_Customer::find方法的典型用法代码示例。如果您正苦于以下问题:PHP Braintree_Customer::find方法的具体用法?PHP Braintree_Customer::find怎么用?PHP Braintree_Customer::find使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Braintree_Customer的用法示例。


在下文中一共展示了Braintree_Customer::find方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCustomerCards

 /**
  * Returns customer credit cards if applicable
  * 
  * @return Braintree_Customer | boolean
  */
 public function getCustomerCards()
 {
     $session = Mage::getSingleton('adminhtml/session_quote');
     $applicableCards = array();
     if (Mage::getStoreConfig(self::CONFIG_PATH_VAULT, $session->getStoreId())) {
         $storedCards = false;
         if ($session->getCustomerId()) {
             $customerId = Mage::helper('braintree_payments')->generateCustomerId($session->getCustomerId(), $session->getQuote()->getCustomerEmail());
             try {
                 $storedCards = Braintree_Customer::find($customerId)->creditCards;
             } catch (Braintree_Exception $e) {
                 Mage::logException($e);
             }
         }
         if ($storedCards) {
             $country = $session->getQuote()->getBillingAddress()->getCountryId();
             $types = Mage::getModel('braintree_payments/creditcard')->getApplicableCardTypes($country);
             $applicableCards = array();
             foreach ($storedCards as $card) {
                 if (in_array(Mage::helper('braintree_payments')->getCcTypeCodeByName($card->cardType), $types)) {
                     $applicableCards[] = $card;
                 }
             }
         }
     }
     return $applicableCards;
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:32,代码来源:Createorder.php

示例2: getCustomerById

 /**
  * @param $id
  *
  * @return object
  */
 public function getCustomerById($id)
 {
     try {
         $customer = \Braintree_Customer::find($id);
     } catch (\Braintree_Exception_NotFound $e) {
         return false;
     }
     return $customer;
 }
开发者ID:yii-ext,项目名称:payment,代码行数:14,代码来源:BraintreeRecurringGateway.php

示例3: testTokenPayment

 /**
  * @depends testCustomerCreate
  */
 public function testTokenPayment()
 {
     $customer = \Braintree_Customer::find(self::$customer->id);
     $this->assertInstanceOf('\\Braintree_Customer', $customer);
     $this->assertArrayHasKey(0, $customer->paymentMethods());
     $model = new BraintreeForm();
     $model->setScenario('saleFromVault');
     $this->assertTrue($model->load(['amount' => rand(1, 200), 'paymentMethodToken' => $customer->paymentMethods()[0]->token], ''));
     $this->assertNotFalse($model->send());
 }
开发者ID:skamnev,项目名称:members,代码行数:13,代码来源:BraintreeFormTest.php

示例4: createSubscription

 public function createSubscription($customer_id, $package_code, $monthly_price)
 {
     try {
         $customer = Braintree_Customer::find($customer_id);
         $payment_method_token = $customer->creditCards[0]->token;
         $result = Braintree_Subscription::create(array('paymentMethodToken' => $payment_method_token, 'planId' => $package_code, 'price' => $monthly_price));
         return $result;
     } catch (Braintree_Exception_NotFound $e) {
         $bexcption = print_r($e, true);
         log_message('error', date('Y-m-d H:i:s') . ' ' . $bexcption, true);
         $result = new stdClass();
         $result->success = false;
         return $result;
     }
 }
开发者ID:agency2016,项目名称:rothy_cloudynote,代码行数:15,代码来源:braintree_ci.php

示例5: test_GatewayRespectsMakeDefault

 function test_GatewayRespectsMakeDefault()
 {
     $result = Braintree_Customer::create();
     $this->assertTrue($result->success);
     $customerId = $result->customer->id;
     $result = Braintree_CreditCard::create(array('customerId' => $customerId, 'number' => '4111111111111111', 'expirationDate' => '11/2099'));
     $this->assertTrue($result->success);
     $clientToken = Braintree_ClientToken::generate(array("customerId" => $customerId, "options" => array("makeDefault" => true)));
     $authorizationFingerprint = json_decode($clientToken)->authorizationFingerprint;
     $response = Braintree_HttpClientApi::post('/client_api/nonces.json', json_encode(array("credit_card" => array("number" => "4242424242424242", "expirationDate" => "11/2099"), "authorization_fingerprint" => $authorizationFingerprint, "shared_customer_identifier" => "fake_identifier", "shared_customer_identifier_type" => "testing")));
     $this->assertEquals(201, $response["status"]);
     $customer = Braintree_Customer::find($customerId);
     $this->assertEquals(2, count($customer->creditCards));
     foreach ($customer->creditCards as $creditCard) {
         if ($creditCard->last4 == "4242") {
             $this->assertTrue($creditCard->default);
         }
     }
 }
开发者ID:riteshkmr33,项目名称:ovessnce,代码行数:19,代码来源:ClientTokenTest.php

示例6: check

 public function check($customer)
 {
     if (empty($customer)) {
         $customer = $this->_controller->currUser;
     }
     $firstName = $lastName = '';
     $name = explode(' ', $customer['User']['full_name']);
     if (count($name) > 0) {
         $firstName = array_shift($name);
         $lastName = implode(' ', $name);
     }
     $customerData = array('firstName' => $firstName, 'lastName' => $lastName, 'email' => $customer['User']['username'], 'phone' => $customer['User']['phone']);
     try {
         $_customer = Braintree_Customer::find('konstruktor-' . $customer['User']['id']);
         $_customer = Braintree_Customer::update('konstruktor-' . $customer['User']['id'], $customerData);
     } catch (Exception $e) {
         $_customer = Braintree_Customer::create(Hash::merge(array('id' => 'konstruktor-' . $customer['User']['id']), $customerData));
     }
     if ($_customer->success) {
         return $_customer->customer;
     }
     return array();
 }
开发者ID:nilBora,项目名称:konstruktor,代码行数:23,代码来源:BraintreeCustomerComponent.php

示例7: getToken

 /**
  * Generates token for further use
  * 
  * @return string | boolean
  */
 public function getToken()
 {
     $customerExists = false;
     $customerSession = Mage::getSingleton('customer/session');
     $magentoCustomerId = false;
     $magentoCustomerEmail = false;
     $storeId = null;
     if ($customerSession->isLoggedIn()) {
         $magentoCustomerId = $customerSession->getCustomerId();
         $magentoCustomerEmail = $customerSession->getCustomer()->getEmail();
     } else {
         if (Mage::app()->getStore()->isAdmin()) {
             $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
             $magentoCustomerId = $quote->getCustomerId();
             $magentoCustomerEmail = $quote->getCustomerEmail();
             $storeId = $quote->getStoreId();
         }
     }
     if ($magentoCustomerId && $magentoCustomerEmail) {
         $customerId = $this->generateCustomerId($magentoCustomerId, $magentoCustomerEmail);
         try {
             $customerExists = Braintree_Customer::find($customerId);
         } catch (Exception $e) {
             $customerExists = false;
         }
     }
     $params = array("merchantAccountId" => Mage::getStoreConfig('payment/braintree/merchant_account_id', $storeId));
     if ($customerExists) {
         $params['customerId'] = $customerId;
     }
     try {
         $token = Braintree_ClientToken::generate($params);
     } catch (Exception $e) {
         Mage::logException($e);
         return false;
     }
     return $this->jsQuoteEscape($token);
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:43,代码来源:Data.php

示例8: getCustomer

 function getCustomer(&$order, $force = false)
 {
     global $current_user;
     //already have it?
     if (!empty($this->customer) && !$force) {
         return $this->customer;
     }
     //try based on user id
     if (!empty($order->user_id)) {
         $user_id = $order->user_id;
     }
     //if no id passed, check the current user
     if (empty($user_id) && !empty($current_user->ID)) {
         $user_id = $current_user->ID;
     }
     //check for a braintree customer id
     if (!empty($user_id)) {
         $customer_id = get_user_meta($user_id, "pmpro_braintree_customerid", true);
     }
     //check for an existing stripe customer
     if (!empty($customer_id)) {
         try {
             $this->customer = Braintree_Customer::find($customer_id);
             //update the customer description and card
             if (!empty($order->accountnumber)) {
                 $response = Braintree_Customer::update($customer_id, array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'creditCard' => array('number' => $order->braintree->number, 'expirationDate' => $order->braintree->expiration_date, 'cardholderName' => trim($order->FirstName . " " . $order->LastName), 'options' => array('updateExistingToken' => $customer_id))));
                 if ($response->success) {
                     $this->customer = $result->customer;
                 } else {
                     $order->error = __("Failed to update customer.", "pmpro");
                     $order->shorterror = $order->error;
                     return false;
                 }
             }
             return $this->customer;
         } catch (Exception $e) {
             //assume no customer found
         }
     }
     //no customer id, create one
     if (!empty($order->accountnumber)) {
         try {
             $result = Braintree_Customer::create(array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'email' => $order->Email, 'phone' => $order->billing->phone, 'creditCard' => array('number' => $order->braintree->number, 'expirationDate' => $order->braintree->expiration_date, 'cvv' => $order->braintree->cvv, 'cardholderName' => trim($order->FirstName . " " . $order->LastName), 'billingAddress' => array('firstName' => $order->FirstName, 'lastName' => $order->LastName, 'streetAddress' => $order->Address1, 'extendedAddress' => $order->Address2, 'locality' => $order->billing->city, 'region' => $order->billing->state, 'postalCode' => $order->billing->zip, 'countryCodeAlpha2' => $order->billing->country))));
             if ($result->success) {
                 $this->customer = $result->customer;
             } else {
                 $order->error = __("Failed to create customer.", "pmpro");
                 $order->shorterror = $order->error;
                 return false;
             }
         } catch (Exception $e) {
             $order->error = __("Error creating customer record with Braintree:", "pmpro") . " " . $e->getMessage();
             $order->shorterror = $order->error;
             return false;
         }
         update_user_meta($user_id, "pmpro_braintree_customerid", $this->customer->id);
         return $this->customer;
     }
     return false;
 }
开发者ID:Willislahav,项目名称:paid-memberships-pro,代码行数:60,代码来源:class.pmprogateway_braintree.php

示例9: vaultCustomer

 public function vaultCustomer()
 {
     $customerId = $this->customerDetails->id;
     if (empty($customerId)) {
         return null;
     } else {
         return Braintree_Customer::find($customerId);
     }
 }
开发者ID:anmolview,项目名称:yiidemos,代码行数:9,代码来源:Transaction.php

示例10: showBTCustomer

 public function showBTCustomer()
 {
     $aCustomerId = $_GET["id_user"];
     $customer = Braintree_Customer::find($aCustomerId);
     pr($customer);
 }
开发者ID:CapsuleCorpIndonesia,项目名称:martabak_revolution,代码行数:6,代码来源:WS.php

示例11: showBraintree

 public function showBraintree()
 {
     try {
         $customer = Braintree_Customer::find('development_fruit_analytics_user_' . Auth::user()->id);
     } catch (Braintree_Exception_NotFound $e) {
         $result = Braintree_Customer::create(array('id' => 'development_fruit_analytics_user_' . Auth::user()->id, 'email' => Auth::user()->email));
         if ($result->success) {
             $customer = $result->customer;
         } else {
             // needs error handling
         }
     }
     $clientToken = Braintree_ClientToken::generate(array("customerId" => $customer->id));
     return View::make('dev.braintree', array('clientToken' => $clientToken));
 }
开发者ID:raschan,项目名称:fruit-dashboard,代码行数:15,代码来源:HelloController.php

示例12: find

 public function find($id)
 {
     switch ($this->context) {
         case 'customer':
             try {
                 return Braintree_Customer::find($id);
             } catch (Exception $e) {
                 return false;
             }
             break;
     }
 }
开发者ID:quantum-x,项目名称:CakeBraintree,代码行数:12,代码来源:CakeBraintreeComponent.php

示例13: testSale_andStoreShippingAddressInVault

 function testSale_andStoreShippingAddressInVault()
 {
     $customer = Braintree_Customer::create(array('firstName' => 'Mike', 'lastName' => 'Jones', 'company' => 'Jones Co.', 'email' => 'mike.jones@example.com', 'phone' => '419.555.1234', 'fax' => '419.555.1235', 'website' => 'http://example.com'))->customer;
     $transaction = Braintree_Transaction::sale(array('amount' => '100.00', 'customerId' => $customer->id, 'creditCard' => array('cardholderName' => 'The Cardholder', 'number' => Braintree_Test_CreditCardNumbers::$visa, 'expirationDate' => '05/12'), 'shipping' => array('firstName' => 'Darren', 'lastName' => 'Stevens'), 'options' => array('storeInVault' => true, 'storeShippingAddressInVault' => true)))->transaction;
     $customer = Braintree_Customer::find($customer->id);
     $this->assertEquals('Darren', $customer->addresses[0]->firstName);
     $this->assertEquals('Stevens', $customer->addresses[0]->lastName);
 }
开发者ID:netGALAXYStudios,项目名称:ourmovingapp,代码行数:8,代码来源:TransactionTest.php

示例14: testUpdateFromTransparentRedirect_andUpdateExistingBillingAddress

 function testUpdateFromTransparentRedirect_andUpdateExistingBillingAddress()
 {
     $customer = Braintree_Customer::createNoValidate();
     $card = Braintree_CreditCard::createNoValidate(array('customerId' => $customer->id, 'number' => '5105105105105100', 'expirationDate' => '05/12', 'billingAddress' => array('firstName' => 'Drew', 'lastName' => 'Smith', 'company' => 'Smith Co.', 'streetAddress' => '123 Old St', 'extendedAddress' => 'Suite 101', 'locality' => 'Chicago', 'region' => 'IL', 'postalCode' => '60622', 'countryName' => 'United States of America')));
     $queryString = $this->updateCreditCardViaTr(array(), array('paymentMethodToken' => $card->token, 'creditCard' => array('billingAddress' => array('streetAddress' => '123 New St', 'locality' => 'St. Louis', 'region' => 'MO', 'postalCode' => '63119', 'options' => array('updateExisting' => True)))));
     $result = Braintree_CreditCard::updateFromTransparentRedirect($queryString);
     $this->assertTrue($result->success);
     $card = $result->creditCard;
     $this->assertEquals(1, sizeof(Braintree_Customer::find($customer->id)->addresses));
     $this->assertEquals('123 New St', $card->billingAddress->streetAddress);
     $this->assertEquals('St. Louis', $card->billingAddress->locality);
     $this->assertEquals('MO', $card->billingAddress->region);
     $this->assertEquals('63119', $card->billingAddress->postalCode);
 }
开发者ID:rayku,项目名称:rayku,代码行数:14,代码来源:CreditCardTest.php

示例15: currentCustomerStoredCards

 /**
  * Array of customer credit cards
  * 
  * @return array
  */
 public function currentCustomerStoredCards()
 {
     if ($this->useVault() && Mage::getSingleton('customer/session')->isLoggedIn()) {
         $customerId = Mage::helper('braintree_payments')->generateCustomerId(Mage::getSingleton('customer/session')->getCustomerId(), Mage::getSingleton('customer/session')->getCustomer()->getEmail());
         try {
             $ret = Braintree_Customer::find($customerId)->creditCards;
             $this->_debug($customerId);
             $this->_debug($ret);
             return $ret;
         } catch (Braintree_Exception $e) {
             return array();
         }
     }
     return array();
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:20,代码来源:Creditcard.php


注:本文中的Braintree_Customer::find方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。