1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Copyright (c) 2013-2014 eBay Enterprise, Inc. |
4
|
|
|
* |
5
|
|
|
* NOTICE OF LICENSE |
6
|
|
|
* |
7
|
|
|
* This source file is subject to the Open Software License (OSL 3.0) |
8
|
|
|
* that is bundled with this package in the file LICENSE.md. |
9
|
|
|
* It is also available through the world-wide-web at this URL: |
10
|
|
|
* http://opensource.org/licenses/osl-3.0.php |
11
|
|
|
* |
12
|
|
|
* @copyright Copyright (c) 2013-2014 eBay Enterprise, Inc. (http://www.ebayenterprise.com/) |
13
|
|
|
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0) |
14
|
|
|
*/ |
15
|
|
|
|
16
|
|
|
namespace eBayEnterprise\RetailOrderManagement\Payload\Payment; |
17
|
|
|
|
18
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\ISchemaValidator; |
19
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IValidatorIterator; |
20
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayloadMap; |
21
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\IPayload; |
22
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\TPayloadLogger; |
23
|
|
|
use eBayEnterprise\RetailOrderManagement\Payload\TTopLevelPayload; |
24
|
|
|
use Psr\Log\LoggerInterface; |
25
|
|
|
use Psr\Log\NullLogger; |
26
|
|
|
|
27
|
|
|
class ProtectPanRequest implements IProtectPanRequest |
28
|
|
|
{ |
29
|
|
|
use TTopLevelPayload, TPayloadLogger; |
30
|
|
|
|
31
|
|
|
/** @var string */ |
32
|
|
|
protected $paymentAccountNumber; |
33
|
|
|
/** @var string */ |
34
|
|
|
protected $tenderClass; |
35
|
|
|
/** @var array */ |
36
|
|
|
protected $tenderClassEnum = [self::TENDER_CLASS_CC, self::TENDER_CLASS_PL_CC, self::TENDER_CLASS_SV,]; |
37
|
|
|
|
38
|
|
|
/** |
39
|
|
|
* @param IValidatorIterator |
40
|
|
|
* @param ISchemaValidator |
41
|
|
|
* @param IPayloadMap |
42
|
|
|
* @param LoggerInterface |
43
|
|
|
* @param IPayload |
44
|
|
|
* @SuppressWarnings(PHPMD.UnusedFormalParameter) |
45
|
|
|
*/ |
46
|
|
|
public function __construct( |
47
|
|
|
IValidatorIterator $validators, |
48
|
|
|
ISchemaValidator $schemaValidator, |
49
|
|
|
IPayloadMap $payloadMap, |
|
|
|
|
50
|
|
|
LoggerInterface $logger, |
51
|
|
|
IPayload $parentPayload = null |
52
|
|
|
) { |
53
|
|
|
$this->logger = $logger; |
|
|
|
|
54
|
|
|
$this->validators = $validators; |
55
|
|
|
$this->schemaValidator = $schemaValidator; |
56
|
|
|
$this->parentPayload = $parentPayload; |
57
|
|
|
|
58
|
|
|
$this->extractionPaths = [ |
59
|
|
|
'paymentAccountNumber' => 'string(x:PaymentAccountNumber)', |
60
|
|
|
'tenderClass' => 'string(x:TenderClass)', |
61
|
|
|
]; |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
|
65
|
|
|
public function getPaymentAccountNumber() |
66
|
|
|
{ |
67
|
|
|
return $this->paymentAccountNumber; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
public function setPaymentAccountNumber($paymentAccountNumber) |
71
|
|
|
{ |
72
|
|
|
$this->paymentAccountNumber = $this->cleanString($paymentAccountNumber, 50); |
73
|
|
|
return $this; |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function getTenderClass() |
77
|
|
|
{ |
78
|
|
|
return $this->tenderClass; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
View Code Duplication |
public function setTenderClass($tenderClass) |
|
|
|
|
82
|
|
|
{ |
83
|
|
|
$isAllowed = in_array($tenderClass, $this->tenderClassEnum); |
84
|
|
|
$this->tenderClass = $isAllowed ? $tenderClass : null; |
85
|
|
|
if (!$isAllowed) { |
86
|
|
|
$logData = ['tender_class' => $tenderClass]; |
87
|
|
|
$this->logger->warning( |
88
|
|
|
'Tender Class "{tender_class}" is not allowed.', |
89
|
|
|
$this->getLogContextData(__CLASS__, $logData) |
90
|
|
|
); |
91
|
|
|
} |
92
|
|
|
return $this; |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
/** |
96
|
|
|
* Serialize the various parts of the payload into XML strings and |
97
|
|
|
* simply concatenate them together. |
98
|
|
|
* @return string |
99
|
|
|
*/ |
100
|
|
|
protected function serializeContents() |
101
|
|
|
{ |
102
|
|
|
return $this->serializeRequiredValue('PaymentAccountNumber', $this->xmlEncode($this->getPaymentAccountNumber())) |
103
|
|
|
. $this->serializeRequiredValue('TenderClass', $this->xmlEncode($this->getTenderClass())); |
104
|
|
|
} |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* The XML namespace for the payload. |
108
|
|
|
* |
109
|
|
|
* @return string |
110
|
|
|
*/ |
111
|
|
|
protected function getXmlNamespace() |
112
|
|
|
{ |
113
|
|
|
return static::XML_NS; |
114
|
|
|
} |
115
|
|
|
|
116
|
|
|
protected function getSchemaFile() |
117
|
|
|
{ |
118
|
|
|
return $this->getSchemaDir() . self::XSD; |
119
|
|
|
} |
120
|
|
|
|
121
|
|
|
/** |
122
|
|
|
* Return the name of the xml root node. |
123
|
|
|
* |
124
|
|
|
* @return string |
125
|
|
|
*/ |
126
|
|
|
protected function getRootNodeName() |
127
|
|
|
{ |
128
|
|
|
return static::ROOT_NODE; |
129
|
|
|
} |
130
|
|
|
} |
131
|
|
|
|
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.