Skip to content

Commit dda8b80

Browse files
SP-352 Java - DELETE /refunds/guid/:guid
1 parent 8d3ca0f commit dda8b80

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
@@ -771,6 +771,33 @@ public Refund cancelRefund(String refundId) throws RefundCancellationException,
771771
return refund;
772772
}
773773

774+
/**
775+
* Cancel a previously submitted refund request on a BitPay invoice.
776+
*
777+
* @param guid The refund Guid for the refund to be canceled.
778+
* @return An updated Refund Object.
779+
* @throws RefundCancellationException RefundCancellationException class
780+
* @throws BitPayException BitPayException class
781+
* @since 8.7.0
782+
*/
783+
public Refund cancelRefundByGuid(String guid) throws RefundCancellationException, BitPayException {
784+
Refund refund;
785+
786+
final List<BasicNameValuePair> params = new ArrayList<BasicNameValuePair>();
787+
params.add(new BasicNameValuePair("token", this.getAccessToken(Facade.Merchant)));
788+
789+
try {
790+
HttpResponse response = this.delete("refunds/guid/" + guid, params);
791+
refund = new ObjectMapper().readValue(this.responseToJsonString(response), Refund.class);
792+
} catch (BitPayException ex) {
793+
throw new RefundCancellationException(ex.getStatusCode(), ex.getReasonPhrase());
794+
} catch (Exception e) {
795+
throw new RefundCancellationException(null, "failed to deserialize BitPay server response (Refund) : " + e.getMessage());
796+
}
797+
798+
return refund;
799+
}
800+
774801
/**
775802
* Create a BitPay bill using the POS facade.
776803
*

0 commit comments

Comments
 (0)