25
25
use Payum \Core \Security \GenericTokenFactoryAwareInterface ;
26
26
use Payum \Core \Security \GenericTokenFactoryInterface ;
27
27
use Payum \Core \Security \TokenInterface ;
28
+ use Sylius \Bundle \PayumBundle \Provider \PaymentDescriptionProviderInterface ;
28
29
use Sylius \Component \Core \Model \CustomerInterface ;
29
30
use Sylius \Component \Core \Model \OrderInterface ;
30
31
use Sylius \Component \Core \Model \OrderItemInterface ;
32
+ use Sylius \Component \Core \Model \PaymentInterface ;
31
33
use Webmozart \Assert \Assert ;
32
34
33
35
final class CaptureAction implements ActionInterface, ApiAwareInterface, GenericTokenFactoryAwareInterface, GatewayAwareInterface
@@ -37,12 +39,18 @@ final class CaptureAction implements ActionInterface, ApiAwareInterface, Generic
37
39
/** @var OpenPayUBridgeInterface */
38
40
private $ openPayUBridge ;
39
41
42
+ /** @var PaymentDescriptionProviderInterface */
43
+ private $ paymentDescriptionProvider ;
44
+
40
45
/** @var GenericTokenFactoryInterface */
41
46
private $ tokenFactory ;
42
47
43
- public function __construct (OpenPayUBridgeInterface $ openPayUBridge )
44
- {
48
+ public function __construct (
49
+ OpenPayUBridgeInterface $ openPayUBridge ,
50
+ PaymentDescriptionProviderInterface $ paymentDescriptionProvider
51
+ ) {
45
52
$ this ->openPayUBridge = $ openPayUBridge ;
53
+ $ this ->paymentDescriptionProvider = $ paymentDescriptionProvider ;
46
54
}
47
55
48
56
/**
@@ -67,12 +75,14 @@ public function execute($request): void
67
75
{
68
76
RequestNotSupportedException::assertSupports ($ this , $ request );
69
77
$ model = $ request ->getModel ();
78
+ /** @var PaymentInterface $payment */
79
+ $ payment = $ request ->getFirstModel ();
70
80
/** @var OrderInterface $orderData */
71
- $ order = $ request -> getFirstModel () ->getOrder ();
81
+ $ order = $ payment ->getOrder ();
72
82
73
83
/** @var TokenInterface $token */
74
84
$ token = $ request ->getToken ();
75
- $ payUdata = $ this ->prepareOrder ($ token , $ order );
85
+ $ payUdata = $ this ->prepareOrder ($ token , $ order, $ payment );
76
86
77
87
$ result = $ this ->openPayUBridge ->create ($ payUdata );
78
88
@@ -116,7 +126,7 @@ public function supports($request): bool
116
126
&& $ request ->getModel () instanceof ArrayObject;
117
127
}
118
128
119
- private function prepareOrder (TokenInterface $ token , OrderInterface $ order ): array
129
+ private function prepareOrder (TokenInterface $ token , OrderInterface $ order, PaymentInterface $ payment ): array
120
130
{
121
131
$ notifyToken = $ this ->tokenFactory ->createNotifyToken ($ token ->getGatewayName (), $ token ->getDetails ());
122
132
$ payUdata = [];
@@ -125,7 +135,7 @@ private function prepareOrder(TokenInterface $token, OrderInterface $order): arr
125
135
$ payUdata ['notifyUrl ' ] = $ notifyToken ->getTargetUrl ();
126
136
$ payUdata ['customerIp ' ] = $ order ->getCustomerIp ();
127
137
$ payUdata ['merchantPosId ' ] = OpenPayU_Configuration::getMerchantPosId ();
128
- $ payUdata ['description ' ] = $ order -> getNumber ( );
138
+ $ payUdata ['description ' ] = $ this -> paymentDescriptionProvider -> getPaymentDescription ( $ payment );
129
139
$ payUdata ['currencyCode ' ] = $ order ->getCurrencyCode ();
130
140
$ payUdata ['totalAmount ' ] = $ order ->getTotal ();
131
141
/** @var CustomerInterface $customer */
0 commit comments