/**
  * Handles the event
  * @return Illuminate\Http\Response
  */
 public function handle()
 {
     try {
         $payload = $this->getPayload();
         $event = $this->gateway->event($payload['id']);
         if ($this->canBeHandled($event->type())) {
             $hook = $this->getHook($event->type());
             $hook->handle($event);
         }
         return Response::make('Hook handled successfully', 200);
     } catch (Exception $e) {
         return Response::make('Hook handled unsuccessfully: ' . $e->getMessage(), 400);
     }
 }
Beispiel #2
0
 /**
  * Creates an invoice of all pending invoice items.
  * @return Invoice
  */
 public function createInvoice($metadata = [], $payNow = true)
 {
     if (!$this->subscription) {
         throw new CashewExceptions\NoSubscriptionException();
     }
     return $this->gateway->createInvoice($this->subscription['customer_id'], $metadata, $payNow);
 }