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\PaymentProcessing; |
||
13 | |||
14 | use BitBag\SyliusMolliePlugin\Entity\SubscriptionInterface; |
||
15 | use BitBag\SyliusMolliePlugin\Factory\MollieSubscriptionGatewayFactory; |
||
16 | use BitBag\SyliusMolliePlugin\Request\Api\CancelRecurringSubscription; |
||
17 | use Payum\Core\Payum; |
||
18 | use Sylius\Component\Core\Model\PaymentMethodInterface; |
||
19 | use Symfony\Component\HttpFoundation\Session\Session; |
||
20 | |||
21 | final class CancelRecurringSubscriptionProcessor implements CancelRecurringSubscriptionProcessorInterface |
||
22 | { |
||
23 | /** @var Payum */ |
||
24 | private $payum; |
||
25 | |||
26 | /** @var Session */ |
||
27 | private $session; |
||
28 | |||
29 | public function __construct(Payum $payum, Session $session) |
||
30 | { |
||
31 | $this->payum = $payum; |
||
32 | $this->session = $session; |
||
33 | } |
||
34 | |||
35 | /** |
||
36 | * {@inheritdoc} |
||
37 | */ |
||
38 | public function process(SubscriptionInterface $subscription): void |
||
39 | { |
||
40 | $payment = $subscription->getOrder()->getLastPayment(); |
||
41 | |||
42 | if (null === $payment) { |
||
43 | return; |
||
44 | } |
||
45 | |||
46 | /** @var PaymentMethodInterface $paymentMethod */ |
||
47 | $paymentMethod = $payment->getMethod(); |
||
48 | |||
49 | if (null === $paymentMethod->getGatewayConfig() || |
||
50 | MollieSubscriptionGatewayFactory::FACTORY_NAME !== $paymentMethod->getGatewayConfig()->getFactoryName() |
||
0 ignored issues
–
show
|
|||
51 | ) { |
||
52 | return; |
||
53 | } |
||
54 | |||
55 | $gateway = $this->payum->getGateway($paymentMethod->getGatewayConfig()->getGatewayName()); |
||
56 | |||
57 | $gateway->execute(new CancelRecurringSubscription($subscription)); |
||
58 | } |
||
59 | } |
||
60 |
This function has been deprecated. The supplier of the function has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the function will be removed and what other function to use instead.