我在 Laravel 5.1,条纹 api 2015-10-16
我正在尝试处理:customer.subscription.deleted 所以我覆盖了handleCustomerSubscriptionDeleted 但该方法从未被调用..(即使我在没有其他代码行的情况下返回 200 响应,条带也会记录 500 错误响应)
我正在按照文档中的说明进行路由:
Route::post('/stripe/webhook', 'WebhookController@handleWebhook');
自定义控制器:
namespace App\Http\Controllers;
use App\Abbonamento;
use Symfony\Component\HttpFoundation\Response;
use Laravel\Cashier\WebhookController as BaseController;
class WebhookController extends BaseController
{
/**
* Handle a stripe webhook.
*
* @param array $payload
* @return Response
*/
public function handleInvoicePaymentSucceeded($payload)
{
$subscription = $payload['data']['object']['subscription'];
$abbo = Abbonamento::bySubscription($subscription)->first();
if ($abbo)
{
$abbo->makeStripePayment($payload);
}
}
public function handleCustomerSubscriptionDeleted($payload)
{
$subscription = $payload['data']['object']['id'];
$abbo = Abbonamento::bySubscription($subscription)->first();
if ($abbo and $abbo->subscribed())
{
$abbo->subscription()->cancel();
}
return new Response('Webhook Handled', 200);
}
}
有人可以告诉我为什么“handleInvoicePaymentSucceeded”有效,但从未调用过“handleCustomerSubscriptionDeleted”?
问题不在于我的自定义实体“Abbonamento”,而在于为什么我总是看到错误 500 作为 customer.subscription.deleted 的条带测试环境中的返回响应,以及在 invoice.payment_succeeded 上的正常响应