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(); |
|
|
|
|
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); |
|
|
|
|
45
|
|
|
|
46
|
|
|
if (!$applePayConfig->isEnabled()) { |
47
|
|
|
return; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
$this->applePayDirectPaymentTypeResolver->resolve($applePayConfig, $payment, $applePayPaymentToken); |
51
|
|
|
} |
52
|
|
|
} |
53
|
|
|
|