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 3b1c58cf
authored
May 09, 2024
by
yeran
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: update
1 parent
50ae069b
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
43 additions
and
32 deletions
composer.json
examples/ali/wapCharge.php
examples/aliconfig.php
examples/wx/wapCharge.php
src/Common/Ali/Data/Charge/ChargeBaseData.php
src/Common/Ali/Data/Charge/WapChargeData.php
src/Common/Weixin/Data/Charge/WapChargeData.php
composer.json
View file @
3b1c58c
{
"name"
:
"ldy/payment"
,
"type"
:
"library"
,
"version"
:
"3.6.
4
"
,
"version"
:
"3.6.
5
"
,
"description"
:
"支付宝支付、微信支付、招商一网通支付、通联支付、米付支付、利楚扫呗、富友支付、联拓付、易生支付、银盛支付、微诺付、汇收钱 php SDK。"
,
"keywords"
:
[
"alipay"
,
"weixin"
,
"支付宝支付"
,
"微信支付"
,
"通联支付"
,
"集成支付接口SDK"
,
"招商一网通"
,
"一网通"
,
"利楚扫呗"
,
"富友支付"
,
"微诺付"
,
"汇收钱"
],
"homepage"
:
""
,
...
...
examples/ali/wapCharge.php
View file @
3b1c58c
...
...
@@ -18,15 +18,12 @@ $aliConfig = require_once __DIR__ . '/../aliconfig.php';
// 订单信息
$orderNo
=
time
()
.
rand
(
1000
,
9999
);
$payData
=
[
'body'
=>
'ali wap pay'
,
'subject'
=>
'测试支付宝手机网站支付'
,
'order_no'
=>
$orderNo
,
'timeout_express'
=>
time
()
+
600
,
// 表示必须 600s 内付款
'amount'
=>
'0.01'
,
// 单位为元 ,最小为0.01
'return_param'
=>
'tata'
,
// 一定不要传入汉字,只能是 字母 数字组合
'client_ip'
=>
isset
(
$_SERVER
[
'REMOTE_ADDR'
])
?
$_SERVER
[
'REMOTE_ADDR'
]
:
'127.0.0.1'
,
// 客户地址
'goods_type'
=>
'1'
,
'store_id'
=>
''
,
];
try
{
...
...
examples/aliconfig.php
View file @
3b1c58c
...
...
@@ -19,6 +19,12 @@
* 登录密码 111111
* 支付密码 111111
*/
//aop->appId = 'your app_id';
//$aop->rsaPrivateKey = '请填写开发者私钥去头去尾去回车,一行字符串';
//$aop->alipayrsaPublicKey='请填写支付宝公钥,一行字符串';
//$aop->apiVersion = '1.0';
//$aop->signType = 'RSA2';
//$aop->postCharset='GBK';
return
[
'use_sandbox'
=>
true
,
// 是否使用沙盒模式
...
...
examples/wx/wapCharge.php
View file @
3b1c58c
...
...
@@ -30,9 +30,10 @@ $payData = [
//{"h5_info": {"type":"Wap","wap_url": "https://pay.qq.com","wap_name": "腾讯充值"}}
'scene_info'
=>
[
'type'
=>
'Wap'
,
// IOS Android Wap 腾讯建议 IOS ANDROID 采用app支付
'wap_url'
=>
'helei112g.github.io'
,
//自己的 wap 地址
'wap_name'
=>
'测试充值'
,
'payer_client_ip'
=>
isset
(
$_SERVER
[
'REMOTE_ADDR'
])
?
$_SERVER
[
'REMOTE_ADDR'
]
:
'127.0.0.1'
,
// 客户地址,
'h5_info'
=>
[
'type'
=>
'Wap'
//// IOS Android Wap 腾讯建议 IOS ANDROID 采用app支付
]
],
];
...
...
src/Common/Ali/Data/Charge/ChargeBaseData.php
View file @
3b1c58c
...
...
@@ -96,16 +96,18 @@ abstract class ChargeBaseData extends AliBaseData
}
// 检查商品类型
if
(
empty
(
$goodsType
))
{
// 默认为实物类商品
$this
->
goods_type
=
1
;
}
elseif
(
!
in_array
(
$goodsType
,
[
0
,
1
]))
{
throw
new
PayException
(
'商品类型可取值为:0-虚拟类商品 1-实物类商品'
);
}
//
if (empty($goodsType)) {// 默认为实物类商品
//
$this->goods_type = 1;
//
} elseif (! in_array($goodsType, [0 ,1])) {
//
throw new PayException('商品类型可取值为:0-虚拟类商品 1-实物类商品');
//
}
// 返回参数进行urlencode编码
if
(
!
empty
(
$passBack
)
&&
!
is_string
(
$passBack
))
{
if
(
!
empty
(
$passBack
))
{
if
(
!
is_string
(
$passBack
))
{
throw
new
PayException
(
'回传参数必须是字符串'
);
}
$this
->
return_param
=
urlencode
(
$passBack
);
}
}
}
src/Common/Ali/Data/Charge/WapChargeData.php
View file @
3b1c58c
...
...
@@ -24,20 +24,19 @@ class WapChargeData extends ChargeBaseData
'subject'
=>
strval
(
$this
->
subject
),
'out_trade_no'
=>
strval
(
$this
->
order_no
),
'total_amount'
=>
strval
(
$this
->
amount
),
'seller_id'
=>
$this
->
partner
,
//
'seller_id' => $this->partner,
// 销售产品码,商家和支付宝签约的产品码,为固定值QUICK_WAP_PAY
'product_code'
=>
'QUICK_WAP_PAY'
,
'goods_type'
=>
$this
->
goods_type
,
//
'goods_type' => $this->goods_type,
'passback_params'
=>
$this
->
return_param
,
'disable_pay_channels'
=>
$this
->
limitPay
,
//
'disable_pay_channels' => $this->limitPay,
'store_id'
=>
$this
->
store_id
,
];
$timeExpire
=
$this
->
timeout_express
;
if
(
!
empty
(
$timeExpire
))
{
$express
=
floor
((
$timeExpire
-
strtotime
(
$this
->
timestamp
))
/
60
);
$express
&&
$content
[
'timeout_express'
]
=
$express
.
'm'
;
// 超时时间 统一使用分钟计算
if
(
!
empty
(
$timeExpire
))
{
$content
[
'time_expire'
]
=
date
(
'Y-m-d H:i:s'
,
$timeExpire
*
60
+
time
());
}
$content
=
ArrayUtil
::
paraFilter
(
$content
);
// 过滤掉空值,下面不用在检查是否为空
...
...
src/Common/Weixin/Data/Charge/WapChargeData.php
View file @
3b1c58c
...
...
@@ -41,24 +41,30 @@ class WapChargeData extends ChargeBaseData
'appid'
=>
trim
(
$this
->
appId
),
'mch_id'
=>
trim
(
$this
->
mchId
),
'nonce_str'
=>
$this
->
nonceStr
,
'sign_type'
=>
$this
->
signType
,
'fee_type'
=>
$this
->
feeType
,
'notify_url'
=>
$this
->
notifyUrl
,
'trade_type'
=>
$this
->
tradeType
,
//设置APP支付
'limit_pay'
=>
$this
->
limitPay
,
// 指定不使用信用卡
'amount'
=>
$this
->
amount
,
'out_trade_no'
=>
trim
(
$this
->
order_no
),
'description'
=>
trim
(
$this
->
subject
),
'time_expire'
=>
$this
->
timeout_express
,
'attach'
=>
trim
(
$this
->
return_param
),
'scene_info'
=>
json_encode
(
$sceneInfo
),
// 'sign_type' => $this->signType,
// 'fee_type' => $this->feeType,
// 'trade_type' => $this->tradeType, //设置APP支付
// 'limit_pay' => $this->limitPay, // 指定不使用信用卡
// 业务数据
'device_info'
=>
$this
->
terminal_id
,
'body'
=>
trim
(
$this
->
subject
),
//
'device_info' => $this->terminal_id,
//'detail' => json_encode($this->body, JSON_UNESCAPED_UNICODE);
'attach'
=>
trim
(
$this
->
return_param
),
'out_trade_no'
=>
trim
(
$this
->
order_no
),
'total_fee'
=>
$this
->
amount
,
'spbill_create_ip'
=>
trim
(
$this
->
client_ip
),
'time_start'
=>
$this
->
timeStart
,
'time_expire'
=>
$this
->
timeout_express
,
'scene_info'
=>
json_encode
(
$sceneInfo
),
// 'spbill_create_ip' => trim($this->client_ip),
// 'time_start' => $this->timeStart,
];
// 移除数组中的空值
...
...
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