Skip to content

Commit cd050ab

Browse files
authored
Merge pull request #188 from mwarzybok-sumoheavy/feature/SP-350-master
SP-350 Java - GET /refunds/guid/:guid
2 parents 0a1582f + 35e456e commit cd050ab

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
@@ -693,6 +693,35 @@ public Refund getRefund(String refundId) throws RefundQueryException, BitPayExce
693693
return refund;
694694
}
695695

696+
/**
697+
* Retrieve a previously made refund request on a BitPay invoice.
698+
*
699+
* @param guid The BitPay refund Guid.
700+
* @return A BitPay Refund object with the associated Refund object.
701+
* @throws RefundQueryException RefundQueryException class
702+
* @throws BitPayException BitPayException class
703+
* @since 8.7.0
704+
*/
705+
public Refund getRefundByGuid(String guid) throws RefundQueryException, BitPayException {
706+
Refund refund;
707+
708+
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
709+
params.add(new BasicNameValuePair("token", this.getAccessToken(Facade.Merchant)));
710+
711+
try {
712+
HttpResponse response = this.get("refunds/guid/" + guid, params, true);
713+
refund = new ObjectMapper().readValue(this.responseToJsonString(response), Refund.class);
714+
} catch (JsonProcessingException e) {
715+
throw new RefundQueryException(null, "failed to deserialize BitPay server response (Refund) : " + e.getMessage());
716+
} catch (BitPayException ex) {
717+
throw new RefundQueryException(ex.getStatusCode(), ex.getReasonPhrase());
718+
} catch (Exception e) {
719+
throw new RefundQueryException(null, "failed to deserialize BitPay server response (Refund) : " + e.getMessage());
720+
}
721+
722+
return refund;
723+
}
724+
696725
/**
697726
* Retrieve all refund requests on a BitPay invoice.
698727
*

0 commit comments

Comments
 (0)