我已经实施了Square Up来通过API创建付款和退款。两种实现看起来都不错,但退款是“待定”。
我正在尝试实施一个webhook来更新我的付款,但我找不到工作流应该如何运作的好例子。
此外,有没有办法每隔X分钟通过ID查询特定退款以查找退款状态而不是实施挂钩?
由于
答案 0 :(得分:2)
webhooks API仅发布已完成但尚未处理的退款。您可以使用retrieve transactions endpoint轮询退款状态。此端点的此响应包括给定事务的所有退款。
答案 1 :(得分:1)
请检查一下。我建议使用streamdata而不是webhook。
//Create refunds
var client = new RestClient("https://connect.squareup.com/v2/locations/{{location_id}}/transactions/{{transaction_id}}/refund");
var request = new RestRequest(Method.POST);
request.AddHeader("postman-token", "");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("content-type", "application/json");
request.AddHeader("authorization", "Bearer {{access_token}}");
request.AddParameter("application/json", "{\n \"idempotency_key\": \"YOUR_IDEMPOTENCY_KEY\",\n \"tender_id\": \"TENDER_ID\",\n \"reason\": \"a reason\",\n \"amount_money\": {\n \"amount\": 100,\n \"currency\": \"USD\"\n }\n}", ParameterType.RequestBody);
IRestResponse response = client.Execute(request);
//List refunds
var client = new RestClient("https://connect.squareup.com/v2/locations/{{location_id}}/refunds");
var request = new RestRequest(Method.GET);
request.AddHeader("postman-token", "");
request.AddHeader("cache-control", "no-cache");
request.AddHeader("authorization", "Bearer {{access_token}}");
IRestResponse response = client.Execute(request);