1 | <?php |
||||||
2 | |||||||
3 | /* |
||||||
4 | * This file has been created by developers from BitBag. |
||||||
5 | * Feel free to contact us once you face any issues or want to start |
||||||
6 | * You can find more information about us on https://bitbag.io and write us |
||||||
7 | * an email on [email protected]. |
||||||
8 | */ |
||||||
9 | |||||||
10 | declare(strict_types=1); |
||||||
11 | |||||||
12 | namespace BitBag\SyliusMolliePlugin\Provider\Apple; |
||||||
13 | |||||||
14 | use BitBag\SyliusMolliePlugin\Entity\GatewayConfigInterface; |
||||||
15 | use BitBag\SyliusMolliePlugin\Resolver\ApplePayDirect\ApplePayDirectPaymentTypeResolverInterface; |
||||||
16 | use Mollie\Api\Types\PaymentMethod; |
||||||
17 | use Sylius\Component\Core\Model\PaymentInterface; |
||||||
18 | use Sylius\Component\Core\Model\PaymentMethodInterface; |
||||||
19 | use Sylius\Component\Order\Model\OrderInterface; |
||||||
20 | |||||||
21 | final class ApplePayDirectPaymentProvider implements ApplePayDirectPaymentProviderInterface |
||||||
22 | { |
||||||
23 | /** @var ApplePayDirectPaymentTypeResolverInterface */ |
||||||
24 | private $applePayDirectPaymentTypeResolver; |
||||||
25 | |||||||
26 | public function __construct(ApplePayDirectPaymentTypeResolverInterface $applePayDirectPaymentTypeResolver) |
||||||
27 | { |
||||||
28 | $this->applePayDirectPaymentTypeResolver = $applePayDirectPaymentTypeResolver; |
||||||
29 | } |
||||||
30 | |||||||
31 | public function provideApplePayPayment(OrderInterface $order, array $applePayPaymentToken): void |
||||||
32 | { |
||||||
33 | /** @var PaymentInterface $paymentMethod */ |
||||||
34 | $payment = $order->getLastPayment(); |
||||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||||
35 | /** @var PaymentMethodInterface $paymentMethod */ |
||||||
36 | $paymentMethod = $payment->getMethod(); |
||||||
37 | /** @var GatewayConfigInterface $gatewayConfig */ |
||||||
38 | $gatewayConfig = $paymentMethod->getGatewayConfig(); |
||||||
39 | |||||||
40 | if ($gatewayConfig->getMollieGatewayConfig()->isEmpty()) { |
||||||
41 | return; |
||||||
42 | } |
||||||
43 | |||||||
44 | $applePayConfig = $gatewayConfig->getMethodByName(PaymentMethod::APPLEPAY); |
||||||
0 ignored issues
–
show
The method
getMethodByName() does not exist on BitBag\SyliusMolliePlugi...\GatewayConfigInterface . Since it exists in all sub-types, consider adding an abstract or default implementation to BitBag\SyliusMolliePlugi...\GatewayConfigInterface .
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||||
45 | |||||||
46 | if (!$applePayConfig->isEnabled()) { |
||||||
47 | return; |
||||||
48 | } |
||||||
49 | |||||||
50 | $this->applePayDirectPaymentTypeResolver->resolve($applePayConfig, $payment, $applePayPaymentToken); |
||||||
51 | } |
||||||
52 | } |
||||||
53 |