/** * Handle card delete event * * @param StripeEventType $event * * @throws StripeException */ public function onCardDeleteEvent(StripeEventType $event) { $stripeCard = $event->getEvent()['data']['object']; if ($stripeCard['object'] != StripeCard::STRIPE_OBJECT) { throw new StripeException(sprintf('Invalid object type "%s". Expected type is "%s".', $stripeCard['object'], StripeCard::STRIPE_OBJECT)); } $this->cardManager->remove($stripeCard, true); }
/** * Handle invoice events * * @param StripeEventType $event * @throws StripeException */ public function onInvoiceEvent(StripeEventType $event) { $stripeInvoice = $event->getEvent()['data']['object']; if ($stripeInvoice['object'] != StripeInvoice::STRIPE_OBJECT) { throw new StripeException(sprintf('Invalid object type "%s". Expected type is "%s".', $stripeInvoice['object'], StripeInvoice::STRIPE_OBJECT)); } $this->invoiceManager->save($stripeInvoice, true); }
/** * Handle subscription delete event * * @param StripeEventType $event * * @throws StripeException */ public function onSubscriptionDeleteEvent(StripeEventType $event) { $stripeSubscription = $event->getEvent()['data']['object']; if ($stripeSubscription['object'] != StripeSubscription::STRIPE_OBJECT) { throw new StripeException(sprintf('Invalid object type "%s". Expected type is "%s".', $stripeSubscription['object'], StripeSubscription::STRIPE_OBJECT)); } $this->subscriptionManager->remove($stripeSubscription['id'], true); }
/** * 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); } } }