Notice.php
13.2 KB
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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
<?php
use Action\WebAction;
use Shopping\PayModel;
use WebPlugin\Pay\PayFactory;
use WebPlugin\Pay\Rspparams;
use WebPlugin\Pay\weixin\PayNotifyCallBack;
use WebPlugin\PhpLog;
/**
* 支付Notice
*/
class NoticeController extends WebAction
{
// 日志等级,2表示记录信息等级的日志
const LOG_LEVEL = 2;
// 向回调通知有关调用日志
const ORDER_STATUS_LOG = '/Data/logs/pc_pay/order_status';
// 存储的UID键名
const SESSION_UID_KEY = 'payUserid';
private $log = null;
public function init() {
parent::init();
$this->log = new PhpLog(self::ORDER_STATUS_LOG, 'PRC', self::LOG_LEVEL);
}
/**
* 支付宝后台服务器返回,主要是用于补单
*/
public function alipaynoticeAction()
{
$payment = PayModel::getPaymentById(2);
$payService = PayFactory::factory($payment);
$this->log->LogInfo("begin alipaynoticeAction");
$res = $payService->parseResponse($_POST); //支付宝通知使用的
if ($res->payResult != -1) {
$this->payResultProc($res, 2);
echo "success";
}
exit();
}
/**
* 支付宝浏览器端返回
*/
public function alipayreturnAction()
{
$this->log->LogInfo("begin alipayreturnAction");
$payment = PayModel::getPaymentById(2);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$dealResult = $this->payResultProc($res, 2);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
}
/**
* 支付宝二维码支付
*/
public function alibarcodenoticeAction()
{
$this->log->LogInfo("begin alibarcodenoticeAction");
$payment = PayModel::getPaymentById(17);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
if ($res->payResult != -1) {
$this->payResultProc($res, 17);
echo "success";
}
exit();
}
/**
* 支付宝二维码支付浏览器端返回
*/
public function alibarcodereturnAction()
{
$this->log->LogInfo("begin alibarcodereturnAction");
$payment = PayModel::getPaymentById(17);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$dealResult = $this->payResultProc($res, 17);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
}
/**
* 通联支付
*/
public function allinpaynoticeAction()
{
$this->log->LogInfo("begin allinpaynoticeAction");
$payment = PayModel::getPaymentById(16);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
if ($res->payResult != -1) {
$this->payResultProc($res, 16);
echo "success";
}
exit();
}
/**
* 通联支付返回
*/
public function allinpayreturnAction()
{
$this->log->LogInfo("begin allinpayreturnAction");
$payment = PayModel::getPaymentById(16);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$dealResult = $this->payResultProc($res, 16);
$dealResult['payData'] = array('payWay' => '通联支付');
$this->commonShowResult($dealResult);
}
/**
* 支付宝快捷网关浏览器回复
*/
public function aliexpressgatewayreturnAction()
{
$this->log->LogInfo("begin aliexpressgatewayreturnAction");
$payment = PayModel::getPaymentById(13);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$dealResult = $this->payResultProc($res, 13);
$dealResult['payData'] = array('payWay' => '支付宝');
$this->commonShowResult($dealResult);
}
/**
* 支付宝快捷网关自动对账回复
*/
public function aliexpressgatewaynoticeAction()
{
$this->log->LogInfo("begin aliexpressgatewaynoticeAction");
$payment = PayModel::getPaymentById(13);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
if ($res->payResult != -1) {
$this->payResultProc($res, 13);
echo "success";
}
exit();
}
/*
* 支付宝银行支付回调(用于后台同步)
*/
public function alibanknoticeAction()
{
$this->log->LogInfo("begin alibanknoticeAction");
$payment = PayModel::getPaymentById(12);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
if ($res->payResult != -1) {
$this->payResultProc($res, 12);
echo "success";
}
exit();
}
/*
* 支付宝银行支付回调(用于前台同步)
*/
public function alibankreturnAction()
{
$this->log->LogInfo("begin alibanknoticeAction");
$payment = PayModel::getPaymentById(12);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_GET);
$dealResult = $this->payResultProc($res, 12);
$dealResult['payData'] = array('payWay' => '银行卡');
$this->commonShowResult($dealResult);
}
/**
* 网银信用卡
*/
public function chinabankAction()
{
$this->log->LogInfo("begin chinabankAction");
$payment = PayModel::getPaymentById(4);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$dealResult = $this->payResultProc($res, 4);
$dealResult['payData'] = array('payWay' => '网银在线');
$this->commonShowResult($dealResult);
}
/**
* 网银在线自动接收
*/
public function chinabankautorevAction()
{
$this->log->LogInfo("begin chinabankautorevAction");
$payment = PayModel::getPaymentById(4);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
if ($res->payResult != -1) {
$this->payResultProc($res, 4);
echo "ok";
} else {
echo 'error';
}
exit();
}
/**
* 腾讯财付通的回应
*/
public function tenpayAction()
{
$this->log->LogInfo("begin tenpayAction");
$payment = PayModel::getPaymentById(1);
$payService = PayFactory::factory($payment);
$rspParams = $payService->parseResponse($_GET); //财付通是以get方式回复的。
$this->payResultProc($rspParams, 1);
}
/**
* 盛付通浏览器返回
* Enter description here ...
*/
public function shengpayreturnAction()
{
$this->log->LogInfo("begin shengpayreturnAction");
$payment = PayModel::getPaymentById(11);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
$dealResult = $this->payResultProc($res, 11);
$dealResult['payData'] = array('payWay' => '盛付通');
$this->commonShowResult($dealResult);
}
/**
* 盛付通服务器端返回
*/
public function shengpaynoticeAction()
{
$this->log->LogInfo("begin shengpaynoticeAction");
$payment = PayModel::getPaymentById(11);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST);
if ($res->payResult != -1) {
$this->payResultProc($res, 11);
echo "OK";
}
exit();
}
/**
* jsonPcallback响应订单支付状态
*/
public function wechatcallbackAction()
{
$this->log->LogInfo("begin wechatcallbackAction");
$callback = $this->get('callback');
$orderCode = $this->get('ordercode');
$uid = $this->getUid(true);
$response = PayModel::checkWechatPayStatus($uid, $orderCode);
$this->helpJsonCallbackResult($callback, $response['code'], $response['message']);
}
/**
* 微信扫码支付结果商户通知地址
*/
public function wechatqrcodenotifyAction()
{
$this->log->LogInfo("begin wechatqrcodenotifyAction");
$uid = $this->getUid();
if (empty($uid)) { // cookie中获取为空时再从之前保存的session中获取
$uid = $this->getSession(self::SESSION_UID_KEY);
$this->setSession(self::SESSION_UID_KEY, null);
}
$notify = new PayNotifyCallBack($uid);
$notify->handle(false);
}
/**
* 微信扫码支付返回
*/
public function wechatqrcodereturnAction()
{
$this->log->LogInfo("begin wechatqrcodereturnAction");
$dealResult = array(
'code' => 500,
'message' => '支付失败'
);
do {
$orderCode = isset($_GET['order_code']) ? $_GET['order_code'] : 0;
if (empty($orderCode)) {
break;
}
$payment = PayModel::getPaymentById(21);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse(array('orderCode' => $orderCode));
$dealResult = $this->payResultProc($res, 21);
$dealResult['payData'] = array('payWay' => '微信扫码支付');
} while (false);
$this->commonShowResult($dealResult);
}
/**
* 银联web支付返回
*/
public function unionpaywebreturnAction()
{
$this->log->LogInfo("begin unionpaywebreturnAction");
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
$dealResult = $this->payResultProc($res, 25);
$dealResult['payData'] = array('payWay' => '银联在线支付');
$this->commonShowResult($dealResult);
}
/**
* 银联支付成功后台回调响应
*/
public function unionpaywebnoticeAction()
{
$this->log->LogInfo("begin unionpaywebnoticeAction");
$payment = PayModel::getPaymentById(25);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_REQUEST);
if ($res->payResult != -1) {
$this->payResultProc($res, 25);
echo "OK";
}
exit();
}
/**
* 支付宝手机支付(极简)的返回
*/
public function alimobilenoticeminiAction()
{
$this->log->LogInfo("begin alimobilenoticeminiAction");
$payment = PayModel::getPaymentById(20);
$payService = PayFactory::factory($payment);
$res = $payService->parseResponse($_POST); //支付宝通知使用的
if ($res->payResult != -1) {
$this->payResultProc($res, 20);
echo "OK";
} else {
echo 'faile';
}
exit();
}
/**
* 通用显示结果的方法
* @param array $dealResult
*/
private function commonShowResult($dealResult)
{
$code = $dealResult['code'];
$view = 'wechatqrcodereturn';
$data = array(
'headerData' => true,
'payData' => $dealResult['payData']
);
if ($code == 200) {
$view = 'index';
$data = array('payNotice' => $dealResult['data']);
}
//头部导航
$this->setSimpleHeader();
$this->_view->display($view, $data);
}
/**
* 处理支付返回的数据
*
* @param Rspparams $payResult 支付返回的结果
* @param $payment 支付方式id
* @return array
*/
private function payResultProc($payResult, $payment)
{
// 初始化日志
$log = $this->log;
$log->LogInfo('================开始验证登录状态============');
$log->LogInfo('================支付结果数据为============');
$log->LogInfo(var_export($payResult, true));
//判断是否登录
$uid = $this->getUid();
if (empty($uid)) { // cookie中获取为空时再从之前保存的session中获取
$uid = $this->getSession(self::SESSION_UID_KEY);
$this->setSession(self::SESSION_UID_KEY, null);
}
$log->LogInfo('================已登录,获取到用户ID============');
$result = array(
'code' => 500,
'message' => '支付失败'
);
if ($payResult->payResult == 200) {
//支付成功
$result = PayModel::procOrderData($uid, $payResult, $payment);
}
$log->LogInfo('================支付结果为============');
$log->LogInfo(var_export($result, true));
return $result;
}
}