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
郝肖肖
9 years ago
Commit
03c54331f9119ab8a9ef07eb792a47586967f17c
1 parent
f46f7962
支付宝 支付notifyurl改成java地址
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
206 additions
and
11 deletions
library/LibModels/Web/Home/CartData.php
library/WebPlugin/Pay/Alipay/Config.php
library/WebPlugin/Pay/Alipay/Service.php
yohobuy/www.yohobuy.com/application/models/Shopping/Payment.php
yohobuy/www.yohobuy.com/application/modules/Pay/controllers/Payreturn.php
yohobuy/www.yohobuy.com/application/modules/Shopping/controllers/Pay.php
library/LibModels/Web/Home/CartData.php
View file @
03c5433
...
...
@@ -496,5 +496,22 @@ class CartData
return
Yohobuy
::
get
(
SearchData
::
getUrl
(
'search'
),
$param
);
}
/**
* 选择支付,校验时间间隔,插入数据
* @param string $uid
* @param string $orderCode
* @param int $payment 14:银联手机支付 15:支付宝手机 18:支付宝wap(wap) 19:微信支付 22:微信wap(wap) 26:QQ钱包手机支付
* @return type
*/
public
static
function
savePrePayInfo
(
$uid
,
$orderCode
,
$payment
)
{
$param
=
Yohobuy
::
param
();
$param
[
'method'
]
=
'app.order.savePrePayInfo'
;
$param
[
'uid'
]
=
$uid
;
$param
[
'orderCode'
]
=
$orderCode
;
$param
[
'payment'
]
=
$payment
;
$param
[
'client_secret'
]
=
Sign
::
getSign
(
$param
);
return
Yohobuy
::
get
(
Yohobuy
::
API_URL
,
$param
);
}
}
...
...
library/WebPlugin/Pay/Alipay/Config.php
View file @
03c5433
...
...
@@ -36,14 +36,14 @@ class Config
* Enter description here ...
* @var String
*/
var
$notify_url
=
"
notice/alipaynotice
"
;
var
$notify_url
=
"
payment/alipay_notify
"
;
/**
* 浏览器的返回
* Enter description here ...
* @var string
*/
var
$return_url
=
"
notice
/alipayreturn"
;
var
$return_url
=
"
/pay/payreturn
/alipayreturn"
;
/**
* 签名方式
...
...
library/WebPlugin/Pay/Alipay/Service.php
View file @
03c5433
...
...
@@ -6,6 +6,8 @@ use WebPlugin\Pay\PayAbstract;
use
WebPlugin\Pay\Reqparams
;
use
WebPlugin\Pay\Rspparams
;
use
WebPlugin\PhpLog
;
use
Api\Yohobuy
;
use
Plugin\Helpers
;
class
Service
extends
PayAbstract
{
...
...
@@ -50,15 +52,15 @@ class Service extends PayAbstract
$this
->
log
->
LogInfo
(
"-----请求参数为---"
);
$this
->
log
->
LogInfo
(
var_export
(
$params
,
true
));
$baseUrl
=
$this
->
getBaseNoticeUrl
(
$params
->
isTest
);
//
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
// $loseTime = intval(($params->orderTime + 7200 -time())/60);
// $loseTime = intval((strtotime(date("Y-m-d 10:00:00", strtotime("+1 day")))-time())/60); //第二天十点
$parameter
=
array
(
'service'
=>
$this
->
config
->
service
,
'partner'
=>
$this
->
config
->
partner
,
'_input_charset'
=>
$this
->
config
->
input_charset
,
'notify_url'
=>
$baseUrl
.
$this
->
config
->
notify_url
,
'return_url'
=>
$baseUrl
.
$this
->
config
->
return_url
,
'notify_url'
=>
Yohobuy
::
SERVICE_URL
.
$this
->
config
->
notify_url
,
'return_url'
=>
Helpers
::
url
(
$this
->
config
->
return_url
),
/* 业务参数 */
'subject'
=>
$params
->
goodsName
,
'out_trade_no'
=>
$params
->
orderCode
,
...
...
@@ -190,9 +192,10 @@ class Service extends PayAbstract
reset
(
$arrResponse
);
$sign
=
''
;
foreach
(
$arrResponse
AS
$key
=>
$val
)
{
if
(
$key
!=
'sign'
&&
$key
!=
'sign_type'
&&
$key
!=
'code'
)
{
$sign
.=
"
$key
=
$val
&"
;
if
(
$key
===
'sign'
||
$key
===
'sign_type'
||
$key
===
'code'
||
$val
===
''
)
{
continue
;
}
$sign
.=
"
$key
=
$val
&"
;
}
$sign
=
substr
(
$sign
,
0
,
-
1
)
.
$this
->
config
->
alipay_key
;
...
...
yohobuy/www.yohobuy.com/application/models/Shopping/Payment.php
0 → 100644
View file @
03c5433
<?php
namespace
Shopping
;
use
LibModels\Web\Home\OrderData
;
use
LibModels\Web\Product\PayData
;
use
Plugin\Helpers
;
use
WebPlugin\Cache
;
use
WebPlugin\Pay\Banks
;
use
WebPlugin\Pay\PayFactory
;
use
WebPlugin\Pay\Reqparams
;
use
WebPlugin\Pay\Rspparams
;
use
WebPlugin\Pay\weixin\lib\WxPayApi
;
use
WebPlugin\Pay\weixin\lib\WxPayConfig
;
use
WebPlugin\Pay\weixin\lib\WxPayNativePay
;
use
WebPlugin\Pay\weixin\lib\WxPayOrderQuery
;
use
WebPlugin\Pay\weixin\lib\WxPayUnifiedOrder
;
/**
* 支付有关方法 改版
* @copyright 2016/5/22 14:19 xiaoxiao<xiaoxiao.hao@yoho.cn>
*/
class
PaymentModel
{
protected
static
$code
=
array
(
'code'
=>
500
,
'message'
=>
'支付失败'
);
// 存储的UID键名
const
SESSION_UID_KEY
=
'payUserid'
;
public
static
function
procOrderData
(
$payResult
)
{
do
{
if
(
empty
(
$payResult
->
orderCode
))
{
self
::
$code
[
'message'
]
=
'未查到订单信息,订单状态更新失败!'
;
break
;
}
$orderCode
=
$payResult
->
orderCode
;
$uid
=
''
;
if
(
USE_CACHE
)
{
// 通过订单号,从缓存记录中获取uid
$uid
=
Cache
::
get
(
self
::
SESSION_UID_KEY
.
$orderCode
);
}
$orderInfo
=
OrderData
::
getOrderDetail
(
$uid
,
$payResult
->
orderCode
);
if
(
empty
(
$orderInfo
[
'data'
]))
{
self
::
$code
[
'message'
]
=
'未查到订单信息,订单状态更新失败!'
;
break
;
}
$orderData
=
$orderInfo
[
'data'
];
$amount
=
$orderData
[
'payment_amount'
];
if
(
$orderData
[
'is_cancel'
]
===
'Y'
)
{
// 给用户发送短信
PayData
::
sendMessage
(
$orderData
[
'mobile'
],
'error_sms'
,
'支付成功,但订单已取消,订单号为'
.
$orderCode
);
self
::
$code
[
'code'
]
=
417
;
self
::
$code
[
'message'
]
=
'支付成功,但订单已取消,需联系客服!'
;
break
;
}
// if ($orderData['payment_status'] === 'N') {
// logup::info(
// '用户支付成功,同步地址返回,查询订单状态为未付款,有可能异步地址还未即时更新状态',
// array('payResult' => $payResult, 'orderData' => $orderData)
// );
// }
// 支付金额与订单金额不一致
if
(
round
(
$amount
,
2
)
!==
round
(
$payResult
->
totalFee
,
2
))
{
self
::
$code
[
'code'
]
=
415
;
self
::
$code
[
'message'
]
=
'支付金额与订单金额不一致,订单状态更新失败!'
;
break
;
}
self
::
$code
[
'code'
]
=
200
;
self
::
$code
[
'message'
]
=
'支付成功,请等待发货'
;
self
::
$code
[
'data'
]
=
array
(
'pay'
=>
$amount
,
'orderNum'
=>
$orderData
[
'order_code'
],
'checkOrderUrl'
=>
Helpers
::
url
(
'/home/orders/detail'
,
array
(
'orderCode'
=>
$orderData
[
'order_code'
])),
'payMode'
=>
(
$orderData
[
'payment_type'
]
==
1
?
'在线支付'
:
'货到付款'
),
'currency'
=>
$orderData
[
'yoho_give_coin'
],
'yohoCoinUrl'
=>
Helpers
::
url
(
'/help'
,
array
(
'category_id'
=>
87
)),
'ordersUrl'
=>
Helpers
::
url
(
'/home/orders'
),
'returnGoodsUrl'
=>
Helpers
::
url
(
'/help'
,
array
(
'category_id'
=>
121
)),
'vipSum'
=>
$amount
,
'vipUrl'
=>
Helpers
::
url
(
'/help'
,
array
(
'category_id'
=>
91
)),
'returnHomeUrl'
=>
Helpers
::
url
(
'/'
)
);
}
while
(
false
);
return
self
::
$code
;
}
}
\ No newline at end of file
...
...
yohobuy/www.yohobuy.com/application/modules/Pay/controllers/Payreturn.php
0 → 100644
View file @
03c5433
<?php
use
Action\WebAction
;
use
Shopping\PayModel
;
use
Shopping\PaymentModel
;
use
WebPlugin\Pay\PayFactory
;
use
WebPlugin\Pay\Rspparams
;
/**
* 支付 同步通知页面
*/
class
PayreturnController
extends
WebAction
{
public
function
init
()
{
parent
::
init
();
}
/**
* 支付宝浏览器端返回
*/
public
function
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
);
}
/**
* 通用显示结果的方法
* @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
(
'../notice/'
.
$view
,
$data
);
}
/**
* 处理支付返回的数据
*
* @param Rspparams $payResult 支付返回的结果
* @param $payment 支付方式id
* @return array
*/
private
function
payResultProc
(
$payResult
,
$payment
)
{
$result
=
array
(
'code'
=>
500
,
'message'
=>
'支付失败'
);
if
(
$payResult
->
payResult
==
200
)
{
//支付成功
$result
=
PaymentModel
::
procOrderData
(
$payResult
,
$payment
);
}
return
$result
;
}
}
...
...
yohobuy/www.yohobuy.com/application/modules/Shopping/controllers/Pay.php
View file @
03c5433
...
...
@@ -4,6 +4,7 @@ use Action\WebAction;
use
Shopping\PayModel
;
use
WebPlugin\Helpers
;
use
LibModels\Web\Home\UserData
;
use
WebPlugin\Cache
;
/**
* 支付相关的控制器
*
...
...
@@ -29,11 +30,14 @@ class PayController extends WebAction
if
(
!
$uid
)
{
$this
->
go
(
Helpers
::
url
(
'/signin.html'
,
array
(
'refer'
=>
$this
->
server
(
'HTTP_REFERER'
,
SITE_MAIN
)))
);
}
// 将用户UID存入session中以便支付成功回调使用
$this
->
setSession
(
self
::
SESSION_UID_KEY
,
$uid
);
// 订单号
$orderCode
=
$this
->
get
(
'order_code'
,
$this
->
get
(
'ordercode'
));
if
(
USE_CACHE
)
{
// 将用户UID存入session中以便支付成功回调使用
$this
->
setSession
(
self
::
SESSION_UID_KEY
,
$uid
);
Cache
::
set
(
self
::
SESSION_UID_KEY
.
$orderCode
,
$uid
,
3600
*
10
);
}
//支付宝快捷支付
$alipayToken
=
$this
->
getSession
(
'alipay_user_token'
);
...
...
Please
register
or
login
to post a comment