customerId() public static method

public static customerId ( )
示例#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 = 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();
     });
 }
示例#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 = [];
     $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);
 }
 public function testHandlesEuropeBankAccounts()
 {
     $gateway = new Braintree\Gateway(['environment' => 'development', 'merchantId' => 'altpay_merchant', 'publicKey' => 'altpay_merchant_public_key', 'privateKey' => 'altpay_merchant_private_key']);
     $result = $gateway->customer()->create();
     $this->assertTrue($result->success);
     $customer = $result->customer;
     $clientApi = new HttpClientApi($gateway->config);
     $nonce = $clientApi->nonceForNewEuropeanBankAccount(["customerId" => $customer->id, "sepa_mandate" => ["locale" => "de-DE", "bic" => "DEUTDEFF", "iban" => "DE89370400440532013000", "accountHolderName" => "Bob Holder", "billingAddress" => ["streetAddress" => "123 Currywurst Way", "extendedAddress" => "Lager Suite", "firstName" => "Wilhelm", "lastName" => "Dix", "locality" => "Frankfurt", "postalCode" => "60001", "countryCodeAlpha2" => "DE", "region" => "Hesse"]]]);
     $transactionResult = $gateway->transaction()->sale(["customerId" => $customer->id, "paymentMethodNonce" => $nonce, "merchantAccountId" => "fake_sepa_ma", "amount" => 100]);
     $this->assertTrue($transactionResult->success);
     $collection = $gateway->transaction()->search([Braintree\TransactionSearch::customerId()->is($customer->id), Braintree\TransactionSearch::europeBankAccountIban()->is("DE89370400440532013000")]);
     $this->assertEquals(1, $collection->maximumCount());
     $this->assertEquals($transactionResult->transaction->id, $collection->firstItem()->id);
 }