1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace ByTIC\Omnipay\PlatiOnline\Message; |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Class ServerCompletePurchaseResponse |
7
|
|
|
* @package ByTIC\Omnipay\PlatiOnline\Message |
8
|
|
|
*/ |
9
|
|
|
class ServerCompletePurchaseResponse extends AbstractResponse |
10
|
|
|
{ |
11
|
|
|
use Traits\RelayResponseTrait; |
|
|
|
|
12
|
|
|
|
13
|
|
|
public function send() |
14
|
|
|
{ |
15
|
|
|
header('Content-type: application/xml'); |
16
|
|
|
echo $this->getContent(); |
17
|
|
|
} |
18
|
|
|
|
19
|
|
|
/** |
20
|
|
|
* @return string |
21
|
|
|
*/ |
22
|
|
|
public function getContent() |
23
|
|
|
{ |
24
|
|
|
$response = '0'; |
25
|
|
|
|
26
|
|
|
$status1 = $this->getStatus1(); |
27
|
|
|
if (in_array($status1, ['13', '1', '2', '8', '3', '6', '7', '9', '10', '16', '17'])) { |
28
|
|
|
$response = '1'; |
29
|
|
|
} elseif ($status1 == 5) { |
30
|
|
|
$status2 = $this->getStatus2(); |
31
|
|
|
if (in_array($status2, ['1', '2', '3', '4'])) { |
32
|
|
|
$response = '1'; |
33
|
|
|
} |
34
|
|
|
} |
35
|
|
|
|
36
|
|
|
$stare1 = '<f_response_code>1</f_response_code>'; |
|
|
|
|
37
|
|
|
|
38
|
|
|
$content = '<?xml version="1.0" encoding="UTF-8" ?>'; |
39
|
|
|
$content .= '<itsn>'; |
40
|
|
|
$content .= '<x_trans_id>' . $this->getTransactionReference() . '</x_trans_id>'; |
41
|
|
|
$content .= '<merchServerStamp>' . date("Y-m-d H:m:s") . '</merchServerStamp>'; |
42
|
|
|
$content .= '<f_response_code>' . $response . '</f_response_code>'; |
43
|
|
|
$content .= '</itsn>'; |
44
|
|
|
return $content; |
45
|
|
|
} |
46
|
|
|
|
47
|
|
|
/** |
48
|
|
|
* @inheritDoc |
49
|
|
|
* @noinspection PhpMissingReturnTypeInspection |
50
|
|
|
*/ |
51
|
|
|
public function getTransactionReference() |
52
|
|
|
{ |
53
|
|
|
return (string)$this->getNotification()['transaction']->x_trans_id; |
54
|
|
|
} |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* @inheritDoc |
58
|
|
|
* @noinspection PhpMissingReturnTypeInspection |
59
|
|
|
*/ |
60
|
|
|
public function getTransactionId() |
61
|
|
|
{ |
62
|
|
|
return (string)$this->getNotification()['order']->f_order_number; |
63
|
|
|
} |
64
|
|
|
|
65
|
|
|
public function getMessage() |
66
|
|
|
{ |
67
|
|
|
return; |
68
|
|
|
} |
69
|
|
|
|
70
|
|
|
/** |
71
|
|
|
* @inheritDoc |
72
|
|
|
*/ |
73
|
|
|
public function getStatus1() |
74
|
|
|
{ |
75
|
|
|
if ($this->hasDataProperty('status1') === false) { |
76
|
|
|
$this->data['status1'] = (string)$this->getNotification()['transaction']->status_fin1->code; |
77
|
|
|
} |
78
|
|
|
return $this->getDataProperty('status1'); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @inheritDoc |
83
|
|
|
*/ |
84
|
|
|
public function getStatus2() |
85
|
|
|
{ |
86
|
|
|
if ($this->hasDataProperty('status2') === false) { |
87
|
|
|
$this->data['status2'] = (string)$this->getNotification()['transaction']->status_fin2->code; |
88
|
|
|
} |
89
|
|
|
return $this->getDataProperty('status2'); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* @inheritdoc |
94
|
|
|
*/ |
95
|
|
|
public function isSuccessful() |
96
|
|
|
{ |
97
|
|
|
return $this->getStatus1() == 2; |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* @inheritdoc |
102
|
|
|
*/ |
103
|
|
|
public function isPending() |
104
|
|
|
{ |
105
|
|
|
return $this->getStatus1() == 1 || $this->getStatus1() == 3; |
106
|
|
|
} |
107
|
|
|
|
108
|
|
|
/** |
109
|
|
|
* @inheritdoc |
110
|
|
|
*/ |
111
|
|
|
public function isCancelled() |
112
|
|
|
{ |
113
|
|
|
return $this->getStatus1() == 9; |
114
|
|
|
} |
115
|
|
|
} |
116
|
|
|
|