1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Eres\SyliusIyzicoPlugin\Action; |
||||
6 | |||||
7 | use Eres\SyliusIyzicoPlugin\Bridge\IyzicoBridgeInterface; |
||||
8 | use Payum\Core\Action\ActionInterface; |
||||
9 | use Payum\Core\GatewayAwareInterface; |
||||
10 | use Payum\Core\GatewayAwareTrait; |
||||
11 | use Payum\Core\Exception\RequestNotSupportedException; |
||||
12 | use Payum\Core\Request\Convert; |
||||
13 | use Sylius\Component\Core\Model\PaymentInterface; |
||||
14 | |||||
15 | |||||
16 | class ConvertPaymentAction implements ActionInterface, GatewayAwareInterface |
||||
17 | { |
||||
18 | use GatewayAwareTrait; |
||||
19 | |||||
20 | public function execute($request): void |
||||
21 | { |
||||
22 | RequestNotSupportedException::assertSupports($this, $request); |
||||
23 | |||||
24 | /** @var PaymentInterface $payment */ |
||||
25 | $payment = $request->getSource(); |
||||
26 | |||||
27 | $order = $payment->getOrder(); |
||||
28 | |||||
29 | $details = [ |
||||
30 | 'iyzico_id' => $order->getId(), |
||||
31 | 'iyzico_currency_code' => $order->getCurrencyCode(), |
||||
0 ignored issues
–
show
Bug
introduced
by
![]() |
|||||
32 | 'iyzico_order_number' => $order->getNumber(), |
||||
33 | 'iyzico_total' => $order->getTotal() / 100, |
||||
34 | 'iyzico_local_code' => explode("_", $order->getLocaleCode())[0], |
||||
0 ignored issues
–
show
The method
getLocaleCode() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
35 | 'iyzico_target_url' => $request->getToken()->getTargetUrl(), |
||||
36 | 'iyzico_shipping_address' => [ |
||||
37 | "firstname" => $order->getShippingAddress()->getFirstName(), |
||||
0 ignored issues
–
show
The method
getShippingAddress() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
38 | "lastname" => $order->getShippingAddress()->getLastName(), |
||||
39 | "country_code" => $order->getShippingAddress()->getCountryCode(), |
||||
40 | "city" => $order->getShippingAddress()->getCity(), |
||||
41 | "street" => $order->getShippingAddress()->getStreet(), |
||||
42 | "postcode" => $order->getShippingAddress()->getPostcode(), |
||||
43 | ], |
||||
44 | 'iyzico_billing_address' => [ |
||||
45 | 'firstname' => $order->getBillingAddress()->getFirstName(), |
||||
0 ignored issues
–
show
The method
getBillingAddress() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
46 | 'lastname' => $order->getBillingAddress()->getLastName(), |
||||
47 | 'country_code' => $order->getBillingAddress()->getCountryCode(), |
||||
48 | 'city' => $order->getBillingAddress()->getCity(), |
||||
49 | 'street' => $order->getBillingAddress()->getStreet(), |
||||
50 | 'postcode' => $order->getBillingAddress()->getPostcode(), |
||||
51 | ], |
||||
52 | 'iyzico_customer' => [ |
||||
53 | 'id' => $order->getCustomer()->getId(), |
||||
0 ignored issues
–
show
The method
getCustomer() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
54 | 'firstname' => $order->getCustomer()->getFirstName() ? $order->getCustomer()->getFirstName() : $order->getShippingAddress()->getFirstName(), |
||||
55 | 'lastname' => $order->getCustomer()->getLastName() ? $order->getCustomer()->getLastName() : $order->getShippingAddress()->getLastName(), |
||||
56 | 'phone_number' => $order->getCustomer()->getPhoneNumber() ? $order->getCustomer()->getPhoneNumber() : $order->getShippingAddress()->getPhoneNumber(), |
||||
57 | 'email' => $order->getCustomer()->getEmail(), |
||||
58 | 'ip' => $order->getCustomerIp(), |
||||
0 ignored issues
–
show
The method
getCustomerIp() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
59 | 'last_login_date' => $order->getCustomer()->getUser() ? $order->getCustomer()->getUser()->getLastLogin() : null, |
||||
60 | 'registration_date' => $order->getCustomer()->getCreatedAt(), |
||||
61 | 'identity_number' => $_ENV['APP_ENV'] === 'test' ? '74300864791' : $order->getCustomer()->getIdentityNumber(), |
||||
62 | 'country_code' => $order->getShippingAddress()->getCountryCode(), |
||||
63 | 'city' => $order->getShippingAddress()->getCity(), |
||||
64 | 'street' => $order->getShippingAddress()->getStreet(), |
||||
65 | 'postcode' => $order->getShippingAddress()->getPostcode(), |
||||
66 | ], |
||||
67 | 'iyzico_items' => array_map(function ($orderItem) { |
||||
68 | return [ |
||||
69 | 'id' => $orderItem->getId(), |
||||
70 | 'name' => $orderItem->getProductName(), |
||||
71 | 'total' => $orderItem->getTotal() / 100, |
||||
72 | 'category' => $orderItem->getProduct()->getMainTaxon() ? $orderItem->getProduct()->getMainTaxon()->getName() : "empty" |
||||
73 | ]; |
||||
74 | }, iterator_to_array($order->getItems())), |
||||
75 | 'iyzico_shipment' => array_map(function ($shipment) use ($order) { |
||||
76 | return [ |
||||
77 | 'id' => $shipment->getMethod()->getId(), |
||||
78 | 'name' => $shipment->getMethod()->getName(), |
||||
79 | 'total' => $order->getShippingTotal() / 100, |
||||
0 ignored issues
–
show
The method
getShippingTotal() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
80 | 'category' => $shipment->getMethod()->getCategory() ? $shipment->getMethod()->getCategory()->getName() : IyzicoBridgeInterface::SHIPPING_CATEGORY |
||||
81 | ]; |
||||
82 | }, iterator_to_array($order->getShipments())) |
||||
0 ignored issues
–
show
The method
getShipments() does not exist on Sylius\Component\Order\Model\OrderInterface . It seems like you code against a sub-type of said class. However, the method does not exist in Sylius\Component\Order\Model\Order . Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
![]() |
|||||
83 | ]; |
||||
84 | |||||
85 | $request->setResult($details); |
||||
86 | } |
||||
87 | |||||
88 | public function supports($request): bool |
||||
89 | { |
||||
90 | return |
||||
91 | $request instanceof Convert && |
||||
92 | $request->getSource() instanceof PaymentInterface && |
||||
93 | $request->getTo() === 'array'; |
||||
94 | } |
||||
95 | } |
||||
96 |