Esempio n. 1
0
 /**
  * Sort the array using the given callback.
  *
  * @param  array $array
  * @param  Closure $callback
  *
  * @return array
  */
 public static function sort($array, Closure $callback)
 {
     return Collection::make($array)->sortBy($callback)->all();
 }
 /**
  * Get the current discounts for the subscription.
  *
  * @return array
  */
 protected function currentDiscounts()
 {
     return Collection::make($this->asBraintreeSubscription()->discounts)->map(function ($discount) {
         return $discount->id;
     })->all();
 }
Esempio n. 3
0
 /**
  * Get a collection of the entity's invoices.
  *
  * @param bool $includePending
  * @param array $parameters
  *
  * @return Collection
  */
 public function invoices($includePending = false, $parameters = [])
 {
     $invoices = [];
     $customer = $this->asBraintreeCustomer();
     $parameters = array_merge([TransactionSearch::customerId()->is($customer->id), TransactionSearch::createdAt()->between(Carbon::today()->subYears(2)->format('m/d/Y H:i'), Carbon::tomorrow()->format('m/d/Y H:i'))], $parameters);
     $transactions = BraintreeTransaction::search($parameters);
     // Here we will loop through the Braintree invoices and create our own custom Invoice
     // instance that gets more helper methods and is generally more convenient to work
     // work than the plain Braintree objects are. Then, we'll return the full array.
     if (!is_null($transactions)) {
         foreach ($transactions as $transaction) {
             if ($transaction->status == BraintreeTransaction::SETTLED || $includePending) {
                 $invoices[] = new Invoice($this, $transaction);
             }
         }
     }
     return Collection::make($invoices);
 }