Exemplo n.º 1
0
 public function syncSubscription(Subscription $subscription)
 {
     $user = $subscription->getUserEntity();
     $customer = $this->em->getRepository(Customer::getEntityClassByUser($user))->findOneBy(['user' => $user]);
     $stripeCustomer = $this->getStripeCustomer($customer);
     try {
         $ss = $stripeCustomer->subscriptions->retrieve($subscription->getStripeId());
         $subscription->syncStripeData($ss);
     } catch (Error\InvalidRequest $e) {
         if (404 === $e->getHttpStatus()) {
             $subscription->stripeReset();
         }
     }
     $this->em->flush($subscription);
     return $subscription;
 }
 public function getUserEntity()
 {
     $this->__load();
     return parent::getUserEntity();
 }