/** * Retrieve a Stripe account for this mercant * * @return Stripe_Customer|boolean * @throws Stripe_Error */ public function getMerchantAccount() { if ($this->account->id) { return $this->account; } if (!$this->entity) { return false; } if (!($access_token = $this->getAccessToken())) { return false; } try { $stripe = new StripeClient(); $stripe->setAccessToken($access_token); $account = $stripe->getAccount(); if (!$account->id || isset($account->deleted)) { throw new Stripe_Error('Account does not exist or has been deleted'); } $this->account = $account; return $this->account; } catch (Stripe_Error $e) { $this->entity->setPrivateSetting('stripe_secret_key', null); $this->entity->setPrivateSetting('stripe_publishable_key', null); return false; } }