2016-07-03 2 views
1

私はSquare Upを実装して、APIを通じて支払いと払い戻しを作成しました。どちらの実装もうまく見えますが、払い戻しは「保留中」となります。返済予定払い戻しサンプル

私の最終的に支払いを更新するためにウェブフックを実装しようとしていますが、ワークフローの仕組みに関する良い例が見つかりません。

また、フックを実装する代わりに払い戻しステータスを見つけるためにX分ごとに特定の払い戻しをIDでクエリする方法はありますか?

おかげ

答えて

2

ウェブフックのAPI保留、ない完成されているだけの記事の払い戻し。 retrieve transactions endpointを使用して払い戻しの状態をポーリングすることができます。このエンドポイントのこの応答には、特定のトランザクションのすべての払い戻しが含まれます。

1

ご確認ください。私はwebhookではなくstreamdataを提案します。

//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); 
関連する問題