Service.php
2.32 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
<?php
namespace WebPlugin\Pay\Alimobilemini;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Rspparams;
use WebPlugin\UdpLog;
/**
* 手机支付返回
* @author tongds
*
*/
class Service extends PayAbstract
{
public $config;
private $utils;
public function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'alimobilemini';
$this->utils = new Utils();
$this->config = new Config();
}
/**
* 处理支付宝极简支付的结果
*
* @param array $arrResponse
* @return Rspparams
*/
public function parseResponse(array $arrResponse)
{
$rsp = new Rspparams();
// ksort($arrResponse);
// ##组织代签名字符串#################
// $sign=$arrResponse['sign'];
// foreach($arrResponse as $a =>$v)
// {
// if(in_array($a,array('sign','sign_type')) || $v=="") continue;
// $data[]=$a.'='.$v;
// }
// $datastr=implode("&", $data);
// ##################################
UdpLog::info("【{$this->logProjectPrefix}-支付宝极简支付】,function:parseResponse,参数", $arrResponse);
$isVerify = $this->utils->getSignVeryfy($arrResponse);
if ($isVerify) {
//验证成功
$rsp->bankName = "";
$rsp->orderCode = $arrResponse['out_trade_no'];
$rsp->payResult = $this->convertResult($arrResponse['trade_status']);
$rsp->payTime = $arrResponse["gmt_create"];
$rsp->totalFee = $arrResponse["total_fee"];
$rsp->resultMsg = $arrResponse["trade_no"];
//添加支付订单号和交易号
$rsp->payOrderCode = $arrResponse['out_trade_no'];
$rsp->tradeNo = $arrResponse['trade_no'];
$rsp->bankBillNo = "";
} else {
//不成功
$rsp->payResult = -1;
}
UdpLog::info("【{$this->logProjectPrefix}-支付宝极简支付】,function:parseResponse,处理结果", $rsp);
return $rsp;
}
/**
* 转换结果
*
* @param string $resultCode 返回码
* @return int
*/
protected function convertResult($resultCode)
{
if ($resultCode == "TRADE_SUCCESS" || $resultCode == "TRADE_FINISHED") {
return 200;
}
return -1;
}
}