Class RedeemVoucherResponse

java.lang.Object
xyz.tcheeric.cashu.voucher.app.dto.RedeemVoucherResponse

public class RedeemVoucherResponse extends Object
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 Details

    • RedeemVoucherResponse

      public RedeemVoucherResponse()
  • Method Details

    • getAmount

      public Long getAmount()
      The amount redeemed (convenience accessor from voucher if not set directly).
    • getUnit

      public String getUnit()
      The currency unit (convenience accessor from voucher if not set directly).
    • getVoucherId

      public String getVoucherId()
      The voucher ID (convenience accessor from voucher if not set directly).
    • success

      public static RedeemVoucherResponse success(SignedVoucher voucher)
      Creates a successful redemption response.
    • failure

      public static RedeemVoucherResponse failure(String errorMessage)
      Creates a failed redemption response.
    • failure

      public static RedeemVoucherResponse failure(String errorCode, String message)
      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