Toggle navigation
Toggle navigation
This project
Loading...
Sign in
fe
/
YOHOBUYPC
·
Commits
Go to a project
GitLab
Go to group
Project
Activity
Files
Commits
Pipelines
0
Builds
0
Graphs
Milestones
Issues
0
Merge Requests
2
Members
Labels
Wiki
Forks
Network
Create a new issue
Download as
Email Patches
Plain Diff
Browse Files
Authored by
Rock Zhang
9 years ago
Commit
21f7383ad4406ec73ee1e0a4be382f64e999ada0
1 parent
5f4cf207
修复微信扫码支付和银联支付回调的bug
Code Review By Rock Zhang
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
47 additions
and
40 deletions
library/WebPlugin/Pay/Wechatqrcode/Service.php
library/WebPlugin/Pay/weixin/PayNotifyCallBack.php
library/WebPlugin/Pay/weixin/lib/WxPayConfig.php
library/WebPlugin/Pay/weixin/lib/WxPayNotify.php
yohobuy/www.yohobuy.com/application/models/Shopping/Pay.php
yohobuy/www.yohobuy.com/application/modules/Pay/controllers/Notice.php
yohobuy/www.yohobuy.com/application/modules/Pay/controllers/Wechatqrcode.php
library/WebPlugin/Pay/Wechatqrcode/Service.php
View file @
21f7383
...
...
@@ -6,6 +6,8 @@ use WebPlugin\Pay\PayAbstract;
use
WebPlugin\Pay\Reqparams
;
use
WebPlugin\Pay\Rspparams
;
use
WebPlugin\Pay\Signature
;
use
WebPlugin\Pay\weixin\lib\WxPayApi
;
use
WebPlugin\Pay\weixin\lib\WxPayOrderQuery
;
class
Service
extends
PayAbstract
{
...
...
@@ -74,25 +76,33 @@ class Service extends PayAbstract
return
array
(
'pay_url'
=>
$payUrl
);
}
public
function
parseResponse
(
array
$
arrResponse
)
{
public
function
parseResponse
(
array
$
data
)
{
/* 返回示例
* http://www.yohobuy.com/pay/notice/wechatqrcodereturn?ordercode=93465435
*/
// 组装微信支付的订单号
$tradeNo
=
'YOHOBuy_'
.
$data
[
'orderCode'
];
$input
=
new
WxPayOrderQuery
();
$input
->
SetOut_trade_no
(
$tradeNo
);
$result
=
WxPayApi
::
orderQuery
(
$input
);
$rsp
=
new
Rspparams
();
if
(
$arrResponse
[
'payResult'
]
==
200
){
// 支付成功
if
(
array_key_exists
(
"return_code"
,
$result
)
&&
array_key_exists
(
"result_code"
,
$result
)
&&
$result
[
"return_code"
]
==
"SUCCESS"
&&
$result
[
"result_code"
]
==
"SUCCESS"
){
$rsp
->
payResult
=
200
;
$rsp
->
bankName
=
"WX"
;
$rsp
->
orderCode
=
$arrResponse
[
'order_code'
];
$rsp
->
payTime
=
$arrResponse
[
"arrive_time"
];
$rsp
->
totalFee
=
$arrResponse
[
"amount"
];
$rsp
->
orderCode
=
$data
[
'orderCode'
];
$rsp
->
payTime
=
$result
[
"time_end"
];
$rsp
->
totalFee
=
$result
[
"total_fee"
];
$rsp
->
resultMsg
=
'支付成功'
;
//添加支付订单号和交易号
$rsp
->
payOrderCode
=
$arrResponse
[
"order_code"
];
$rsp
->
tradeNo
=
""
;
$rsp
->
bankBillNo
=
""
;
$rsp
->
payOrderCode
=
$data
[
"orderCode"
];
$rsp
->
tradeNo
=
$result
[
"out_trade_no"
];
$rsp
->
bankBillNo
=
$result
[
'bank_type'
];
}
else
{
$rsp
->
payResult
=
-
1
;
}
return
$rsp
;
}
...
...
library/WebPlugin/Pay/weixin/PayNotifyCallBack.php
View file @
21f7383
...
...
@@ -4,6 +4,7 @@ namespace WebPlugin\Pay\weixin;
use
WebPlugin\Pay\weixin\lib\WxPayApi
;
use
WebPlugin\Pay\weixin\lib\WxPayNotify
;
use
WebPlugin\Pay\weixin\lib\WxPayOrderQuery
;
class
PayNotifyCallBack
extends
WxPayNotify
{
...
...
library/WebPlugin/Pay/weixin/lib/WxPayConfig.php
View file @
21f7383
...
...
@@ -31,7 +31,7 @@ class WxPayConfig
const
APPSECRET
=
'ce21ae4a3f93852279175a167e54509b'
;
//=======【异步通知url设置】===================================
//异步通知url,商户根据实际开发过程设定
const
NOTIFY_URL
=
'http://www.yohobuy.com/pay/notice/wechatqrcode
return
'
;
const
NOTIFY_URL
=
'http://www.yohobuy.com/pay/notice/wechatqrcode
notify
'
;
//=======【证书路径设置】=====================================
/**
* TODO:设置商户证书路径
...
...
library/WebPlugin/Pay/weixin/lib/WxPayNotify.php
View file @
21f7383
...
...
@@ -80,7 +80,7 @@ class WxPayNotify extends WxPayNotifyReply
{
//如果需要签名
if
(
$needSign
==
true
&&
$this
->
GetReturn_code
(
$return_code
)
==
"SUCCESS"
)
{
$this
->
GetReturn_code
()
==
"SUCCESS"
)
{
$this
->
SetSign
();
}
WxpayApi
::
replyNotify
(
$this
->
ToXml
());
...
...
yohobuy/www.yohobuy.com/application/models/Shopping/Pay.php
View file @
21f7383
...
...
@@ -342,10 +342,9 @@ class PayModel
*
* @param int $uid 用户ID
* @param string $orderCode 订单号
* @param int $paymentCode 支付方式ID
* @return array
*/
public
static
function
weixinQrcode
(
$uid
,
$orderCode
,
$paymentCode
)
public
static
function
weixinQrcode
(
$uid
,
$orderCode
)
{
$result
=
array
();
...
...
yohobuy/www.yohobuy.com/application/modules/Pay/controllers/Notice.php
View file @
21f7383
...
...
@@ -2,9 +2,9 @@
use
Action\WebAction
;
use
Shopping\PayModel
;
use
WebPlugin\Helpers
;
use
WebPlugin\Pay\PayFactory
;
use
WebPlugin\Pay\Rspparams
;
use
WebPlugin\Pay\weixin\PayNotifyCallBack
;
/**
* 支付Notice
...
...
@@ -237,24 +237,34 @@ class NoticeController extends WebAction
}
/**
* 微信扫码支付返回返回
* 微信扫码支付结果商户通知地址
*/
public
function
wechatqrcodenotifyAction
()
{
$notify
=
new
PayNotifyCallBack
();
$notify
->
handle
(
false
);
}
/**
* 微信扫码支付返回
*/
public
function
wechatqrcodereturnAction
()
{
//判断是否登录
$uid
=
$this
->
auditJumpLogin
();
$dealResult
=
array
(
'code'
=>
500
,
'message'
=>
'支付失败'
);
do
{
$orderCode
=
isset
(
$_GET
[
'order_code'
])
?
$_GET
[
'order_code'
]
:
0
;
if
(
empty
(
$orderCode
))
{
$dealResult
=
array
(
'code'
=>
500
,
'message'
=>
'支付失败'
);
break
;
}
$dealResult
=
PayModel
::
getPayDetail
(
$uid
,
$orderCode
);
$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
);
...
...
@@ -266,23 +276,11 @@ class NoticeController extends WebAction
*/
public
function
unionpaywebreturnAction
()
{
//判断是否登录
$uid
=
$this
->
auditJumpLogin
();
do
{
$orderCode
=
isset
(
$_GET
[
'order_code'
])
?
$_GET
[
'order_code'
]
:
0
;
if
(
empty
(
$orderCode
))
{
$dealResult
=
array
(
'code'
=>
500
,
'message'
=>
'支付失败'
);
break
;
}
$dealResult
=
PayModel
::
getPayDetail
(
$uid
,
$orderCode
);
$dealResult
[
'payData'
]
=
array
(
'payWay'
=>
'银联在线支付'
);
}
while
(
false
);
$payment
=
PayModel
::
getPaymentById
(
25
);
$payService
=
PayFactory
::
factory
(
$payment
);
$res
=
$payService
->
parseResponse
(
$_REQUEST
);
$dealResult
=
$this
->
payResultProc
(
$res
,
25
);
$dealResult
[
'payData'
]
=
array
(
'payWay'
=>
'银联在线支付'
);
$this
->
commonShowResult
(
$dealResult
);
}
...
...
yohobuy/www.yohobuy.com/application/modules/Pay/controllers/Wechatqrcode.php
View file @
21f7383
...
...
@@ -19,8 +19,7 @@ class WechatqrcodeController extends WebAction
}
$orderCode
=
$this
->
get
(
'order_code'
,
$this
->
get
(
'ordercode'
));
$paymentCode
=
$this
->
get
(
'payment_code'
);
$data
=
PayModel
::
weixinQrcode
(
$uid
,
$orderCode
,
$paymentCode
);
$data
=
PayModel
::
weixinQrcode
(
$uid
,
$orderCode
);
if
(
isset
(
$data
[
'error'
]))
{
$this
->
helpJsRedirect
(
$data
[
'message'
]);
}
...
...
Please
register
or
login
to post a comment