1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/* |
4
|
|
|
* This file is part of PHP CS Fixer. |
5
|
|
|
* |
6
|
|
|
* (c) Fabien Potencier <[email protected]> |
7
|
|
|
* Dariusz Rumiński <[email protected]> |
8
|
|
|
* |
9
|
|
|
* This source file is subject to the MIT license that is bundled |
10
|
|
|
* with this source code in the file LICENSE. |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Etrias\PaazlConnector\Services; |
14
|
|
|
|
15
|
|
|
use Etrias\PaazlConnector\Client\PaazlClientInterface; |
16
|
|
|
use Etrias\PaazlConnector\SoapTypes\BaseCheckoutRequestType; |
17
|
|
|
|
18
|
|
|
class CheckoutService implements CheckoutServiceInterface |
19
|
|
|
{ |
20
|
|
|
/** |
21
|
|
|
* @var PaazlClientInterface |
22
|
|
|
*/ |
23
|
|
|
protected $client; |
24
|
|
|
/** |
25
|
|
|
* @var SecurityServiceInterface |
26
|
|
|
*/ |
27
|
|
|
protected $security; |
28
|
|
|
|
29
|
|
|
/** |
30
|
|
|
* DocumentService constructor. |
31
|
|
|
* |
32
|
|
|
* @param PaazlClientInterface $client |
33
|
|
|
* @param SecurityServiceInterface $security |
34
|
|
|
*/ |
35
|
|
|
public function __construct(PaazlClientInterface $client, SecurityServiceInterface $security) |
36
|
|
|
{ |
37
|
|
|
$this->security = $security; |
38
|
|
|
$this->client = $client; |
39
|
|
|
} |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritdoc} |
43
|
|
|
*/ |
44
|
|
View Code Duplication |
public function getCheckoutUrl($orderReference, $targetWebShop = null) |
|
|
|
|
45
|
|
|
{ |
46
|
|
|
$request = new BaseCheckoutRequestType( |
47
|
|
|
$this->security->getHash($orderReference), |
48
|
|
|
$this->client->getWebShopId(), |
49
|
|
|
$targetWebShop, |
50
|
|
|
$orderReference |
51
|
|
|
); |
52
|
|
|
|
53
|
|
|
return $this->client->checkout($request); |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* {@inheritdoc} |
58
|
|
|
*/ |
59
|
|
View Code Duplication |
public function getCheckoutStatus($orderReference, $targetWebShop = null) |
|
|
|
|
60
|
|
|
{ |
61
|
|
|
$request = new BaseCheckoutRequestType( |
62
|
|
|
$this->security->getHash($orderReference), |
63
|
|
|
$this->client->getWebShopId(), |
64
|
|
|
$targetWebShop, |
65
|
|
|
$orderReference |
66
|
|
|
); |
67
|
|
|
|
68
|
|
|
return $this->client->checkoutStatus($request); |
|
|
|
|
69
|
|
|
} |
70
|
|
|
} |
71
|
|
|
|
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.