2016-07-03 3 views
1

Square Up을 구현하여 API를 통해 지불 및 환불을 생성했습니다. 두 가지 구현 모두 훌륭하게 보이지만 환불은 "보류 중"으로 처리됩니다.Square Up 보류 중 환불 샘플

내 끝에서 지불을 업데이트하기 위해 Webhook을 구현하려하지만 워크 플로 작동 방법에 대한 좋은 예를 찾을 수 없습니다.

또한 각 후크를 구현하는 대신 환불 상태를 찾기 위해 X 분마다 ID별로 특정 환불을 쿼리 할 수있는 방법이 있습니까?

감사

답변

2

webhooks의 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);