php - 无法解析 razropay 的 webhook
问题描述
webhook ping 成功,但我无法解析它,我花了 4 个小时仍然没有运气,我尝试了所有方法但仍然失败,我只是不知道为什么会发生这种情况,我已经将它用于 stripe webhook,它有效,但这适用于剃刀工资
以下是我在 webhook 上收到的标题和响应:来源:https ://webhook.site/
标头
connection close
accept-encoding gzip
x-razorpay-signature f0087994b59ee5ec1b1828a87f794c89bb398033a428bb79971875e5f295322e
x-razorpay-event-id Gb5kMCdcAZ8jJ8
request-id Gb5kMCdcAZ8jJ8
content-type application/json
content-length 1053
user-agent Razorpay-Webhook/v1
host webhook.site
原始内容
{
"entity": "event",
"account_id": "acc_DOXUp08NQX6Sr9",
"event": "payment.captured",
"contains": [
"payment"
],
"payload": {
"payment": {
"entity": {
"id": "pay_Gb5kLMBMjON6So",
"entity": "payment",
"amount": 1132,
"currency": "USD",
"base_amount": 82174,
"base_currency": "INR",
"status": "captured",
"order_id": "order_Gb5kEv5w8pveU5",
"invoice_id": null,
"international": false,
"method": "card",
"amount_refunded": 0,
"refund_status": null,
"captured": true,
"description": null,
"card_id": "card_Gb5kLUZEfKlXF4",
"card": {
"id": "card_Gb5kLUZEfKlXF4",
"entity": "card",
"name": "231231231231231231",
"last4": "8826",
"network": "Visa",
"type": "prepaid",
"issuer": "SBIN",
"international": false,
"emi": false,
"sub_type": "business"
},
"bank": null,
"wallet": null,
"vpa": null,
"email": "niteshkmr366@gmail.com",
"contact": "+918169179450",
"notes": {
"ytsubme_account_email": "niteshkmr366@gmail.com",
"phone": "8169179450"
},
"fee": 1644,
"tax": 0,
"error_code": null,
"error_description": null,
"error_source": null,
"error_step": null,
"error_reason": null,
"acquirer_data": {
"auth_code": null
},
"created_at": 1613226609
}
}
},
"created_at": 1613226609
}
我的 PHP 代码:
<?
$data = file_get_contents('php://input');
$obj = json_decode($data);
file_put_contents('data.txt',$data);
//data.txt file is still empty
?>
解决方案
感谢@IMSoP,在您担心解析它之前提醒我理清为什么它是空的。
我的 webhook 正在 ping 到需要登录的 URL,)更多信息:SESSIONS:即如果没有设置会话,它会将它们重定向到 / 页面。)
由于我得到了空数据,对此我感到很愚蠢。
推荐阅读
- c# - 无法转换 LINQ 表达式中的 OData $top 查询,将使用 EF Core 和 .NET Core 2.2 在本地进行评估
- azure-devops - 关于新的 azure 多阶段管道的电子邮件通知
- r - 如何加快 r data.table 中的查找和求和函数
- asp.net-core - 通过 HTTPS 的本地安全机构进程 (lsass) 繁重的 CPU 负载
- c# - 理解接口 V 类
- php - 一个 php 测试应用程序的 Kubernetes 部署
- mongodb - Golang mongo 驱动性能
- c# - 在线程中使用 AWAIT 时,Thread.Abort() 不起作用。C#
- python - 根据 Python 中的键列表动态创建 json
- java - 如何实时获取executor的队列大小