channel->request(MessageType::PurchaseVoucher, ['einloesecode' => $redemptionCode]); } /** * Validates a promo voucher (Aktionsgutschein) for a travel and participant price. Promo * vouchers are absolute discounts, per person ("P") or per booking ("B") as pro_buchung_person * says. * * @throws ApiClientException */ public function validatePromoVoucher(string $promoCode, int $travelId, float $participantPrice): Notification|PromoVoucher { return $this->channel->request(MessageType::PromoVoucher, [ 'aktionsgutschein' => $promoCode, 'idreise' => $travelId, 'preis' => number_format($participantPrice, 2, ',', ''), ]); } /** * Fetches the voucher designs on sale and the amount bounds. * * @throws ApiClientException */ public function getVoucherTemplates(): Notification|VoucherTemplates { return $this->channel->request(MessageType::VoucherTemplates); } /** * Fetches the payment methods offered for voucher purchases. * * @return list|Notification * * @throws ApiClientException */ public function getVoucherPaymentMethods(): array|Notification { return $this->channel->request(MessageType::VoucherPaymentMethods); } /** * Renders the PDF preview of a voucher design with the entered data. * * @throws ApiClientException */ public function getVoucherPreview(VoucherPurchaseDto $voucherPurchaseDto): Notification|VoucherPreview { return $this->channel->request(MessageType::VoucherPreview, $this->voucherSalePayloadBuilder->buildPreviewPayload($voucherPurchaseDto)); } /** * Dry run of a voucher purchase: full validation, nothing is issued. * * Every HINWEIS is a rejection on this path, including 650 (missing address data), so the * result must not be judged by Notification::isError(). * * @throws ApiClientException */ public function createVoucherSaleInquiry(VoucherPurchaseDto $voucherPurchaseDto): Notification|VoucherSaleResponse { return $this->sendVoucherSale($voucherPurchaseDto, Constants::BOOKING_TYPE_INQUIRY); } /** * Buys the voucher. BusPro mails it to the buyer once the payment has arrived. * * Every HINWEIS is a rejection on this path, including 650. * * @throws ApiClientException */ public function createVoucherSale(VoucherPurchaseDto $voucherPurchaseDto): Notification|VoucherSaleResponse { return $this->sendVoucherSale($voucherPurchaseDto, Constants::BOOKING_TYPE_BOOKING); } /** * @throws ApiClientException */ private function sendVoucherSale(VoucherPurchaseDto $voucherPurchaseDto, string $saleType): Notification|VoucherSaleResponse { return $this->channel->request(MessageType::VoucherSale, $this->voucherSalePayloadBuilder->buildSalePayload($voucherPurchaseDto, $saleType)); } }