Esempio n. 1
0
 /**
  * Handle customer discount remove action
  *
  * @param StripeEventType $event
  *
  * @throws StripeException
  */
 public function onCustomerDiscountDeleteEvent(StripeEventType $event)
 {
     $stripeDiscount = $event->getEvent()['data']['object'];
     $this->validateEventObject($stripeDiscount, StripeDiscount::STRIPE_OBJECT);
     /** @var CustomerModelInterface $customer */
     if ($customer = $this->customerManager->retrieve($stripeDiscount['customer'])) {
         if ($customer->getCoupon() == ${$stripeDiscount}['coupon']['id']) {
             $customer->setCoupon(null);
             $this->objectManager->flush($customer);
         }
     }
 }