Skip to content

Commit fd031ae

Browse files
authored
Merge pull request #193 from mwarzybok-sumoheavy/feature/SP-352-master
SP-352 Java - DELETE /refunds/guid/:guid
2 parents a246d45 + dda8b80 commit fd031ae

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

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

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,33 @@ public Refund cancelRefund(String refundId) throws RefundCancellationException,
897897
return refund;
898898
}
899899

900+
/**
901+
* Cancel a previously submitted refund request on a BitPay invoice.
902+
*
903+
* @param guid The refund Guid for the refund to be canceled.
904+
* @return An updated Refund Object.
905+
* @throws RefundCancellationException RefundCancellationException class
906+
* @throws BitPayException BitPayException class
907+
* @since 8.7.0
908+
*/
909+
public Refund cancelRefundByGuid(String guid) throws RefundCancellationException, BitPayException {
910+
Refund refund;
911+
912+
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
913+
params.add(new BasicNameValuePair("token", this.getAccessToken(Facade.Merchant)));
914+
915+
try {
916+
HttpResponse response = this.delete("refunds/guid/" + guid, params);
917+
refund = new ObjectMapper().readValue(this.responseToJsonString(response), Refund.class);
918+
} catch (BitPayException ex) {
919+
throw new RefundCancellationException(ex.getStatusCode(), ex.getReasonPhrase());
920+
} catch (Exception e) {
921+
throw new RefundCancellationException(null, "failed to deserialize BitPay server response (Refund) : " + e.getMessage());
922+
}
923+
924+
return refund;
925+
}
926+
900927
/**
901928
* Create a BitPay bill using the POS facade.
902929
*

0 commit comments

Comments
 (0)