/
mistercode
/
calculate-price
Обзор
Документация
Войти
/
mistercode
/
calculate-price
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/Service/PaymentService.php
27 строк
806 B
codefinecode
Tests (with AppTestFixtures), some fixes
09 фев 2025, 13:12
09 фев 2025, 13:12
f6fae59
Код
Авторство
О чём код?
<?php namespace App\Service; use App\Service\Payment\PaymentProcessorFactory; use App\Service\PriceCalculatorService; class PaymentService { private PaymentProcessorFactory $factory; private PriceCalculatorService $calculator; public function __construct( PaymentProcessorFactory $factory, PriceCalculatorService $calculator ) { $this->factory = $factory; $this->calculator = $calculator; } public function processPayment(int $productId, string $taxNumber, ?string $couponCode, string $processorName): array { $priceDetails = $this->calculator->calculate($productId, $taxNumber, $couponCode); $processor = $this->factory->getProcessor($processorName); return $processor->process($priceDetails['final_price']); } }