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 f9a43093
authored
Mar 27, 2019
by
yeran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
update some bugs
1 parent
d05e5fdf
Hide whitespace changes
Inline
Side-by-side
Showing
22 changed files
with
151 additions
and
32 deletions
examples/sw/liteCharge.php
src/Common/BaseData.php
src/Common/Sw/Data/BackBarChargeData.php
src/Common/Sw/Data/BackFaceChargeData.php
src/Common/Sw/Data/BackFaceInfoData.php
src/Common/Sw/Data/BackLiteChargeData.php
src/Common/Sw/Data/BackPubChargeData.php
src/Common/Sw/Data/BackRefundData.php
src/Common/Sw/Data/BackScanChargeData.php
src/Common/Sw/Data/Cancel/BackCancelData.php
src/Common/Sw/Data/Cancel/BackCloseData.php
src/Common/Sw/Data/Cancel/CancelData.php
src/Common/Sw/Data/Cancel/CloseData.php
src/Common/Sw/Data/Charge/BarChargeData.php
src/Common/Sw/Data/Charge/FaceChargeData.php
src/Common/Sw/Data/Charge/FaceInfoData.php
src/Common/Sw/Data/Charge/LiteChargeData.php
src/Common/Sw/Data/Charge/PubChargeData.php
src/Common/Sw/Data/Charge/ScanChargeData.php
src/Common/Sw/Data/Query/ChargeQueryData.php
src/Common/Sw/Data/RefundData.php
src/Common/SwConfig.php
examples/sw/liteCharge.php
0 → 100644
View file @
f9a4309
<?php
require_once
__DIR__
.
'/../../autoload.php'
;
use
Payment\Common\PayException
;
use
Payment\Client\Charge
;
use
Payment\Config
;
date_default_timezone_set
(
'Asia/Shanghai'
);
$configStr
=
"
{
\"pay_var\":\"100\",\"pay_type\":\"010\",\"service_id\":\"015\",\"mch_id\":\"858100307000002\",\"merchant_no\":\"858100307000002\",\"terminal_id\":\"30055973\",\"sub_appid\":\"wx24863377e74518f8\",\"app_id\":\"wx24863377e74518f8\",\"limit_pay\":[\"\"],\"access_token\":\"bae3420022594dd9a14703f890765f9e\",\"notify_url\":\"http://www.ledian.com/payments/notify\",\"use_sandbox\":false,\"return_raw\":false
}
"
;
$config
=
json_decode
(
$configStr
,
true
);
// 订单信息
$payDataStr
=
"
{
\"terminal_trace\":\"20190327151722366145505357545320\",\"total_fee\":1,\"order_body\":\"支付测试\",\"open_id\":\"oUlAM0Wp1K1rJEGJ0t__Ls5-qFKE\",\"attach\":\"10054c238f670a2e9649a8b100f20562\"
}
"
;
$payData
=
json_decode
(
$payDataStr
,
true
);
try
{
$ret
=
Charge
::
run
(
Config
::
SW_CHANNEL_LITE
,
$config
,
$payData
);
}
catch
(
PayException
$e
)
{
echo
$e
->
errorMessage
();
exit
;
}
echo
json_encode
(
$ret
,
JSON_UNESCAPED_UNICODE
);
\ No newline at end of file
src/Common/BaseData.php
View file @
f9a4309
...
...
@@ -138,8 +138,9 @@ abstract class BaseData
}
else
if
(
$this
->
channel
===
Config
::
SW_PAY
){
//添加令牌,参数由makesign函数自由控制
$values
=
ArrayUtil
::
removeKeys
(
$data
,
[
'key_sign'
]);
// $values = ArrayUtil::arraySort($values);
$signData
=
$this
->
certainSignData
??
$data
;
$values
=
ArrayUtil
::
removeKeys
(
$signData
,
[
'key_sign'
]);
if
(
$this
->
sign_sort
)
$values
=
ArrayUtil
::
arraySort
(
$values
);
$signStr
=
ArrayUtil
::
createLinkstring
(
$values
);
$this
->
makeSign
(
$signStr
);
...
...
src/Common/Sw/Data/BackBarChargeData.php
View file @
f9a4309
...
...
@@ -13,7 +13,9 @@ namespace Payment\Common\Sw\Data;
*/
class
BackBarChargeData
extends
SwBaseData
{
protected
function
buildData
(){
public
function
getData
()
{
$this
->
retData
[
'package'
]
=
[
'channel_trade_no'
=>
$this
->
channel_trade_no
??
''
,
//通道订单号,微信订单号、支付宝订单号等,返回时不参与签名
...
...
@@ -36,6 +38,12 @@ class BackBarChargeData extends SwBaseData
if
(
$this
->
pay_type
==
'090'
){
//口碑实收金额,pay_type为090时必填
$this
->
retData
[
'package'
][
'receipt_fee'
]
=
$this
->
receipt_fee
;
}
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
(){
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/BackFaceChargeData.php
View file @
f9a4309
...
...
@@ -12,7 +12,8 @@ namespace Payment\Common\Sw\Data;
*/
class
BackFaceChargeData
extends
SwBaseData
{
protected
function
buildData
()
public
function
getData
()
{
$this
->
retData
[
'package'
]
=
[
'channel_trade_no'
=>
$this
->
channel_trade_no
??
''
,
//通道订单号,微信订单号、支付宝订单号等,返回时不参与签名
...
...
@@ -31,6 +32,13 @@ class BackFaceChargeData extends SwBaseData
'order_body'
=>
$this
->
order_body
??
''
,
'attach'
=>
$this
->
attach
??
''
,
];
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/BackFaceInfoData.php
View file @
f9a4309
...
...
@@ -12,7 +12,7 @@ namespace Payment\Common\Sw\Data;
*/
class
BackFaceInfoData
extends
SwBaseData
{
p
rotected
function
build
Data
()
p
ublic
function
get
Data
()
{
$this
->
retData
[
'package'
]
=
[
'authinfo'
=>
$this
->
authinfo
??
''
,
//微信、支付宝人脸识别SDK调用凭证
...
...
@@ -32,6 +32,13 @@ class BackFaceInfoData extends SwBaseData
if
(
$this
->
pay_type
==
'020'
){
//支付宝ZimInitClientData
$this
->
retData
[
'package'
][
'zim_init'
]
=
$this
->
zim_init
;
}
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/BackLiteChargeData.php
View file @
f9a4309
...
...
@@ -13,9 +13,8 @@ use Payment\Common\PayException;
*/
class
BackLiteChargeData
extends
SwBaseData
{
p
rotected
function
build
Data
()
p
ublic
function
get
Data
()
{
$data
=
[];
switch
(
$this
->
pay_type
){
case
'010'
:
{
//微信
$data
=
[
...
...
@@ -53,10 +52,21 @@ class BackLiteChargeData extends SwBaseData
'total_fee'
=>
$this
->
total_fee
,
'out_trade_no'
=>
$this
->
out_trade_no
];
return
parent
::
getData
();
}
protected
function
checkDataParam
()
{
// 对于返回数据不做检查检查
}
/**
* 构建用于支付的签名相关数据
* @return array
*/
protected
function
buildData
()
{
// TODO: Implement buildData() method.
}
}
src/Common/Sw/Data/BackPubChargeData.php
View file @
f9a4309
...
...
@@ -15,7 +15,7 @@ namespace Payment\Common\Sw\Data;
*/
class
BackPubChargeData
extends
SwBaseData
{
p
rotected
function
build
Data
()
p
ublic
function
get
Data
()
{
$data
=
[];
switch
(
$this
->
pay_type
){
...
...
@@ -50,6 +50,14 @@ class BackPubChargeData extends SwBaseData
$this
->
retData
[
'other'
]
=
[
'out_trade_no'
=>
$this
->
out_trade_no
];
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/BackRefundData.php
View file @
f9a4309
...
...
@@ -12,7 +12,8 @@ namespace Payment\Common\Sw\Data;
*/
class
BackRefundData
extends
SwBaseData
{
protected
function
buildData
()
public
function
getData
()
{
$this
->
retData
[
'package'
]
=
[
'refund_fee'
=>
$this
->
refund_fee
,
//退款金额,单位分
...
...
@@ -30,6 +31,14 @@ class BackRefundData extends SwBaseData
'out_trade_no'
=>
$this
->
out_trade_no
,
// 'refund_fee' => $this->refund_fee,//退款金额,单位分
];
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/BackScanChargeData.php
View file @
f9a4309
...
...
@@ -13,7 +13,7 @@ use Payment\Common\PayException;
*/
class
BackScanChargeData
extends
SwBaseData
{
p
rotected
function
build
Data
()
p
ublic
function
get
Data
()
{
$this
->
retData
[
'qr_code'
]
=
$this
->
qr_code
;
//二维码码串
$this
->
retData
[
'other'
]
=
[
...
...
@@ -26,6 +26,14 @@ class BackScanChargeData extends SwBaseData
'total_fee'
=>
$this
->
total_fee
,
'out_trade_no'
=>
$this
->
out_trade_no
];
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/Cancel/BackCancelData.php
View file @
f9a4309
...
...
@@ -13,9 +13,9 @@ use Payment\Common\PayException;
*/
class
BackCancelData
extends
SwBaseData
{
protected
function
buildData
()
{
public
function
getData
()
{
$this
->
retData
[
'package'
]
=
[
'recall'
=>
$this
->
recall
,
//是否重新发起撤销
];
...
...
@@ -30,6 +30,12 @@ class BackCancelData extends SwBaseData
'out_trade_no'
=>
$this
->
out_trade_no
];
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/Cancel/BackCloseData.php
View file @
f9a4309
...
...
@@ -12,9 +12,8 @@ namespace Payment\Common\Sw\Data;
*/
class
BackCloseData
extends
SwBaseData
{
p
rotected
function
build
Data
()
p
ublic
function
get
Data
()
{
$this
->
retData
[
'package'
]
=
[
'result_code'
=>
$this
->
result_code
,
//"业务结果,01成功,表示关单成功,此笔订单不能再发起支付;
];
...
...
@@ -26,6 +25,12 @@ class BackCloseData extends SwBaseData
'terminal_time'
=>
$this
->
terminal_time
??
''
,
];
return
parent
::
getData
();
// TODO: Change the autogenerated stub
}
protected
function
buildData
()
{
}
protected
function
checkDataParam
()
...
...
src/Common/Sw/Data/Cancel/CancelData.php
View file @
f9a4309
...
...
@@ -26,7 +26,7 @@ class CancelData extends ChargeBaseData
protected
function
buildData
(){
$
s
ignData
=
[
$
this
->
certainS
ignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -35,10 +35,10 @@ class CancelData extends ChargeBaseData
'terminal_id'
=>
$this
->
terminal_id
,
'terminal_trace'
=>
$this
->
terminal_trace
,
'terminal_time'
=>
$this
->
terminal_time
,
// 'total_fee' => $this->total_fee, // 金额,单位分
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
];
if
(
isset
(
$this
->
out_trade_no
)){
$signData
[
'out_trade_no'
]
=
$this
->
out_trade_no
;
}
...
...
src/Common/Sw/Data/Cancel/CloseData.php
View file @
f9a4309
...
...
@@ -25,7 +25,7 @@ class CloseData extends ChargeBaseData
protected
function
buildData
(){
$
signData
=
[
$
this
->
certainSignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
//010微信,020支付宝,000自动识别类型
...
...
@@ -36,6 +36,9 @@ class CloseData extends ChargeBaseData
'terminal_time'
=>
$this
->
terminal_time
,
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
out_trade_no
)
&&
!
empty
(
$this
->
out_trade_no
)){
//利楚唯一订单号,优先使用订单号out_trade_no发起撤销,
//在out_trade_no获取异常的情况,可使用当前支付请求的终端交易流水号pay_trace和终端交易时间pay_time发起撤销
...
...
src/Common/Sw/Data/Charge/BarChargeData.php
View file @
f9a4309
...
...
@@ -38,7 +38,7 @@ class BarChargeData extends ChargeBaseData
*/
protected
function
buildData
()
{
$
s
ignData
=
[
$
this
->
certainS
ignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -50,9 +50,8 @@ class BarChargeData extends ChargeBaseData
'auth_no'
=>
$this
->
auth_no
,
//授权码,客户的付款码
'total_fee'
=>
$this
->
total_fee
,
// 金额,单位分
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
sub_appid
)){
$signData
[
'sub_appid'
]
=
$this
->
sub_appid
;
}
...
...
src/Common/Sw/Data/Charge/FaceChargeData.php
View file @
f9a4309
...
...
@@ -35,6 +35,8 @@ class FaceChargeData extends ChargeBaseData
protected
function
buildData
()
{
$this
->
sign_sort
=
true
;
//需要按照字典排序
$signData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
...
...
src/Common/Sw/Data/Charge/FaceInfoData.php
View file @
f9a4309
...
...
@@ -33,6 +33,8 @@ class FaceInfoData extends ChargeBaseData
protected
function
buildData
()
{
$this
->
sign_sort
=
true
;
$signData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
...
...
src/Common/Sw/Data/Charge/LiteChargeData.php
View file @
f9a4309
...
...
@@ -35,7 +35,7 @@ class LiteChargeData extends ChargeBaseData
protected
function
buildData
()
{
$
signData
=
[
$
this
->
certainSignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -49,6 +49,9 @@ class LiteChargeData extends ChargeBaseData
// 'time_expire' => $this->timeout_express,
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
sub_appid
)){
$signData
[
'sub_appid'
]
=
$this
->
sub_appid
;
}
...
...
src/Common/Sw/Data/Charge/PubChargeData.php
View file @
f9a4309
...
...
@@ -37,7 +37,7 @@ class PubChargeData extends ChargeBaseData
protected
function
buildData
()
{
$
s
ignData
=
[
$
this
->
certainS
ignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -49,8 +49,10 @@ class PubChargeData extends ChargeBaseData
'total_fee'
=>
$this
->
total_fee
,
// 金额,单位分
// 'time_expire' => $this->timeout_express,
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
sub_appid
)){
$signData
[
'sub_appid'
]
=
$this
->
sub_appid
;
}
...
...
src/Common/Sw/Data/Charge/ScanChargeData.php
View file @
f9a4309
...
...
@@ -35,7 +35,7 @@ class ScanChargeData extends ChargeBaseData
*/
protected
function
buildData
()
{
$
s
ignData
=
[
$
this
->
certainS
ignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -49,12 +49,13 @@ class ScanChargeData extends ChargeBaseData
// 'time_expire' => $this->timeout_express,
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
sub_appid
)){
$signData
[
'sub_appid'
]
=
$this
->
sub_appid
;
}
// if(isset($this->open_id)){
// $signData['open_id'] = $this->open_id;
// }
if
(
isset
(
$this
->
order_body
)){
$signData
[
'order_body'
]
=
$this
->
order_body
;
}
...
...
src/Common/Sw/Data/Query/ChargeQueryData.php
View file @
f9a4309
...
...
@@ -42,7 +42,7 @@ class ChargeQueryData extends SwBaseData
protected
function
buildData
(){
$
s
ignData
=
[
$
this
->
certainS
ignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -51,9 +51,12 @@ class ChargeQueryData extends SwBaseData
'terminal_id'
=>
$this
->
terminal_id
,
'terminal_trace'
=>
$this
->
terminal_trace
,
//终端查询流水号,填写商户系统的查询流水号
'terminal_time'
=>
$this
->
terminal_time
,
'out_trade_no'
=>
$this
->
out_trade_no
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
pay_trace
)){
//用户标识(微信openid),用于调起微信刷脸SDK
$signData
[
'pay_trace'
]
=
$this
->
pay_trace
;
}
...
...
@@ -61,7 +64,7 @@ class ChargeQueryData extends SwBaseData
$signData
[
'pay_time'
]
=
$this
->
pay_time
;
}
$signData
[
'out_trade_no'
]
=
$this
->
out_trade_no
;
// 金额,单位分
$this
->
retData
=
ArrayUtil
::
paraFilter
(
$this
->
retData
);
}
...
...
src/Common/Sw/Data/RefundData.php
View file @
f9a4309
...
...
@@ -42,10 +42,9 @@ class RefundData extends SwBaseData
}
}
protected
function
buildData
(){
$
s
ignData
=
[
$
this
->
certainS
ignData
=
[
// 基本数据
'pay_ver'
=>
trim
(
$this
->
pay_ver
),
'pay_type'
=>
trim
(
$this
->
pay_type
),
...
...
@@ -58,6 +57,8 @@ class RefundData extends SwBaseData
'out_trade_no'
=>
$this
->
out_trade_no
,
//订单号,查询凭据,利楚订单号、微信订单号、支付宝订单号任意一个
];
$signData
=
array_merge
(
$this
->
certainSignData
,[]);
if
(
isset
(
$this
->
pay_trace
)){
//当前支付终端流水号,与pay_time同时传递
$signData
[
'pay_trace'
]
=
$this
->
pay_trace
;
}
...
...
src/Common/SwConfig.php
View file @
f9a4309
...
...
@@ -24,6 +24,9 @@ final class SwConfig extends ConfigInterface
public
$terminal_time
;
//终端交易时间,yyyyMMddHHmmss,全局统一时间格式
public
$certainSignData
=
null
;
//专门用于签名的数组
public
$sign_sort
=
false
;
//签名是否需要字典排序
// 指定回调页面
public
$notify_url
;
...
...
@@ -129,6 +132,10 @@ final class SwConfig extends ConfigInterface
$this
->
attach
=
trim
(
$config
[
'attach'
]);
}
if
(
key_exists
(
'access_token'
,
$config
))
{
$this
->
access_token
=
trim
(
$config
[
'access_token'
]);
}
// 设置交易开始时间 格式为yyyyMMddHHmmss,在次之前一定要设置时区
$startTime
=
time
();
$this
->
terminal_time
=
date
(
'YmdHis'
,
$startTime
);
...
...
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