Php 条纹&x2B;单击漏斗和网钩
我最近将Webhook集成到我的stripe帐户中。 我还集成了一个clickfunnels页面。在我的登录页面触发了一个charge.successful事件之后,我希望能在我的webhook上得到一些帖子Php 条纹&x2B;单击漏斗和网钩,php,laravel,Php,Laravel,我最近将Webhook集成到我的stripe帐户中。 我还集成了一个clickfunnels页面。在我的登录页面触发了一个charge.successful事件之后,我希望能在我的webhook上得到一些帖子 <?php namespace Laravel\Cashier; use Exception; use Stripe_Event; use Stripe_Customer; use Illuminate\Routing\Controller; use Illuminate\Supp
<?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;
}
}
单击漏斗发送JSON数据而不是POST,因此您可能需要使用类似的方式从单击漏斗接收数据:
$json = file_get_contents('php://input');
$obj = json_decode($json, TRUE);
请共享集成的相关代码。webhook代码不是问题所在。我没有收到任何邮件到我的服务器。当我使用curl模拟请求时,我的webhook就可以了。它只是在stripe开发者控制台中,webhook只为ClickFunnels配置,而不是为我自己的webhook配置,用于特定的ClickFunnel事件。非常感谢,您为我解决了一个非常复杂的问题