I've recently integrated webhooks into my stripe account. I've also integrated a clickfunnels page. After a charge.successful event has been triggered from my landing page I'm expecting to get some POST to my webhook.
<?php namespace Laravel\Cashier;
use Exception;
use Stripe_Event;
use Stripe_Customer;
use Illuminate\Routing\Controller;
use Illuminate\Support\Facades\App;
use Illuminate\Support\Facades\Request;
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
use Person;
use Order;
use OrderItem;
use Item;
class WebhookController extends Controller
{
/**
* Handle a Stripe webhook call.
*
* @return \Symfony\Component\HttpFoundation\Response
*/
public function handleWebhook()
{
$payload = $this->getJsonPayload();
try {
$var = Stripe_Event::retrieve($payload['id']);
} catch (Exception $e) {
return $e->getMessage();
}
if (!$this->eventExistsOnStripe($payload['id'])) {
return "doesn't exist onstripe";
}
$method = 'handle' . studly_case(str_replace('.', '_', $payload['type']));
if (method_exists($this, $method)) {
return $this->{$method}($payload);
} else {
return $this->missingMethod();
}
}
/**
* Verify with Stripe that the event is genuine.
*
* @param string $id
* @return bool
*/
protected function eventExistsOnStripe($id)
{
try {
return !is_null(Stripe_Event::retrieve($id));
} catch (Exception $e) {
return false;
}
}
protected function handleChargeSucceeded(array $payload)
{
return true
}
/**
* Handle a failed payment from a Stripe subscription.
*
* @param array $payload
* @return \Symfony\Component\HttpFoundation\Response
*/
protected function handleInvoicePaymentFailed(array $payload)
{
if ($this->tooManyFailedPayments($payload)) {
$billable = $this->getBillable($payload['data']['object']['customer']);
if ($billable) $billable->subscription()->cancel();
}
return new Response('Webhook Handled', 200);
}
/**
* Determine if the invoice has too many failed attempts.
*
* @param array $payload
* @return bool
*/
protected function tooManyFailedPayments(array $payload)
{
return $payload['data']['object']['attempt_count'] > 3;
}
/**
* Get the billable entity instance by Stripe ID.
*
* @param string $stripeId
* @return \Laravel\Cashier\BillableInterface
*/
protected function getBillable($stripeId)
{
return App::make('Laravel\Cashier\BillableRepositoryInterface')->find($stripeId);
}
/**
* Get the JSON payload for the request.
*
* @return array
*/
protected function getJsonPayload()
{
return (array)json_decode(Request::getContent(), true);
}
/**
* Handle calls to missing methods on the controller.
*
* @param array $parameters
* @return mixed
*/
public function missingMethod($parameters = array())
{
return new Response;
}
}
I have also put code on this link as it contains too many methods.
But this doesn't appear to be the case.
When I go to Stripe event logs I can see that only the clickfunnel webhooks were triggered and not mine.. How to fix this so I can trigger both my webhook and clickfunnels?