/** * Handles the webhook call * @param Event $event * @return void */ public function handle(Event $event) { $subscription = $this->storage->subscription($event->customer(), true); Cashew::user($subscription['user_id']); if ($event->failedMoreThan(Config::get('cashew::attempts'))) { Cashew::expireCustomer($event->customer()); IlluminateEvent::fire('cashew.user.expire', array($subscription['user_id'])); } else { IlluminateEvent::fire('cashew.payment.fail', array($subscription['user_id'], $event->invoice())); } }
/** * Handles the event * @param Event $event * @return void */ public function handle(Event $event) { $invoice = $event->invoice(); $subscription = $this->storage->subscription($event->customer(), true); Cashew::user($subscription['user_id']); if ($invoice->total() > 0.0) { if ($invoice instanceof StorableInvoice) { $invoice->store($subscription['user_id']); // store invoice } if (Cashew::hasCard()) { $this->storage->updateStatus($subscription['user_id'], 'active'); // make subscription active } } IlluminateEvent::fire('cashew.payment.success', array($subscription['user_id'], $invoice)); }