Passed
Pull Request — master (#23)
by Volodymyr
05:31
created

SecurityInvoice::mapRefundOrderItems()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 34

Duplication

Lines 34
Ratio 100 %

Importance

Changes 0
Metric Value
dl 34
loc 34
rs 9.376
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
/**
4
 * MIT License
5
 * Use of this software requires acceptance of the Evaluation License Agreement. See LICENSE file.
6
 */
7
8
namespace SprykerEco\Zed\Payone\Business\Payment\MethodMapper;
9
10
use Generated\Shared\Transfer\ExpenseTransfer;
11
use Generated\Shared\Transfer\OrderTransfer;
12
use Generated\Shared\Transfer\PayoneAuthorizationTransfer;
13
use Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer;
14
use Orm\Zed\Payone\Persistence\SpyPaymentPayone;
15
use Spryker\Shared\Kernel\Store;
16
use SprykerEco\Shared\Payone\PayoneApiConstants;
17
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer;
18
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer;
19
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PaymentMethod\SecurityInvoiceContainer;
20
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\PersonalContainer;
21
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainer;
22
use SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainerInterface;
23
use SprykerEco\Zed\Payone\Business\Api\Request\Container\CaptureContainer;
24
use SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface;
25
use SprykerEco\Zed\Payone\Business\Api\Request\Container\DebitContainer;
26
use SprykerEco\Zed\Payone\Business\Api\Request\Container\GetSecurityInvoiceContainer;
27
use SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\ItemContainer;
28
use SprykerEco\Zed\Payone\Business\Api\Request\Container\PreAuthorizationContainer;
29
use SprykerEco\Zed\Payone\Business\Api\Request\Container\RefundContainer;
30
use SprykerEco\Zed\Payone\PayoneConfig;
31
32
class SecurityInvoice extends AbstractMapper
33
{
34
    /**
35
     * @var \SprykerEco\Zed\Payone\PayoneConfig
36
     */
37
    protected $payoneConfig;
38
39
    /**
40
     * @param \Spryker\Shared\Kernel\Store $storeConfig
41
     * @param \SprykerEco\Zed\Payone\PayoneConfig $payoneConfig
42
     */
43
    public function __construct(Store $storeConfig, PayoneConfig $payoneConfig)
44
    {
45
        parent::__construct($storeConfig);
46
        $this->payoneConfig = $payoneConfig;
47
    }
48
49
    /**
50
     * @return string
51
     */
52
    public function getName(): string
53
    {
54
        return PayoneApiConstants::PAYMENT_METHOD_SECURITY_INVOICE;
55
    }
56
57
    /**
58
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
59
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
60
     *
61
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainerInterface
62
     */
63 View Code Duplication
    public function mapPaymentToAuthorization(SpyPaymentPayone $paymentEntity, OrderTransfer $orderTransfer): AuthorizationContainerInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
64
    {
65
        $authorizationContainer = new AuthorizationContainer();
66
        $authorizationContainer = $this->mapPaymentToAbstractAuthorization($paymentEntity, $authorizationContainer);
67
        $authorizationContainer = $this->mapOrderItems($orderTransfer, $authorizationContainer);
68
        $authorizationContainer = $this->mapEmail($paymentEntity, $authorizationContainer);
0 ignored issues
show
Compatibility introduced by
$authorizationContainer of type object<SprykerEco\Zed\Pa...ner\ContainerInterface> is not a sub-type of object<SprykerEco\Zed\Pa...AuthorizationContainer>. It seems like you assume a concrete implementation of the interface SprykerEco\Zed\Payone\Bu...iner\ContainerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
69
        $authorizationContainer = $this->mapBusinessRelation($authorizationContainer);
70
71
        return $authorizationContainer;
72
    }
73
74
    /**
75
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
76
     *
77
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AuthorizationContainerInterface
78
     */
79 View Code Duplication
    public function mapPaymentToPreAuthorization(SpyPaymentPayone $paymentEntity): AuthorizationContainerInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
80
    {
81
        $preAuthorizationContainer = new PreAuthorizationContainer();
82
        $preAuthorizationContainer = $this->mapPaymentToAbstractAuthorization($paymentEntity, $preAuthorizationContainer);
83
        $preAuthorizationContainer = $this->mapEmail($paymentEntity, $preAuthorizationContainer);
84
        $preAuthorizationContainer = $this->mapAmount($paymentEntity, $preAuthorizationContainer);
85
        $preAuthorizationContainer = $this->mapBusinessRelation($preAuthorizationContainer);
86
87
        return $preAuthorizationContainer;
88
    }
89
90
    /**
91
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
92
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer $authorizationContainer
93
     *
94
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
95
     */
96 View Code Duplication
    public function mapOrderItems(OrderTransfer $orderTransfer, AbstractRequestContainer $authorizationContainer): ContainerInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
97
    {
98
        $arrayIt = [];
99
        $arrayId = [];
100
        $arrayPr = [];
101
        $arrayNo = [];
102
        $arrayDe = [];
103
        $arrayVa = [];
104
105
        $key = 1;
106
107
        $amount = 0;
108
109
        foreach ($orderTransfer->getItems() as $itemTransfer) {
110
            $arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_GOODS;
111
            $arrayId[$key] = $itemTransfer->getSku();
112
            $arrayPr[$key] = $itemTransfer->getSumPrice();
113
            $arrayNo[$key] = $itemTransfer->getQuantity();
114
            $arrayDe[$key] = $itemTransfer->getName();
115
            $arrayVa[$key] = (int)$itemTransfer->getTaxRate();
116
            $key++;
117
            $amount += $itemTransfer->getSumPrice();
118
        }
119
120
        $authorizationContainer->setIt($arrayIt);
121
        $authorizationContainer->setId($arrayId);
122
        $authorizationContainer->setPr($arrayPr);
123
        $authorizationContainer->setNo($arrayNo);
124
        $authorizationContainer->setDe($arrayDe);
125
        $authorizationContainer->setVa($arrayVa);
126
        $authorizationContainer->setAmount($amount);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SprykerEco\Zed\Payone\Bu...bstractRequestContainer as the method setAmount() does only exist in the following sub-classes of SprykerEco\Zed\Payone\Bu...bstractRequestContainer: SprykerEco\Zed\Payone\Bu...\AuthorizationContainer, SprykerEco\Zed\Payone\Bu...tAuthorizationContainer, SprykerEco\Zed\Payone\Bu...tainer\CaptureContainer, SprykerEco\Zed\Payone\Bu...ontainer\DebitContainer, SprykerEco\Zed\Payone\Bu...GenericPaymentContainer, SprykerEco\Zed\Payone\Bu...eAuthorizationContainer, SprykerEco\Zed\Payone\Bu...ntainer\RefundContainer, SprykerEco\Zed\Payone\Bu...eeDSecureCheckContainer. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
127
128
        return $authorizationContainer;
129
    }
130
131
    /**
132
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
133
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer $authorizationContainer
134
     *
135
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
136
     */
137 View Code Duplication
    public function mapRefundOrderItems(OrderTransfer $orderTransfer, AbstractRequestContainer $authorizationContainer): ContainerInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
138
    {
139
        $arrayIt = [];
140
        $arrayId = [];
141
        $arrayPr = [];
142
        $arrayNo = [];
143
        $arrayDe = [];
144
        $arrayVa = [];
145
146
        $key = 1;
147
148
        $amount = 0;
149
150
        foreach ($orderTransfer->getItems() as $itemTransfer) {
151
            $arrayIt[$key] = PayoneApiConstants::INVOICING_ITEM_TYPE_GOODS;
152
            $arrayId[$key] = $itemTransfer->getSku();
153
            $arrayPr[$key] = $itemTransfer->getSumPrice();
154
            $arrayNo[$key] = $itemTransfer->getQuantity();
155
            $arrayDe[$key] = $itemTransfer->getName();
156
            $arrayVa[$key] = (int)$itemTransfer->getTaxRate();
157
            $amount += $itemTransfer->getSumPrice();
158
            $key++;
159
        }
160
161
        $authorizationContainer->setIt($arrayIt);
162
        $authorizationContainer->setId($arrayId);
163
        $authorizationContainer->setPr($arrayPr);
164
        $authorizationContainer->setNo($arrayNo);
165
        $authorizationContainer->setDe($arrayDe);
166
        $authorizationContainer->setVa($arrayVa);
167
        $authorizationContainer->setAmount(0 - $amount);
0 ignored issues
show
Bug introduced by
It seems like you code against a specific sub-type and not the parent class SprykerEco\Zed\Payone\Bu...bstractRequestContainer as the method setAmount() does only exist in the following sub-classes of SprykerEco\Zed\Payone\Bu...bstractRequestContainer: SprykerEco\Zed\Payone\Bu...\AuthorizationContainer, SprykerEco\Zed\Payone\Bu...tAuthorizationContainer, SprykerEco\Zed\Payone\Bu...tainer\CaptureContainer, SprykerEco\Zed\Payone\Bu...ontainer\DebitContainer, SprykerEco\Zed\Payone\Bu...GenericPaymentContainer, SprykerEco\Zed\Payone\Bu...eAuthorizationContainer, SprykerEco\Zed\Payone\Bu...ntainer\RefundContainer, SprykerEco\Zed\Payone\Bu...eeDSecureCheckContainer. Maybe you want to instanceof check for one of these explicitly?

Let’s take a look at an example:

abstract class User
{
    /** @return string */
    abstract public function getPassword();
}

class MyUser extends User
{
    public function getPassword()
    {
        // return something
    }

    public function getDisplayName()
    {
        // return some name.
    }
}

class AuthSystem
{
    public function authenticate(User $user)
    {
        $this->logger->info(sprintf('Authenticating %s.', $user->getDisplayName()));
        // do something.
    }
}

In the above example, the authenticate() method works fine as long as you just pass instances of MyUser. However, if you now also want to pass a different sub-classes of User which does not have a getDisplayName() method, the code will break.

Available Fixes

  1. Change the type-hint for the parameter:

    class AuthSystem
    {
        public function authenticate(MyUser $user) { /* ... */ }
    }
    
  2. Add an additional type-check:

    class AuthSystem
    {
        public function authenticate(User $user)
        {
            if ($user instanceof MyUser) {
                $this->logger->info(/** ... */);
            }
    
            // or alternatively
            if ( ! $user instanceof MyUser) {
                throw new \LogicException(
                    '$user must be an instance of MyUser, '
                   .'other instances are not supported.'
                );
            }
    
        }
    }
    
Note: PHP Analyzer uses reverse abstract interpretation to narrow down the types inside the if block in such a case.
  1. Add the method to the parent class:

    abstract class User
    {
        /** @return string */
        abstract public function getPassword();
    
        /** @return string */
        abstract public function getDisplayName();
    }
    
Loading history...
168
169
        return $authorizationContainer;
170
    }
171
172
    /**
173
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
174
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $container
175
     *
176
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer
177
     */
178
    public function mapEmail(SpyPaymentPayone $paymentEntity, AbstractAuthorizationContainer $container): AbstractAuthorizationContainer
179
    {
180
        $container->setEmail($paymentEntity->getSpySalesOrder()->getEmail());
181
182
        return $container;
183
    }
184
185
    /**
186
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
187
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $container
188
     *
189
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer
190
     */
191
    public function mapAmount(SpyPaymentPayone $paymentEntity, AbstractAuthorizationContainer $container): AbstractAuthorizationContainer
192
    {
193
        $container->setAmount($paymentEntity->getSpySalesOrder()->getOrderTotals()->get(0)->getSubTotal());
194
195
        return $container;
196
    }
197
198
    /**
199
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $container
200
     *
201
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer
202
     */
203
    public function mapBusinessRelation(AbstractAuthorizationContainer $container): AbstractAuthorizationContainer
204
    {
205
        $container->setBusinessrelation($this->payoneConfig->getBusinessRelation());
206
207
        return $container;
208
    }
209
210
    /**
211
     * @param \Generated\Shared\Transfer\ExpenseTransfer $expense
212
     *
213
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Invoicing\ItemContainer
214
     */
215 View Code Duplication
    public function mapExpenseToItemContainer(ExpenseTransfer $expense)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
216
    {
217
        $itemContainer = new ItemContainer();
218
        $itemContainer->setIt(PayoneApiConstants::INVOICING_ITEM_TYPE_SHIPMENT);
219
        $itemContainer->setId('-');
220
        $itemContainer->setPr($expense->getUnitGrossPrice());
221
        $itemContainer->setNo($expense->getQuantity());
222
        $itemContainer->setDe($expense->getName());
223
        $itemContainer->setVa($expense->getTaxRate());
224
225
        return $itemContainer;
226
    }
227
228
    /**
229
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
230
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
231
     *
232
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer
233
     */
234 View Code Duplication
    public function mapPaymentToCapture(SpyPaymentPayone $paymentEntity, OrderTransfer $orderTransfer): AbstractRequestContainer
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
235
    {
236
        $paymentDetailEntity = $paymentEntity->getSpyPaymentPayoneDetail();
0 ignored issues
show
Unused Code introduced by
$paymentDetailEntity is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
237
238
        $captureContainer = new CaptureContainer();
239
        $captureContainer = $this->mapOrderItems($orderTransfer, $captureContainer);
240
        $captureContainer->setCurrency($this->getStandardParameter()->getCurrency());
241
        $captureContainer->setTxid($paymentEntity->getTransactionId());
242
243
        return $captureContainer;
244
    }
245
246
    /**
247
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
248
     * @param \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer $authorizationContainer
249
     *
250
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\Authorization\AbstractAuthorizationContainer
251
     */
252 View Code Duplication
    protected function mapPaymentToAbstractAuthorization(SpyPaymentPayone $paymentEntity, AbstractAuthorizationContainer $authorizationContainer): AbstractAuthorizationContainer
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
253
    {
254
        $paymentDetailEntity = $paymentEntity->getSpyPaymentPayoneDetail();
0 ignored issues
show
Unused Code introduced by
$paymentDetailEntity is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
255
256
        $authorizationContainer->setAid($this->getStandardParameter()->getAid());
257
        $authorizationContainer->setClearingType(PayoneApiConstants::CLEARING_TYPE_SECURITY_INVOICE);
258
        $authorizationContainer->setClearingsubtype(PayoneApiConstants::CLEARING_SUBTYPE_SECURITY_INVOICE);
259
        $authorizationContainer->setReference($paymentEntity->getReference());
260
        $authorizationContainer->setCurrency($this->getStandardParameter()->getCurrency());
261
        $authorizationContainer->setPaymentMethod($this->createPaymentMethodContainerFromPayment($paymentEntity));
0 ignored issues
show
Compatibility introduced by
$this->createPaymentMeth...Payment($paymentEntity) of type object<SprykerEco\Zed\Pa...ner\ContainerInterface> is not a sub-type of object<SprykerEco\Zed\Pa...PaymentMethodContainer>. It seems like you assume a concrete implementation of the interface SprykerEco\Zed\Payone\Bu...iner\ContainerInterface to be always present.

This check looks for parameters that are defined as one type in their type hint or doc comment but seem to be used as a narrower type, i.e an implementation of an interface or a subclass.

Consider changing the type of the parameter or doing an instanceof check before assuming your parameter is of the expected type.

Loading history...
262
263
        $personalContainer = new PersonalContainer();
264
        $this->mapBillingAddressToPersonalContainer($personalContainer, $paymentEntity);
265
266
        $authorizationContainer->setPersonalData($personalContainer);
267
268
        return $authorizationContainer;
269
    }
270
271
    /**
272
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
273
     *
274
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
275
     */
276
    public function mapPaymentToDebit(SpyPaymentPayone $paymentEntity): ContainerInterface
277
    {
278
        $debitContainer = new DebitContainer();
279
280
        $debitContainer->setTxid($paymentEntity->getTransactionId());
281
        $debitContainer->setSequenceNumber($this->getNextSequenceNumber($paymentEntity->getTransactionId()));
282
        $debitContainer->setCurrency($this->getStandardParameter()->getCurrency());
283
        $debitContainer->setAmount($paymentEntity->getSpyPaymentPayoneDetail()->getAmount());
284
285
        return $debitContainer;
286
    }
287
288
    /**
289
     * @param \Generated\Shared\Transfer\PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer
290
     *
291
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
292
     */
293
    public function mapGetSecurityInvoice(PayoneGetSecurityInvoiceTransfer $getSecurityInvoiceTransfer): ContainerInterface
294
    {
295
        $getInvoiceContainer = new GetSecurityInvoiceContainer();
296
        $getInvoiceContainer->setInvoiceTitle($getSecurityInvoiceTransfer->getReference());
297
298
        return $getInvoiceContainer;
299
    }
300
301
    /**
302
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
303
     * @param \Generated\Shared\Transfer\OrderTransfer $orderTransfer
304
     *
305
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\AbstractRequestContainer
306
     */
307
    public function mapPaymentToRefund(SpyPaymentPayone $paymentEntity, OrderTransfer $orderTransfer): AbstractRequestContainer
308
    {
309
        $refundContainer = new RefundContainer();
310
311
        $refundContainer = $this->mapRefundOrderItems($orderTransfer, $refundContainer);
312
        $refundContainer->setTxid($paymentEntity->getTransactionId());
313
        $refundContainer->setSequenceNumber($this->getNextSequenceNumber($paymentEntity->getTransactionId()));
314
        $refundContainer->setCurrency($this->getStandardParameter()->getCurrency());
315
        $refundContainer->setBankcountry($paymentEntity->getSpyPaymentPayoneDetail()->getBankCountry());
316
        $refundContainer->setBankaccount($paymentEntity->getSpyPaymentPayoneDetail()->getBankAccount());
317
        $refundContainer->setBankcode($paymentEntity->getSpyPaymentPayoneDetail()->getBankCode());
318
        $refundContainer->setBankbranchcode($paymentEntity->getSpyPaymentPayoneDetail()->getBankBranchCode());
319
        $refundContainer->setBankcheckdigit($paymentEntity->getSpyPaymentPayoneDetail()->getBankCheckDigit());
320
        $refundContainer->setIban($paymentEntity->getSpyPaymentPayoneDetail()->getIban());
321
        $refundContainer->setBic($paymentEntity->getSpyPaymentPayoneDetail()->getBic());
322
323
        return $refundContainer;
324
    }
325
326
    /**
327
     * @param \Orm\Zed\Payone\Persistence\SpyPaymentPayone $paymentEntity
328
     *
329
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
330
     */
331
    protected function createPaymentMethodContainerFromPayment(SpyPaymentPayone $paymentEntity): ContainerInterface
0 ignored issues
show
Unused Code introduced by
The parameter $paymentEntity is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
332
    {
333
        $paymentMethodContainer = new SecurityInvoiceContainer();
334
335
        return $paymentMethodContainer;
336
    }
337
338
    /**
339
     * @param \Generated\Shared\Transfer\PayoneAuthorizationTransfer $payoneAuthorizationTransfer
340
     *
341
     * @return \SprykerEco\Zed\Payone\Business\Api\Request\Container\ContainerInterface
342
     */
343 View Code Duplication
    protected function createAuthorizationPersonalData(PayoneAuthorizationTransfer $payoneAuthorizationTransfer): ContainerInterface
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
344
    {
345
        $personalContainer = new PersonalContainer();
346
347
        $personalContainer->setFirstName($payoneAuthorizationTransfer->getOrder()->getFirstName());
348
        $personalContainer->setLastName($payoneAuthorizationTransfer->getOrder()->getLastName());
349
        $personalContainer->setCountry($this->storeConfig->getCurrentCountry());
350
351
        return $personalContainer;
352
    }
353
}
354