1 | <?php |
||
22 | trait TOrderContext |
||
23 | { |
||
24 | use TBrowserData, TCustomerSessionInfo, TPayPalPayerInfo, TOrderContextCustomAttributeContainer; |
||
25 | |||
26 | /** @var DateTime */ |
||
27 | protected $tdlOrderTimestamp; |
||
28 | /** @var int */ |
||
29 | protected $tdlMilliseconds = 0; |
||
30 | |||
31 | public function getTdlOrderTimestamp() |
||
35 | |||
36 | public function getTdlMilliseconds() |
||
40 | |||
41 | /** |
||
42 | * The fraud system requires millisecond precision. |
||
43 | * PHP DateTime does not support this, but we use that for backwards compatibility. |
||
44 | * |
||
45 | * @param DateTime |
||
46 | * @return self |
||
47 | */ |
||
48 | public function setTdlOrderTimestamp(DateTime $tdlOrderTimestamp, $milliseconds = 0) |
||
54 | |||
55 | /** |
||
56 | * Get property => XPath mapping for properties to be extracted from |
||
57 | * serialized payloads for Order Context properties. |
||
58 | * |
||
59 | * @return array |
||
60 | */ |
||
61 | protected function getOrderContextExtractionPaths() |
||
76 | |||
77 | /** |
||
78 | * Get property => XPath mapping for optional properties to be extracted from |
||
79 | * serialized payloads for Order Context properties. |
||
80 | * |
||
81 | * @return array |
||
82 | */ |
||
83 | protected function getOrderContextOptionalExtractionPaths() |
||
103 | |||
104 | /** |
||
105 | * Get property => XPath mapping for subpayload properties to be extracted from |
||
106 | * serialized payloads for Order Context properties. |
||
107 | * |
||
108 | * @return array |
||
109 | */ |
||
110 | protected function getOrderContextSubpayloadExtractionPaths() |
||
116 | |||
117 | /** |
||
118 | * Build an XML serialization of the order context - browser data, tdl order |
||
119 | * timestamp, session info, PayPal payer info and custom attributes. |
||
120 | * |
||
121 | * @return string |
||
122 | */ |
||
123 | protected function serializeOrderContext() |
||
133 | |||
134 | /** |
||
135 | * Serialize the TDL order timestamp into an XML node with an ISO8601 time format with millisecond precision. |
||
136 | * |
||
137 | * @return string |
||
138 | */ |
||
139 | protected function serializeTdlOrderTimestamp() |
||
151 | |||
152 | /** |
||
153 | * Deserialize order context data that is not represented by primitive types, |
||
154 | * e.g. DateTime objects, DateInterval objects. |
||
155 | * |
||
156 | * @param DOMXPath |
||
157 | * @return self |
||
158 | */ |
||
159 | protected function deserializeExtraOrderContext(DOMXPath $xpath) |
||
175 | |||
176 | /** |
||
177 | * Convert a string of HH:MM:SS to a date interval spec string. |
||
178 | * |
||
179 | * @param string |
||
180 | * @return string |
||
181 | */ |
||
182 | protected function convertHMSToDateInterval($hmsTime) |
||
187 | } |
||
188 |