Skip to content

Commit 35e456e

Browse files
SP-350 Java - GET /refunds/guid/:guid
1 parent 8d3ca0f commit 35e456e

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/main/java/com/bitpay/sdk/Client.java

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -637,6 +637,35 @@ public Refund getRefund(String refundId) throws RefundQueryException, BitPayExce
637637
return refund;
638638
}
639639

640+
/**
641+
* Retrieve a previously made refund request on a BitPay invoice.
642+
*
643+
* @param guid The BitPay refund Guid.
644+
* @return A BitPay Refund object with the associated Refund object.
645+
* @throws RefundQueryException RefundQueryException class
646+
* @throws BitPayException BitPayException class
647+
* @since 8.7.0
648+
*/
649+
public Refund getRefundByGuid(String guid) throws RefundQueryException, BitPayException {
650+
Refund refund;
651+
652+
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
653+
params.add(new BasicNameValuePair("token", this.getAccessToken(Facade.Merchant)));
654+
655+
try {
656+
HttpResponse response = this.get("refunds/guid/" + guid, params, true);
657+
refund = new ObjectMapper().readValue(this.responseToJsonString(response), Refund.class);
658+
} catch (JsonProcessingException e) {
659+
throw new RefundQueryException(null, "failed to deserialize BitPay server response (Refund) : " + e.getMessage());
660+
} catch (BitPayException ex) {
661+
throw new RefundQueryException(ex.getStatusCode(), ex.getReasonPhrase());
662+
} catch (Exception e) {
663+
throw new RefundQueryException(null, "failed to deserialize BitPay server response (Refund) : " + e.getMessage());
664+
}
665+
666+
return refund;
667+
}
668+
640669
/**
641670
* Retrieve all refund requests on a BitPay invoice.
642671
*

0 commit comments

Comments
 (0)