Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
ldy
/
payment
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit cf69edc0
authored
Sep 15, 2020
by
Administrator
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master-LTF' into 'master'
Master ltf See merge request !1
2 parents
93ef1753
a21d9bb4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
63 additions
and
32 deletions
examples/ltfpay/barCharge.php
src/Common/LTFpay/Data/Charge/ChargeBaseData.php
src/Notify/LTFNotify.php
examples/ltfpay/barCharge.php
View file @
cf69edc
...
...
@@ -25,12 +25,13 @@ $config = [
$payData
=
[
'out_trade_no'
=>
'2019062017085196425851101912'
,
'refund_no'
=>
'2019062017085196425851101912'
,
'total_fee'
=>
0.9
];
//2019062017085196425851101985
try
{
$ret
=
C
lose
::
run
(
Config
::
LTF_CHARG
E
,
$config
,
$payData
);
$ret
=
C
harge
::
run
(
Config
::
LTF_CHANNEL_LIT
E
,
$config
,
$payData
);
}
catch
(
PayException
$e
){
exit
(
$e
->
errorMessage
());
}
...
...
src/Common/LTFpay/Data/Charge/ChargeBaseData.php
View file @
cf69edc
...
...
@@ -17,7 +17,7 @@ abstract class ChargeBaseData extends LTFBaseData{
protected
function
checkDataParam
(){
// TODO: Implement checkDataParam() method.
// 检查金额不能低于0.01
if
(
$this
->
total_fee
<
1
)
{
if
(
$this
->
total_fee
<
0.0
1
)
{
throw
new
PayException
(
'支付金额不能低于 '
.
Config
::
PAY_MIN_FEE
.
' 元'
);
}
...
...
src/Notify/LTFNotify.php
View file @
cf69edc
...
...
@@ -5,7 +5,7 @@ namespace Payment\Notify;
use
Payment\Common\LTFConfig
;
use
Payment\Common\PayException
;
use
Payment\Config
;
use
Payment\Utils\
DataParser
;
use
Payment\Utils\
ArrayUtil
;
class
LTFNotify
extends
NotifyStrategy
{
...
...
@@ -31,13 +31,19 @@ class LTFNotify extends NotifyStrategy{
* @return array|false
*/
public
function
getNotifyData
(){
$params
=
[];
$data
=
$_POST
[
'req'
]
??
file_get_contents
(
'php://input'
);
if
(
empty
(
$data
))
return
false
;
$params
=
DataParser
::
toArray
(
urldecode
(
$data
));
if
(
empty
(
$params
)
||
count
(
$params
)
<
1
)
return
false
;
foreach
(
$params
as
$key
=>
&
$value
)
$value
=
is_array
(
$value
)
&&
empty
(
$value
)
?
''
:
$value
;
unset
(
$value
);
$params
=
array
();
//支持直接读取input流
$data
=
@
file_get_contents
(
'php://input'
);
if
(
!
empty
(
$data
)){
$inputArray
=
json_decode
(
$data
,
true
);
$params
=
array_merge
(
$params
,
$inputArray
);
}
if
(
count
(
$params
)
<
1
){
//如果参数为空,则不进行处理
return
false
;
}
return
$params
;
// TODO: Implement getNotifyData() method.
}
...
...
@@ -48,48 +54,72 @@ class LTFNotify extends NotifyStrategy{
*
* @param array $data 由 $this->getNotifyData() 返回的数据
* @return boolean
* @throws \Exception
*/
public
function
checkNotifyData
(
array
$data
){
if
(
$data
[
'code'
]
!=
'SUCCESS'
)
return
false
;
if
(
$data
[
'code'
]
!=
'SUCCESS'
)
return
false
;
return
$this
->
verifySign
(
$data
);
// TODO: Implement checkNotifyData() method.
}
/**
* 检查数据是否被篡改过
*
* @param array $retData
* @return bool
* @throws \Exception
*/
protected
function
verifySign
(
array
$retData
)
{
$retSign
=
$retData
[
'sign'
]
??
''
;
protected
function
verifySign
(
array
$retData
){
$retSign
=
$retData
[
'sign'
];
//先不验证加密
return
true
;
$data
=
ArrayUtil
::
removeKeys
(
$retData
,
[
'sign'
]);
$values
=
[
'return_code'
=>
$data
[
'code'
],
'return_msg'
=>
$data
[
'msg'
],
'out_trade_no'
=>
$data
[
'outTradeNo'
],
'transaction_id'
=>
$data
[
'transactionId'
],
'pay_type'
=>
$data
[
'payType'
],
'total_fee'
=>
$data
[
'totalAmount'
],
'user_id'
=>
$data
[
'buyerId'
],
'out_transaction_id'
=>
$data
[
'outTransactionId'
],
];
$values
=
ArrayUtil
::
paraFilter
(
$values
);
// $values = ArrayUtil::arraySort($values);
$signStr
=
ArrayUtil
::
createLinkstring
(
$values
);
switch
(
$this
->
config
->
signType
){
case
'MD5'
:
$sign
=
md5
(
$signStr
);
break
;
default
:
$sign
=
''
;
}
return
strtoupper
(
$sign
)
===
strtoupper
(
$retSign
);
}
/**
* 向客户端返回必要的数据
*
* @param array $data
回调机构返回的回调通知数据
* @return
array|false
* @param array $data
* @return
void
*/
protected
function
getRetData
(
array
$data
){
// TODO: Implement getRetData() method.
if
(
$this
->
config
->
returnRaw
)
return
array_merge
(
$data
,
[
'channel'
=>
Config
::
LTF_CHARGE
]);
$retData
=
[
'ins_cd'
=>
$data
[
'ins_cd'
],
//机构号
'mchnt_cd'
=>
$data
[
'mchnt_cd'
],
//商户号
'term_id'
=>
$data
[
'term_id'
]
??
''
,
//终端号
'user_id'
=>
$data
[
'user_id'
]
??
''
,
//用户在商户的id
'buyer_id'
=>
$data
[
'reserved_buyer_logon_id'
]
??
''
,
//买家在渠道登录账号
'pay_time'
=>
date
(
'Y-m-d H:i:s'
,
strtotime
(
$data
[
'txn_fin_ts'
])),
//支付完成时间
'amount'
=>
$data
[
'order_amt'
],
//订单金额
'amount_settle'
=>
$data
[
'settle_order_amt'
],
//应结订单金额
'transaction_id'
=>
$data
[
'transaction_id'
]
??
''
,
//渠道交易流水号
'order_no'
=>
$data
[
'mchnt_order_no'
]
??
''
,
//商户订单号, 商户系统内部的订单号
'return_param'
=>
$data
[
'reserved_addn_inf'
]
??
''
,
//附加数据
'channel'
=>
Config
::
WX_CHARGE
,
//通道
'return_code'
=>
$data
[
'code'
],
'return_msg'
=>
$data
[
'msg'
],
'out_trade_no'
=>
$data
[
'outTradeNo'
],
'transaction_id'
=>
$data
[
'transactionId'
],
'pay_type'
=>
$data
[
'payType'
],
'total_fee'
=>
$data
[
'totalAmount'
],
'user_id'
=>
$data
[
'buyerId'
],
'out_transaction_id'
=>
$data
[
'outTransactionId'
],
'pay_time'
=>
$data
[
'payTime'
],
'channel'
=>
Config
::
LTF_CHARGE
,
];
return
$retData
;
}
...
...
@@ -101,7 +131,7 @@ class LTFNotify extends NotifyStrategy{
* @return mixed
*/
protected
function
replyNotify
(
$flag
,
$msg
=
'OK'
){
return
(
$flag
?
1
:
0
);
return
(
$flag
?
true
:
false
);
// TODO: Implement replyNotify() method.
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment