/** * Get the Braintree customer instance for the current user and token. * * @param string|null $nonce * @param array $options * * @return \Braintree\Customer */ protected function getBraintreeCustomer($nonce = null, array $options = []) { if (!$this->user->braintree_id) { $customer = $this->user->createAsBraintreeCustomer($nonce, $options); } else { $customer = $this->user->asBraintreeCustomer(); if ($nonce) { $this->user->updateCard($nonce); } } return $customer; }