/** * Handles the event * @param Event $event * @return void */ public function handle(Event $event) { $subscription = $this->storage->subscription($event->customer(), true); // we are not doing anything special here, // just firing the event to be handeled by the app. IlluminateEvent::fire('cashew.invoice.created', array($subscription['user_id'], $event->invoice())); }
/** * Handles the event * @param Event $event * @return void */ public function handle(Event $event) { $subscription = $this->storage->subscription($event->customer(), true); // // if user turns from trialing to active, we will make the status as active // if($subscription['status'] == 'trialing' and $event->subscription()->status() == 'active') // { // $this->storage->updateStatus($subscription['user_id'], $event->subscription()->status()); // } IlluminateEvent::fire('cashew.subscription.update', array($subscription['user_id'], $event->subscription())); }
/** * 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)); }