'测试webhook错误:超时'在条纹上

时间:2016-07-07 20:54:35

标签: php stripe-payments webhooks

我的网络应用使用Stripe进行付款处理。我在Stripe中有一个名为mysite.com/callback的webhook。当我尝试测试webhook时,它会超时。订单通过我的/充电路线成功处理并显示在Stripe中。

我/回调路线有什么问题?它不会更新数据库中的数据。

以下是回调路线:

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']))]);

});

1 个答案:

答案 0 :(得分:0)

看起来像Laravel,看起来该函数没有返回任何内容,因此Stripe没有得到回应。我怀疑你想在那里做这样的事情:

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

注意:Partly stolen from this answer...