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 50ae069b
authored
May 08, 2024
by
yeran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
1 parent
becd7b3d
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
133 additions
and
3 deletions
composer.json
src/Charge/Hsq/HsqJSCharge.php
src/ChargeContext.php
src/Client/Charge.php
src/Common/Hsq/Data/Charge/JSChargeData.php
src/Common/HsqConfig.php
src/Config.php
composer.json
View file @
50ae069
{
"name"
:
"ldy/payment"
,
"type"
:
"library"
,
"version"
:
"3.6.
3
"
,
"version"
:
"3.6.
4
"
,
"description"
:
"支付宝支付、微信支付、招商一网通支付、通联支付、米付支付、利楚扫呗、富友支付、联拓付、易生支付、银盛支付、微诺付、汇收钱 php SDK。"
,
"keywords"
:
[
"alipay"
,
"weixin"
,
"支付宝支付"
,
"微信支付"
,
"通联支付"
,
"集成支付接口SDK"
,
"招商一网通"
,
"一网通"
,
"利楚扫呗"
,
"富友支付"
,
"微诺付"
,
"汇收钱"
],
"homepage"
:
""
,
...
...
src/Charge/Hsq/HsqJSCharge.php
0 → 100644
View file @
50ae069
<?php
namespace
Payment\Charge\Hsq
;
use
Payment\Common\Hsq\Data\BackAppChargeData
;
use
Payment\Common\Hsq\Data\Charge\AppChargeData
;
use
Payment\Common\Hsq\Data\Charge\JSChargeData
;
use
Payment\Common\Hsq\HsqBaseStrategy
;
use
Payment\Common\HsqConfig
;
use
Payment\Common\PayException
;
/**
* HsqJSCharge
*/
class
HsqJSCharge
extends
HsqBaseStrategy
{
public
function
getBuildDataClass
()
{
$this
->
config
->
method
=
HsqConfig
::
JS_ORDER_URL
;
return
JSChargeData
::
class
;
}
protected
function
getReqUrl
(
$url
=
null
)
{
return
parent
::
getReqUrl
(
$url
);
}
/**
* 处理支付的返回值。直接返回与微信文档对应的字段
* @param array $ret
*
* @return array $data 包含以下键
*
* ```php
* $data = [
* 'appId' => '', // 公众号id
* 'package' => '', // 订单详情扩展字符串 统一下单接口返回的prepay_id参数值,提交格式如:prepay_id=***
* 'nonceStr' => '', // 随机字符串
* 'timeStamp' => '', // 时间戳
* 'signType' => '', // 签名算法,暂支持MD5
* 'paySign' => '', // 签名
* ];
* ```
*
* @throws PayException
*/
protected
function
retData
(
array
$ret
)
{
$back
=
new
BackAppChargeData
(
$this
->
config
,
$ret
);
$backData
=
$back
->
getData
();
unset
(
$backData
[
'sign'
]);
return
$backData
;
}
}
src/ChargeContext.php
View file @
50ae069
...
...
@@ -19,6 +19,7 @@ use Payment\Charge\Fu\FuBarCharge;
use
Payment\Charge\Fu\FuPubCharge
;
use
Payment\Charge\Fu\FuScanCharge
;
use
Payment\Charge\Hsq\HsqAppCharge
;
use
Payment\Charge\Hsq\HsqJSCharge
;
use
Payment\Charge\LTF\LTFBarCharge
;
use
Payment\Charge\LTF\LTFLiteCharge
;
use
Payment\Charge\LTF\LTFPayCharge
;
...
...
@@ -228,7 +229,9 @@ class ChargeContext
case
Config
::
HSQ_CHANNEL_APP
:
$this
->
channel
=
new
HsqAppCharge
(
$config
);
break
;
case
Config
::
HSQ_CHANNEL_JS
:
$this
->
channel
=
new
HsqJSCharge
(
$config
);
break
;
default
:
throw
new
PayException
(
'当前支持:支付宝、微信、招商一网通、通联支付、米付支付、扫呗支付、富友支付、联拓富、易生支付、微诺付、慧收钱。'
);
}
...
...
src/Client/Charge.php
View file @
50ae069
...
...
@@ -71,6 +71,8 @@ class Charge
//慧收钱
Config
::
HSQ_CHANNEL_LITE
,
Config
::
HSQ_CHANNEL_APP
,
Config
::
HSQ_CHANNEL_JS
,
];
...
...
src/Common/Hsq/Data/Charge/JSChargeData.php
0 → 100644
View file @
50ae069
<?php
namespace
Payment\Common\Hsq\Data\Charge
;
use
Payment\Common\PayException
;
/**
* Class JSChargeData
* @package Payment\Common\Hsq\Data\Charge
*/
class
JSChargeData
extends
ChargeBaseData
{
/**
* checkDataParam
* @return mixed|void
* @throws PayException
*/
protected
function
checkDataParam
()
{
parent
::
checkDataParam
();
$tradeType
=
$this
->
payType
;
if
(
empty
(
$tradeType
))
throw
new
PayException
(
'订单类型有误(WECHAT_JSAPI、ALI_JSAPI)'
);
$spbillCreateIp
=
$this
->
spbillCreateIp
;
if
(
empty
(
$spbillCreateIp
))
{
$this
->
spbillCreateIp
=
isset
(
$_SERVER
[
'REMOTE_ADDR'
])
?
$_SERVER
[
'REMOTE_ADDR'
]
:
'127.0.0.1'
;
}
}
/**
* 构建用于支付的签名相关数据
* @return array|void
*/
protected
function
buildData
()
{
$memo
=
[
'spbillCreateIp'
=>
$this
->
spbillCreateIp
??
'127.0.0.1'
,
//终端用户IP
'longitude'
=>
$this
->
longitude
,
//经度
'latitude'
=>
$this
->
latitude
,
//纬度
'openid'
=>
$this
->
openid
,
//纬度
'appid'
=>
$this
->
appid
,
//纬度
];
$signContent
=
[
'transNo'
=>
$this
->
transNo
,
//商户订单号
'payType'
=>
$this
->
payType
,
//支付类型
'orderAmt'
=>
intval
(
$this
->
orderAmt
),
//交易金额, 交易金额,单位为:分
'goodsInfo'
=>
$this
->
goodsInfo
,
//商品信息
'returnUrl'
=>
$this
->
returnUrl
,
//后端通知地址, 用户支付完成后,慧收钱服务器主动通知商户服务器里指定地址
'requestDate'
=>
$this
->
requestDate
,
//请求时间
'memo'
=>
json_encode
(
$memo
,
JSON_UNESCAPED_UNICODE
),
];
$signData
=
[
'method'
=>
$this
->
method
,
//方法名
'version'
=>
$this
->
version
,
//版本
'format'
=>
$this
->
format
,
//请求格式
'merchantNo'
=>
$this
->
merchantNo
,
//商户号
'signType'
=>
$this
->
signType
,
//加密类型
'signContent'
=>
json_encode
(
$signContent
,
JSON_UNESCAPED_UNICODE
),
'key'
=>
$this
->
key
,
];
$this
->
retData
=
$signData
;
}
}
src/Common/HsqConfig.php
View file @
50ae069
...
...
@@ -12,6 +12,8 @@ final class HsqConfig extends ConfigInterface
public
const
APP_ORDER_URL
=
'POLYMERIZE_PROGRAM_CASHIER'
;
//APP下单
public
const
JS_ORDER_URL
=
'POLYMERIZE_MAIN_SWEPTN'
;
//JS下单
public
const
QUERY_URL
=
'POLYMERIZE_QUERY'
;
//订单查询
public
const
REFUND_URL
=
'POLYMERIZE_REFUND'
;
//退款申请
...
...
src/Config.php
View file @
50ae069
...
...
@@ -282,10 +282,12 @@ final class Config{
//========================= 慧收钱相关接口 =======================//
// 支付常量
const
HSQ_CHANNEL_APP
=
'hsq_app'
;
//
小程序
支付
const
HSQ_CHANNEL_APP
=
'hsq_app'
;
//
APP
支付
const
HSQ_CHANNEL_LITE
=
'hsq_lite'
;
//小程序支付
const
HSQ_CHANNEL_JS
=
'hsq_JS'
;
//jsapi支付
const
HSQ_CHARGE
=
'hsq_charge'
;
// 慧收钱支付-统一下单
// 其他相关常量
...
...
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