Class RedeemVoucherResponse
java.lang.Object
xyz.tcheeric.cashu.voucher.app.dto.RedeemVoucherResponse
Response DTO for voucher redemption.
This DTO indicates whether the redemption was successful and provides details about the redeemed voucher.
Usage Example
RedeemVoucherResponse response = merchantService.redeem(request);
if (response.isSuccess()) {
System.out.println("Redeemed: " + response.getAmount() + " " + response.getUnit());
// Credit customer account, etc.
} else {
System.err.println("Redemption failed: " + response.getError());
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic RedeemVoucherResponseCreates a failed redemption response.static RedeemVoucherResponseCreates a failed redemption response with error code.The amount redeemed (convenience accessor from voucher if not set directly).getUnit()The currency unit (convenience accessor from voucher if not set directly).The voucher ID (convenience accessor from voucher if not set directly).static RedeemVoucherResponsesuccess(SignedVoucher voucher) Creates a successful redemption response.
-
Constructor Details
-
RedeemVoucherResponse
public RedeemVoucherResponse()
-
-
Method Details
-
getAmount
The amount redeemed (convenience accessor from voucher if not set directly). -
getUnit
The currency unit (convenience accessor from voucher if not set directly). -
getVoucherId
The voucher ID (convenience accessor from voucher if not set directly). -
success
Creates a successful redemption response. -
failure
Creates a failed redemption response. -
failure
Creates a failed redemption response with error code.- Parameters:
errorCode- the error code (e.g., DUPLICATE_REDEMPTION)message- human-readable error description- Returns:
- failure response
-