Package xyz.tcheeric.cashu.voucher.app
Class VoucherIssuanceService
java.lang.Object
xyz.tcheeric.cashu.voucher.app.VoucherIssuanceService
Service for voucher issuance with mint-specific integration logic.
This service wraps VoucherService with additional mint-specific business logic and validations. It serves as the integration point between the mint's API and the core voucher service.
Responsibilities
- Validate mint-specific business rules (quotas, limits, permissions)
- Enforce issuance policies (max amount, expiry constraints)
- Track issuance metrics and statistics
- Provide mint-friendly API wrapper around VoucherService
Usage Example
VoucherIssuanceService service = new VoucherIssuanceService(voucherService);
IssueVoucherRequest request = IssueVoucherRequest.builder()
.issuerId("merchant123")
.unit("sat")
.amount(50000L)
.build();
IssueVoucherResponse response = service.issueVoucher(request);
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionVoucherIssuanceService(@NonNull VoucherService voucherService) Constructs a VoucherIssuanceService with default limits.VoucherIssuanceService(@NonNull VoucherService voucherService, long maxVoucherAmount, int maxExpiryDays) Constructs a VoucherIssuanceService with custom limits. -
Method Summary
Modifier and TypeMethodDescriptionintGets the maximum allowed expiry in days.longGets the maximum allowed voucher amount.issueVoucher(@NonNull IssueVoucherRequest request) Issues a new voucher with policy enforcement.
-
Constructor Details
-
VoucherIssuanceService
Constructs a VoucherIssuanceService with default limits.- Parameters:
voucherService- the underlying voucher service (must not be null)
-
VoucherIssuanceService
public VoucherIssuanceService(@NonNull @NonNull VoucherService voucherService, long maxVoucherAmount, int maxExpiryDays) Constructs a VoucherIssuanceService with custom limits.- Parameters:
voucherService- the underlying voucher service (must not be null)maxVoucherAmount- the maximum allowed voucher amount (must be positive)maxExpiryDays- the maximum allowed expiry in days (must be positive)
-
-
Method Details
-
issueVoucher
Issues a new voucher with policy enforcement.This method validates the request against mint policies before delegating to the core VoucherService.
- Parameters:
request- the voucher issuance request (must not be null)- Returns:
- the issuance response containing the voucher and token
- Throws:
IllegalArgumentException- if request violates policiesRuntimeException- if issuance fails
-
getMaxVoucherAmount
public long getMaxVoucherAmount()Gets the maximum allowed voucher amount.- Returns:
- the maximum amount
-
getMaxExpiryDays
public int getMaxExpiryDays()Gets the maximum allowed expiry in days.- Returns:
- the maximum expiry days
-