@@ -35,7 +35,6 @@ public function __construct(string $key, string $iv, string $type = '')
35
35
$ prefix .= "sandbox- " ;
36
36
}
37
37
$ this ->apiUrl = $ prefix . $ this ->apiUrl ;
38
-
39
38
$ this ->parameter = [
40
39
'MerID ' => '' ,
41
40
'Version ' => '1.0 ' ,
@@ -72,66 +71,66 @@ public function UniversalTrade(array $encryptInfo, string $tradeType)
72
71
case 'atm ' : // 交易建立 虛擬帳號幕後
73
72
case 'cvs ' : // 交易建立 超商代碼幕後
74
73
if ($ this ->encryptInfo ['MerTradeNo ' ] == null || $ this ->encryptInfo ['MerTradeNo ' ] == '' ) {
75
- throw new Exception ('MerTradeNo is not setting ' );
74
+ throw new Exception ('商店訂單編號為必填( MerTradeNo is not setting) ' );
76
75
}
77
76
if ($ this ->encryptInfo ['TradeAmt ' ] == null || $ this ->encryptInfo ['TradeAmt ' ] == '' ) {
78
- throw new Exception ('TradeAmt is not setting ' );
77
+ throw new Exception ('訂單金額為必填( TradeAmt is not setting) ' );
79
78
}
80
79
break ;
81
80
case 'credit ' : // 交易建立 信用卡幕後
82
81
if ($ this ->encryptInfo ['MerTradeNo ' ] == null || $ this ->encryptInfo ['MerTradeNo ' ] == '' ) {
83
- throw new Exception ('MerTradeNo is not setting ' );
82
+ throw new Exception ('商店訂單編號為必填( MerTradeNo is not setting) ' );
84
83
}
85
84
if ($ this ->encryptInfo ['TradeAmt ' ] == null || $ this ->encryptInfo ['TradeAmt ' ] == '' ) {
86
- throw new Exception ('TradeAmt is not setting ' );
85
+ throw new Exception ('訂單金額為必填( TradeAmt is not setting) ' );
87
86
}
88
87
if (!isset ($ this ->encryptInfo ['CreditHash ' ])) {
89
88
if ($ this ->encryptInfo ['CardNo ' ] == null || $ this ->encryptInfo ['CardNo ' ] == '' ) {
90
- throw new Exception ('CardNo is not setting ' );
89
+ throw new Exception ('信用卡卡號為必填( CardNo is not setting) ' );
91
90
}
92
91
if ($ this ->encryptInfo ['CardExpired ' ] == null || $ this ->encryptInfo ['CardExpired ' ] == '' ) {
93
- throw new Exception ('CardExpired is not setting ' );
92
+ throw new Exception ('信用卡到期年月為必填( CardExpired is not setting) ' );
94
93
}
95
94
if ($ this ->encryptInfo ['CardCVC ' ] == null || $ this ->encryptInfo ['CardCVC ' ] == '' ) {
96
- throw new Exception ('CardCVC is not setting ' );
95
+ throw new Exception ('信用卡安全碼為必填( CardCVC is not setting) ' );
97
96
}
98
97
}
99
98
break ;
100
99
case 'trade_close ' : // 交易請退款
101
100
if ($ this ->encryptInfo ['TradeNo ' ] == null || $ this ->encryptInfo ['TradeNo ' ] == '' ) {
102
- throw new Exception ('TradeNo is not setting ' );
101
+ throw new Exception ('uni序號為必填( TradeNo is not setting) ' );
103
102
}
104
103
if ($ this ->encryptInfo ['CloseType ' ] == null || $ this ->encryptInfo ['CloseType ' ] == '' ) {
105
- throw new Exception ('CloseType is not setting ' );
104
+ throw new Exception ('關帳類型為必填( CloseType is not setting) ' );
106
105
}
107
106
break ;
108
107
case 'trade_cancel ' : // 交易取消授權
109
108
if ($ this ->encryptInfo ['TradeNo ' ] == null || $ this ->encryptInfo ['TradeNo ' ] == '' ) {
110
- throw new Exception ('TradeNo is not setting ' );
109
+ throw new Exception ('uni序號為必填( TradeNo is not setting) ' );
111
110
}
112
111
break ;
113
112
case 'credit_bind_cancel ' : // 信用卡token取消(約定/記憶卡號)
114
113
if ($ this ->encryptInfo ['UseTokenType ' ] == null || $ this ->encryptInfo ['UseTokenType ' ] == '' ) {
115
- throw new Exception ('UseTokenType is not setting ' );
114
+ throw new Exception ('信用卡Token類型為必填( UseTokenType is not setting) ' );
116
115
}
117
116
if ($ this ->encryptInfo ['BindVal ' ] == null || $ this ->encryptInfo ['BindVal ' ] == '' ) {
118
- throw new Exception ('BindVal is not setting ' );
117
+ throw new Exception ('綁定回傳值 /信用卡Token( BindVal is not setting) ' );
119
118
}
120
119
break ;
121
120
case 'trade_refund_icash ' : // 愛金卡退款(ICASH)
122
121
case 'trade_refund_aftee ' : // 後支付退款(AFTEE)
123
122
if ($ this ->encryptInfo ['TradeNo ' ] == null || $ this ->encryptInfo ['TradeNo ' ] == '' ) {
124
- throw new Exception ('TradeNo is not setting ' );
123
+ throw new Exception ('uni序號為必填( TradeNo is not setting) ' );
125
124
}
126
125
if ($ this ->encryptInfo ['TradeAmt ' ] == null || $ this ->encryptInfo ['TradeAmt ' ] == '' ) {
127
- throw new Exception ('TradeAmt is not setting ' );
126
+ throw new Exception ('訂單金額為必填( TradeAmt is not setting) ' );
128
127
}
129
128
break ;
130
129
case 'trade_query ' : // 交易查詢
131
130
case 'credit_bind_query ' : // 信用卡token查詢(約定)
132
131
break ;
133
132
default :
134
- throw new Exception ('Unknown params ' );
133
+ throw new Exception ('未提供該參數類型( Unknown params) ' );
135
134
break ;
136
135
}
137
136
$ this ->SetParams ($ contrast [$ tradeType ]);
@@ -162,7 +161,7 @@ public function ResultProcess($result)
162
161
} else {
163
162
$ resultArr = json_decode ($ result , true );
164
163
if (!is_array ($ resultArr )) {
165
- throw new Exception ('Result must be an array ' );
164
+ throw new Exception ('傳入參數需為陣列( Result must be an array) ' );
166
165
}
167
166
}
168
167
if ("ERROR " == $ resultArr ['Status ' ]) {
@@ -172,15 +171,15 @@ public function ResultProcess($result)
172
171
if (isset ($ resultArr ['HashInfo ' ])) {
173
172
$ chkHash = $ this ->HashInfo ($ resultArr ['EncryptInfo ' ]);
174
173
if ($ chkHash != $ resultArr ['HashInfo ' ]) {
175
- throw new Exception ('Hash mismatch ' );
174
+ throw new Exception ('Hash值比對失敗( Hash mismatch) ' );
176
175
}
177
176
$ resultArr ['EncryptInfo ' ] = $ this ->Decrypt ($ resultArr ['EncryptInfo ' ]);
178
177
return ['success ' => true , 'message ' => $ resultArr ];
179
178
} else {
180
- throw new Exception ('missing HashInfo ' );
179
+ throw new Exception ('缺少Hash資訊( missing HashInfo) ' );
181
180
}
182
181
} else {
183
- throw new Exception ('missing EncryptInfo ' );
182
+ throw new Exception ('缺少加密字串( missing EncryptInfo) ' );
184
183
}
185
184
} catch (Exception $ e ) {
186
185
return ['success ' => false , 'message ' => $ e ->getMessage ()];
@@ -195,10 +194,10 @@ private function CheckParams()
195
194
{
196
195
try {
197
196
if ($ this ->encryptInfo ['MerID ' ] == null || $ this ->encryptInfo ['MerID ' ] == '' ) {
198
- throw new Exception ('MerID is not setting ' );
197
+ throw new Exception ('商店代號為必填( MerID is not setting) ' );
199
198
}
200
199
if ($ this ->encryptInfo ['Timestamp ' ] == null || $ this ->encryptInfo ['Timestamp ' ] == '' ) {
201
- throw new Exception ('Timestamp is not setting ' );
200
+ throw new Exception ('時間戳記為必填( Timestamp is not setting) ' );
202
201
}
203
202
return ['success ' => true , 'message ' => 'params is set correctly ' ];
204
203
} catch (Exception $ e ) {
0 commit comments