Webhook功能无法执行

时间:2019-08-03 17:11:45

标签: laravel webhooks

我有此代码可在付款时向用户添加用户信用

class Webhook extends Controller
{
    public function rave(Request $request){
if(Request::input('pay.type') == "credits" and Request::get('price') == 500 ){

 $credit = Credit::firstOrCreate(['user_id' => Auth::getUser()->id]);
$credit->increment('amount', 600);
$credit->refresh();

 }

}
}

当我将它作为附加到按钮的ajax调用尝试时,该代码运行良好,但即使使用ngrok检查时返回200 ok,它也不会与返回的webhook响应一起执行。 可能是什么原因?

1 个答案:

答案 0 :(得分:1)

您实际上没有返回任何东西。我不确定您希望得到什么样的响应,但是请尝试在if块中返回一些内容,看看是否会在正确的方向推动您。

# Read the entire file content as a [byte[]] array.
# Note: Use PowerShell *Core* syntax. 
# In *Windows PowerShell*, replace `-AsByteStream` with `-Encoding Byte`
# `-Raw` ensures that the file is efficiently read as [byte[]] array at once.
$byteArray = Get-Content C:\OldFile.exe -Raw -AsByteStream

# Convert the byte array to a single-line "byte string", 
# where the whitespace-separated tokens are the hex. encoding of a single byte.
# If you want to guaranteed that even byte values < 0x10 are represented as
# *pairs* of hex digits, use 'X2' instead.
$byteString = $byteArray.ForEach('ToString', 'X') -join ' '

# Perform the replacement.
# Note that since the string is guaranteed to be single-line, 
# inline option `(?s)` isn't needed.
# Also note how the hex-digit sequences representing bytes are also separated
# by spaces in the search and replacement strings.
$byteString = $byteString -replace '\b12 34 56\b(.*)', 'FF FF FF$1'

# Convert the byte string back to a [byte[]] array, and save it to the
# target file.
# Note how the array is passed as an *argument*, via parameter -Value, 
# rather than via the pipeline, because that is much faster.
# Again, in *Windows PowerShell* use `-Encoding Byte` instead of `-AsByteStream`.
[byte[]] $newByteArray = -split $byteString -replace '^', '0x'
Set-Content "C:\NewFile.exe" -AsByteStream -Value $newByteArray
相关问题