예제 #1
0
 /**
  * Retrieve a Stripe customer account
  * @return Stripe_Customer|boolean
  * @throws Stripe_Error
  */
 public function getCustomerAccount()
 {
     if ($this->account->id) {
         return $this->account;
     }
     try {
         $customer_id = $this->getCustomerId();
         if (!$customer_id) {
             throw new Stripe_Error('No customer id');
         }
         $stripe = new StripeClient();
         $account = $stripe->getCustomer($customer_id);
         if (!$account->id || isset($account->deleted)) {
             throw new Stripe_Error('Customer does not exist or has been deleted');
         }
         return $account;
     } catch (Stripe_Error $e) {
         $this->user->removePrivateSetting('stripe_customer_id');
         error_log($e->getMessage());
         return $this->getCustomerAccount();
     }
 }