简体   繁体   English

Stripe上的“测试webhook错误:超时”

[英]'Test webhook error: Timed out' on Stripe

My web app uses Stripe for payment processing. 我的Web应用程序使用Stripe进行付款处理。 I have a webhook in Stripe calling mysite.com/callback. 我在Stripe中有一个Webhook,名为mysite.com/callback。 When I try to test the webhook, it times out. 当我尝试测试网络挂钩时,​​它超时。 Orders process successfully through my /charge route and show up in Stripe. 订单通过我的/ charge路线成功处理并显示在Stripe中。

What is wrong with my /callback route? 我的/ callback路由有什么问题? It doesn't update the data in the DB. 它不会更新数据库中的数据。

Here is the callback route: 这是回调路由:

Route::post('/callback', function () {

http_response_code(200);
  $amount=array('1900'=>array('name'=>'small','period'=>"+1 month",'visits'=>1000),
                '7900'=>array('name'=>'medium','period'=>"+3 month",'visits'=>10000),
                '14900'=>array('name'=>'large','period'=>"+6 month",'visits'=>25000),
                '39900'=>array('name'=>'xlarge','period'=>"+12 month",'visits'=>100000),
                '79900'=>array('name'=>'enterprise','period'=>"+24 month",'visits'=>500000),
            );

$input =Input::all();

$email = $input["data"]["object"]["source"]["name"];
$stripe_plan=$amount[$input["data"]["object"]['amount']]['name'];

$user = DB::table('users')
                    ->where('email',$email)
                    ->select('remaining_visits','subscription_ends_at')->first();

$date=$user->subscription_ends_at;
$remaining_visits=$user->remaining_visits+$amount[$input["data"]["object"]['amount']]['visits'];

$affectedRows=User::where('email',$email)->update(['secret' => uniqid(),'stripe_active' => 1,'stripe_plan'=>$stripe_plan,'remaining_visits'=>$remaining_visits,'subscription_ends_at'=> date( 'Y-m-d H:i:s', strtotime($date.$amount[$input["data"]["object"]['amount']]['period']))]);

});

That looks like Laravel, and it looks like that function doesn't return anything, so Stripe is not getting a response. 看起来像Laravel,并且看起来该函数没有返回任何内容,因此Stripe没有得到响应。 I suspect you want to do something like this in there: 我怀疑您想在此处执行以下操作:

try {
    return response("", 200);
} finally {
    // All the other fun stuff you're doing after you respond
}

Note: Partly stolen from this answer... 注意: 此答案部分被盗...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM