コード例 #1
0
 /**
  * Get a collection of the entity's invoices.
  *
  * @param  bool  $includePending
  * @param  array  $parameters
  * @return \Illuminate\Support\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:s'), Carbon::tomorrow()->format('m/d/Y H:s'))], $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 new Collection($invoices);
 }
コード例 #2
0
 /**
  * Get a collection of the entity's invoices.
  *
  * @param bool  $includePending
  * @param array $parameters
  *
  * @return \Illuminate\Support\Collection
  */
 public function invoices($includePending = false, $parameters = [])
 {
     $invoices = new Collection();
     $customer = $this->asBraintreeCustomer();
     $parameters = array_merge([TransactionSearch::customerId()->is($customer->id)], $parameters);
     $braintreeTransactions = Transaction::search($parameters);
     $subscriptionIds = [];
     foreach ($braintreeTransactions as $braintreeTransaction) {
         $subscriptionIds[] = $braintreeTransaction->subscriptionId;
     }
     $braintreeSubscriptions = BraintreeSubscription::fetch([], array_unique($subscriptionIds));
     // Here we will loop through the Braintree invoices and create our own custom Invoice
     // instances that have more helper methods and are generally more convenient to
     // work with than the plain Braintree objects are. Then, we'll return the array.
     if (!is_null($braintreeSubscriptions)) {
         foreach ($braintreeSubscriptions as $subscription) {
             if ($subscription->status == BraintreeSubscription::ACTIVE || $includePending) {
                 foreach ($subscription->transactions as $transaction) {
                     $invoices->push(new Invoice($this, $subscription, $transaction));
                 }
             }
         }
     }
     return $invoices->sortByDesc(function ($invoice) {
         return $invoice->date();
     });
 }
コード例 #3
0
ファイル: Braintree.php プロジェクト: znatali/yii2-braintree
 public function searchTransaction($params = [])
 {
     return Transaction::search($params);
 }
コード例 #4
0
 public function testHandlesPayPalAccounts()
 {
     $http = new HttpClientApi(Braintree\Configuration::$global);
     $nonce = $http->nonceForPayPalAccount(['paypal_account' => ['access_token' => 'PAYPAL_ACCESS_TOKEN']]);
     $result = Braintree\Transaction::sale(['amount' => Braintree\Test\TransactionAmounts::$authorize, 'paymentMethodNonce' => $nonce]);
     $this->assertTrue($result->success);
     $paypalDetails = $result->transaction->paypalDetails;
     $collection = Braintree\Transaction::search([Braintree\TransactionSearch::paypalPaymentId()->is($paypalDetails->paymentId), Braintree\TransactionSearch::paypalAuthorizationId()->is($paypalDetails->authorizationId), Braintree\TransactionSearch::paypalPayerEmail()->is($paypalDetails->payerEmail)]);
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($result->transaction->id, $collection->firstItem()->id);
 }
コード例 #5
0
 /**
  * @param array $filters
  * @return \Braintree\ResourceCollection
  */
 public function search(array $filters)
 {
     return Transaction::search($filters);
 }