使用Java的WebHook示例

时间:2019-01-22 09:49:15

标签: payment-gateway flutterwave

我的Webhook被调用,但是正在获取的数据被加密。根据{{​​3}}此处的文档,期望收到json消息,但是却得到了

id=64883&txRef=HJDVXUSEMO&flwRef=N%2FA&orderRef=URF_1516263337305_8473935&paymentPlan=&createdAt=2018-01-18T08%3A15%3A37.000Z&amount=12.819223403930664&charged_amount=13.08&status=pending&IP=%3A%3Affff%3A127.0.0.1&currency=USD&customer%5Bid%5D=12569&customer%5Bphone%5D=&customer%5BfullName%5D=solodriver%20KESO4&customer%5Bcustomertoken%5D=&customer%5Bemail%5D=email%40solo.com&customer%5BcreatedAt%5D=2018-01-18T08%3A15%3A37.000Z&customer%5BupdatedAt%5D=2018-01-18T08%3A15%3A37.000Z&customer%5BdeletedAt%5D=&customer%5BAccountId%5D=957&entity%5Bcard6%5D=424242&entity%5Bcard_last4%5D=4242.

我在HttpServlet中使用此代码

private static JSONObject getBody(HttpServletRequest request) throws 
IOException {

String jb = IOUtils.toString(request.getReader());
AppConstants.logger("JB:" + jb);
try 
    return HTTP.toJSONObject(jb);
catch (JSONException e) 
    // crash and burn
    throw new IOException("Error parsing JSON request string");
}

如何获得这种格式?

{
"id": "8368",
"txRef": "rave-checkout-1499791631",
"flwRef": "N/A",
"createdAt": "2017-07-11T16:47:39.000Z",
"amount": "9000",
"charged_amount": "9152.5",
"status": "pending",
"IP": "154.120.106.151",
"currency": "NGN",
"customer[id]": "380",
"customer[phone]": "",
"customer[fullName]": "Anonymous customer",
"customer[customertoken]": "",
"customer[email]": "user@example.com",
"customer[createdAt]": "2017-05-09T18:32:52.000Z",
"customer[updatedAt]": "2017-05-09T18:32:52.000Z",
"customer[deletedAt]": "customer[AccountId]",
"entity[card6]": "543889",
"entity[card_last4]": "0229"
}

2 个答案:

答案 0 :(得分:0)

根据您提供的文档链接:

  

Webhook数据默认以表单编码发送,但是您可以   在信息中心上的Webhook设置页面上进行配置,以发送   请求改为JSON。

因此,我将登录到仪表板并在此处配置设置。我没有Flutterwave登录名,所以不知道设置是什么样子

答案 1 :(得分:0)

@Matt Freake, 你是对的。

您可以做的另一件事是,在收到事件通知后,进行URL解码,您应该获得整洁的字符串