public static function fetch($query, $ids)
 {
     $criteria = array();
     foreach ($query as $term) {
         $criteria[$term->name] = $term->toparam();
     }
     $criteria["ids"] = Braintree_CustomerSearch::ids()->in($ids)->toparam();
     $response = Braintree_Http::post('/customers/advanced_search', array('search' => $criteria));
     return Braintree_Util::extractattributeasarray($response['customers'], 'customer');
 }
 public function searchUserInBrainTree($objUser)
 {
     echo 'searchUserInBrainTree';
     //        $braintree_id = '12';
     $collection = Braintree_Customer::search([Braintree_CustomerSearch::id()->is($objUser->braintree_id), Braintree_CustomerSearch::addressFirstName()->is($objUser->full_name)]);
     //        $customer = Braintree_Customer::find($objUser->braintree_id);
     //        pr($customer);
     $arrUser = $collection->_ids;
     pr($arrUser);
 }
Пример #3
0
 public function fetch($query, $ids)
 {
     $criteria = array();
     foreach ($query as $term) {
         $criteria[$term->name] = $term->toparam();
     }
     $criteria["ids"] = Braintree_CustomerSearch::ids()->in($ids)->toparam();
     $path = $this->_config->merchantPath() . '/customers/advanced_search';
     $response = $this->_http->post($path, array('search' => $criteria));
     return Braintree_Util::extractattributeasarray($response['customers'], 'customer');
 }
 function test_createdAt()
 {
     $customer = Braintree_Customer::createNoValidate();
     $past = clone $customer->createdAt;
     $past->modify("-1 hour");
     $future = clone $customer->createdAt;
     $future->modify("+1 hour");
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::createdAt()->between($past, $future)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::createdAt()->lessThanOrEqualTo($future)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
     $collection = Braintree_Customer::search(array(Braintree_CustomerSearch::id()->is($customer->id), Braintree_CustomerSearch::createdAt()->greaterThanOrEqualTo($past)));
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($customer->id, $collection->firstItem()->id);
 }
 function test_throwsIfNoOperatorNodeGiven()
 {
     $this->setExpectedException('InvalidArgumentException', 'Operator must be provided');
     Braintree_Customer::search(array(Braintree_CustomerSearch::creditCardExpirationDate()));
 }
 /**
  * Selects bulk of customers to process
  * 
  * @param Datetime $startDate
  * @param Datetime $endDate
  */
 protected function _selectBulk($startDate, $endDate = null)
 {
     if (is_null($endDate)) {
         $endDate = new Datetime();
     }
     try {
         $customers = Braintree_Customer::search(array(Braintree_CustomerSearch::createdAt()->between($startDate, $endDate)));
     } catch (Exception $e) {
         Mage::logException($e);
         $customers = false;
     }
     if ($customers) {
         if ($customers->maximumCount() == 0) {
             return;
         } else {
             if ($customers->maximumCount() >= self::BULK_MAX_SIZE) {
                 $this->_output('There are more than ' . self::BULK_MAX_SIZE . ' customers in interval between ' . $startDate->format('Y-m-d') . ' and ' . $endDate->format('Y-m-d') . '. Selecting smaller periods');
                 $customers = false;
             }
         }
     }
     if ($customers === false) {
         $median = clone $startDate;
         $interval = new DateInterval('P' . ceil($endDate->diff($startDate)->days / 2) . 'D');
         $median->add($interval);
         $this->_selectBulk($startDate, $median);
         $this->_selectBulk($median, $endDate);
     } else {
         $this->_processBulk($customers);
     }
 }
Пример #7
0
if (isset($_GET['action']) && $_GET['action'] == 'generateNewCustomer') {
    $faker = Faker\Factory::create();
    $firstName = $faker->firstName;
    $lastName = $faker->lastName;
    $createCustomer = Braintree_Customer::create(['firstName' => $firstName, 'lastName' => $lastName, 'company' => $faker->company, 'email' => $firstName . "." . $lastName . "@dummy.com", 'phone' => $faker->phoneNumber, 'fax' => $faker->phoneNumber]);
    if ($createCustomer->success) {
        echo '<div class="alert alert-success" role="alert">Customer "' . $firstName . " " . $lastName . '" is generated.</div>';
    } else {
        echo "<div class='alert alert-danger' role='alert'>{$createCustomer->message}</div>";
    }
}
// continue loading customers page
$now = new DateTime();
$past = clone $now;
$past = $past->modify("-5 month");
$customerCollection = Braintree_Customer::search([Braintree_CustomerSearch::createdAt()->between($past, $now)]);
?>

<div class="page-header">
  <h1>Customers <small>click payment method to charge</small></h1>
</div>

<a href="./customers.php?action=generateNewCustomer" class="btn btn-primary">Generate new customer</a>
<br/><br/>

<table class="table table-striped">
  <thead>
    <tr>
      <th>ID</th>
      <th>First Name</th>
      <th>Last Name</th>