|
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\Processor\Processor; |
|
16
|
|
|
use Etrias\PaazlConnector\ServiceType\Service as GeneralServiceType; |
|
17
|
|
|
use Etrias\PaazlConnector\StructType\BaseCheckoutRequestType; |
|
18
|
|
|
use Etrias\PaazlConnector\StructType\CheckoutResponse; |
|
19
|
|
|
use Etrias\PaazlConnector\StructType\CheckoutStatusResponse; |
|
20
|
|
|
|
|
21
|
|
|
class CheckoutService |
|
22
|
|
|
{ |
|
23
|
|
|
use Processor; |
|
24
|
|
|
|
|
25
|
|
|
/** |
|
26
|
|
|
* @var SecurityServiceInterface |
|
27
|
|
|
*/ |
|
28
|
|
|
protected $securityService; |
|
29
|
|
|
/** |
|
30
|
|
|
* @var GeneralServiceType |
|
31
|
|
|
*/ |
|
32
|
|
|
protected $generalServiceType; |
|
33
|
|
|
|
|
34
|
|
|
/** |
|
35
|
|
|
* DocumentService constructor. |
|
36
|
|
|
* |
|
37
|
|
|
* @param GeneralServiceType $generalServiceType |
|
38
|
|
|
* @param SecurityServiceInterface $securityService |
|
39
|
|
|
*/ |
|
40
|
|
|
public function __construct(GeneralServiceType $generalServiceType, SecurityServiceInterface $securityService) |
|
41
|
|
|
{ |
|
42
|
|
|
$this->securityService = $securityService; |
|
43
|
|
|
$this->generalServiceType = $generalServiceType; |
|
44
|
|
|
} |
|
45
|
|
|
|
|
46
|
|
|
/** |
|
47
|
|
|
* @param $orderReference |
|
48
|
|
|
* @param null $targetWebShop |
|
49
|
|
|
* |
|
50
|
|
|
* @return CheckoutResponse |
|
51
|
|
|
*/ |
|
52
|
|
|
public function getCheckoutUrl($orderReference, $targetWebShop = null) |
|
53
|
|
|
{ |
|
54
|
|
|
$request = new BaseCheckoutRequestType( |
|
55
|
|
|
$this->securityService->getHash($orderReference), |
|
56
|
|
|
$this->generalServiceType->getWebShopId(), |
|
57
|
|
|
$targetWebShop, |
|
58
|
|
|
$orderReference |
|
59
|
|
|
); |
|
60
|
|
|
|
|
61
|
|
|
$response = $this->generalServiceType->checkout($request); |
|
62
|
|
|
|
|
63
|
|
|
return $this->processResponse($response, $this->generalServiceType); |
|
64
|
|
|
} |
|
65
|
|
|
|
|
66
|
|
|
/** |
|
67
|
|
|
* @param $orderReference |
|
68
|
|
|
* @param null $targetWebShop |
|
69
|
|
|
* |
|
70
|
|
|
* @return CheckoutStatusResponse |
|
71
|
|
|
*/ |
|
72
|
|
|
public function getCheckoutStatus($orderReference, $targetWebShop = null) |
|
73
|
|
|
{ |
|
74
|
|
|
$request = new BaseCheckoutRequestType( |
|
75
|
|
|
$this->securityService->getHash($orderReference), |
|
76
|
|
|
$this->generalServiceType->getWebShopId(), |
|
77
|
|
|
$targetWebShop, |
|
78
|
|
|
$orderReference |
|
79
|
|
|
); |
|
80
|
|
|
|
|
81
|
|
|
$response = $this->generalServiceType->checkoutStatus($request); |
|
82
|
|
|
|
|
83
|
|
|
return $this->processResponse($response, $this->generalServiceType); |
|
84
|
|
|
} |
|
85
|
|
|
} |
|
86
|
|
|
|