feat: improved promotional and purchase vouchers
This commit is contained in:
@@ -9,17 +9,11 @@ use App\Form\Service\Abstract\AbstractParticipantFieldHandler;
|
||||
use App\Service\VoucherValidationService;
|
||||
|
||||
/**
|
||||
* Handles processing and validation of purchase voucher codes for booking participants.
|
||||
* Handles purchase voucher code field processing.
|
||||
*
|
||||
* This handler validates purchase vouchers (including goodwill vouchers) via the BPN API
|
||||
* and provides immediate feedback to users about voucher validity and remaining balance.
|
||||
* Purchase vouchers reduce the booking price by their remaining balance and support
|
||||
* partial redemption.
|
||||
*
|
||||
* Validation includes:
|
||||
* - Voucher existence check
|
||||
* - Remaining balance verification (zero-balance vouchers are reported as invalid)
|
||||
* - Real-time API validation with 15-minute caching
|
||||
* Detects goodwill (Kulanz) vouchers and marks them for special XML handling.
|
||||
* Goodwill vouchers must be sent as <aktionscode> per participant, not aggregated
|
||||
* in <gutscheine> collection. Validation is performed by PurchaseVoucher constraint.
|
||||
*
|
||||
* Dependencies: None (purchase vouchers don't require price calculation)
|
||||
*/
|
||||
@@ -62,23 +56,17 @@ class ParticipantPurchaseVoucherFieldHandler extends AbstractParticipantFieldHan
|
||||
return;
|
||||
}
|
||||
|
||||
// Validate voucher via API
|
||||
// Validate voucher to check if it's goodwill type
|
||||
$result = $this->voucherValidationService->validatePurchaseVoucher($voucherCode);
|
||||
|
||||
if (true === $result->isValid && null !== $result->voucher) {
|
||||
$participant->addNotification(
|
||||
'success',
|
||||
sprintf(
|
||||
'Gutschein gültig: %s (Restwert: %.2f €)',
|
||||
$result->voucher->type,
|
||||
$result->voucher->remainingBalance
|
||||
)
|
||||
);
|
||||
} else {
|
||||
$participant->addNotification(
|
||||
'error',
|
||||
sprintf('Gutschein ungültig: %s', $result->errorMessage ?? 'Unbekannter Fehler')
|
||||
);
|
||||
// Only process valid vouchers
|
||||
if (false === $result->isValid || null === $result->voucher) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Check if this is a goodwill voucher
|
||||
if (true === $result->voucher->isGoodwill()) {
|
||||
$participant->hasGoodwillVoucher = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user