forked from fall1600/ecpay
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Response.php
149 lines (131 loc) · 2.95 KB
/
Response.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
namespace fall1600\Package\Ecpay;
class Response
{
/** @var array */
protected $data;
public function __construct(array $data)
{
$this->data = $data;
}
/**
* @return string|null
*/
public function getMerchantId()
{
return $this->data['MerchantID'] ?? null;
}
/**
* OrderInterface 提供給綠界的 MerchantTradeNo, 由特店(應用層系統)提供
* @return string|null
*/
public function getMerchantTradeNo()
{
return $this->data['MerchantTradeNo'] ?? null;
}
/**
* 特店旗下店舖代號
* @return string|null
*/
public function getSubMerchant()
{
return $this->data['StoreID'] ?? null;
}
/**
* 交易狀態
* 若回傳值為 1 時, 為付款成功其餘代碼皆為交易異常, 請至廠商管理後台確認後再出貨。
* @return int|null
*/
public function getReturnCode()
{
return $this->data['RtnCode'] ?? null;
}
/**
* Server POST 成功回傳:交易成功
* Server POST 補送通知回傳:paid
* Client POST 成功回傳:Succeeded
* @return string|null
*/
public function getReturnMessage()
{
return $this->data['RtnMsg'] ?? null;
}
/**
* @return string|null
*/
public function getChecksum()
{
return $this->data['CheckMacValue'] ?? null;
}
/**
* 綠界的交易編號, 由綠界提供
* @return string|null
*/
public function getTradeNo()
{
return $this->data['TradeNo'] ?? null;
}
/**
* 交易金額
* @return int|null
*/
public function getTradeAmt()
{
return $this->data['TradeAmt'] ?? null;
}
/**
* 付款時間(yyyy/MM/dd HH:mm:ss)
* @return string|null
*/
public function getPaymentDate()
{
return $this->data['PaymentDate'] ?? null;
}
/**
* 付款方式
* @return string|null
*/
public function getPaymentType()
{
return $this->data['PaymentType'] ?? null;
}
/**
* 通路費
* @return int|null
*/
public function getPaymentTypeChargeFee()
{
return $this->data['PaymentTypeChargeFee'] ?? null;
}
/**
* 訂單成立時間(yyyy/MM/dd HH:mm:ss)
* @return string|null
*/
public function getTradeDate()
{
return $this->data['TradeDate'] ?? null;
}
/**
* 是否為模擬付款
* @return bool
*/
public function isSimulated()
{
return (bool) $this->data['SimulatePaid'];
}
/**
* 原始交易資訊, 可用此payload 計算checksum, 確認綠界來的checksum 是否相符
* @return array
*/
public function getOriginInfoPayload()
{
return array_diff_key($this->data, ['CheckMacValue' => 1]);
}
/**
* @return array
*/
public function getData()
{
return $this->data;
}
}