Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
纵之格
ShopXO
提交
33f3ff6c
ShopXO
项目概览
纵之格
/
ShopXO
通知
394
Star
16
Fork
11
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
ShopXO
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
33f3ff6c
编写于
9月 19, 2020
作者:
D
devil
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
qq小程序支持微信支付
上级
c1499a40
变更
9
隐藏空白更改
内联
并排
Showing
9 changed file
with
146 addition
and
42 deletion
+146
-42
extend/base/QQ.php
extend/base/QQ.php
+58
-1
extend/payment/Weixin.php
extend/payment/Weixin.php
+38
-3
sourcecode/alipay/pages/user-order/user-order.js
sourcecode/alipay/pages/user-order/user-order.js
+2
-1
sourcecode/baidu/pages/user-order/user-order.js
sourcecode/baidu/pages/user-order/user-order.js
+2
-1
sourcecode/qq/pages/goods-detail/goods-detail.js
sourcecode/qq/pages/goods-detail/goods-detail.js
+0
-3
sourcecode/qq/pages/plugins/wallet/user-recharge/user-recharge.js
...de/qq/pages/plugins/wallet/user-recharge/user-recharge.js
+31
-16
sourcecode/qq/pages/user-order/user-order.js
sourcecode/qq/pages/user-order/user-order.js
+6
-10
sourcecode/toutiao/pages/user-order/user-order.js
sourcecode/toutiao/pages/user-order/user-order.js
+3
-2
sourcecode/weixin/pages/user-order/user-order.js
sourcecode/weixin/pages/user-order/user-order.js
+6
-5
未找到文件。
extend/base/QQ.php
浏览文件 @
33f3ff6c
...
...
@@ -106,7 +106,7 @@ class QQ
{
// 请求获取session_key
$url
=
'https://api.q.qq.com/sns/jscode2session?appid='
.
$this
->
_appid
.
'&secret='
.
$this
->
_appsecret
.
'&js_code='
.
$authcode
.
'&grant_type=authorization_code'
;
$result
=
json_decode
(
file_get_contents
(
$url
),
true
);
$result
=
$this
->
HttpRequestGet
(
$url
);
if
(
!
empty
(
$result
[
'openid'
]))
{
// 从缓存获取用户信息
...
...
@@ -118,5 +118,62 @@ class QQ
}
return
false
;
}
/**
* 公共获取access_token
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-08-26
* @desc description
*/
public
function
GetAccessToken
()
{
// 缓存key
$key
=
$this
->
_appid
.
'_access_token'
;
$result
=
cache
(
$key
);
if
(
!
empty
(
$result
))
{
if
(
$result
[
'expires_in'
]
>
time
())
{
return
$result
[
'access_token'
];
}
}
// 网络请求
$url
=
'https://api.q.qq.com/api/getToken?grant_type=client_credential&appid='
.
$this
->
_appid
.
'&secret='
.
$this
->
_appsecret
;
$result
=
$this
->
HttpRequestGet
(
$url
);
if
(
!
empty
(
$result
[
'access_token'
]))
{
// 缓存存储
$result
[
'expires_in'
]
+=
time
();
cache
(
$key
,
$result
);
return
$result
[
'access_token'
];
}
return
false
;
}
/**
* [HttpRequestGet get请求]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @datetime 2018-01-03T19:21:38+0800
* @param [string] $url [url地址]
* @return [array] [返回数据]
*/
public
function
HttpRequestGet
(
$url
)
{
$curl
=
curl_init
();
curl_setopt
(
$curl
,
CURLOPT_RETURNTRANSFER
,
true
);
curl_setopt
(
$curl
,
CURLOPT_TIMEOUT
,
500
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYPEER
,
false
);
curl_setopt
(
$curl
,
CURLOPT_SSL_VERIFYHOST
,
false
);
curl_setopt
(
$curl
,
CURLOPT_URL
,
$url
);
$res
=
curl_exec
(
$curl
);
curl_close
(
$curl
);
return
json_decode
(
$res
,
true
);
}
}
?>
\ No newline at end of file
extend/payment/Weixin.php
浏览文件 @
33f3ff6c
...
...
@@ -161,8 +161,11 @@ class Weixin
return
DataReturn
(
'支付缺少配置'
,
-
1
);
}
// 平台
$client_type
=
ApplicationClientType
();
// 微信中打开
if
(
ApplicationClientType
()
==
'h5'
&&
IsWeixinEnv
())
if
(
$client_type
==
'h5'
&&
IsWeixinEnv
())
{
exit
(
header
(
'location:'
.
PluginsHomeUrl
(
'weixinwebauthorization'
,
'pay'
,
'index'
,
input
())));
}
...
...
@@ -174,8 +177,26 @@ class Weixin
return
$ret
;
}
// QQ小程序使用微信支付
if
(
$client_type
==
'qq'
)
{
// 获取QQ access_token
$qq_appid
=
MyC
(
'common_app_mini_qq_appid'
);
$qq_appsecret
=
MyC
(
'common_app_mini_qq_appsecret'
);
$access_token
=
(
new
\
base\QQ
(
$qq_appid
,
$qq_appsecret
))
->
GetAccessToken
();
if
(
$access_token
===
false
)
{
return
DataReturn
(
'QQ凭证AccessToken获取失败'
,
-
1
);
}
// QQ小程序代理下单地址
$request_url
=
'https://api.q.qq.com/wxpay/unifiedorder?appid='
.
$qq_appid
.
'&access_token='
.
$access_token
.
'&real_notify_url='
.
urlencode
(
$this
->
GetNotifyUrl
(
$params
));
}
else
{
$request_url
=
'https://api.mch.weixin.qq.com/pay/unifiedorder'
;
}
// 请求接口处理
$result
=
$this
->
XmlToArray
(
$this
->
HttpRequest
(
'https://api.mch.weixin.qq.com/pay/unifiedorder'
,
$this
->
ArrayToXml
(
$ret
[
'data'
])));
$result
=
$this
->
XmlToArray
(
$this
->
HttpRequest
(
$request_url
,
$this
->
ArrayToXml
(
$ret
[
'data'
])));
if
(
!
empty
(
$result
[
'return_code'
])
&&
$result
[
'return_code'
]
==
'SUCCESS'
&&
!
empty
(
$result
[
'prepay_id'
]))
{
return
$this
->
PayHandleReturn
(
$ret
[
'data'
],
$result
,
$params
);
...
...
@@ -352,7 +373,7 @@ class Weixin
$appid
=
(
$client_type
==
'weixin'
)
?
$this
->
config
[
'mini_appid'
]
:
$this
->
config
[
'appid'
];
// 异步地址处理
$notify_url
=
(
__MY_HTTP__
==
'https'
&&
isset
(
$this
->
config
[
'agreement'
])
&&
$this
->
config
[
'agreement'
]
==
1
)
?
'http'
.
mb_substr
(
$params
[
'notify_url'
],
5
,
null
,
'utf-8'
)
:
$params
[
'notify_url'
]
;
$notify_url
=
(
$client_type
==
'qq'
)
?
'https://api.q.qq.com/wxpay/notify'
:
$this
->
GetNotifyUrl
(
$params
)
;
// 请求参数
$data
=
[
...
...
@@ -373,6 +394,20 @@ class Weixin
return
DataReturn
(
'success'
,
0
,
$data
);
}
/**
* 获取异步通知地址
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
* @date 2020-09-19
* @desc description
* @param [array] $params [输入参数]
*/
private
function
GetNotifyUrl
(
$params
)
{
return
(
__MY_HTTP__
==
'https'
&&
isset
(
$this
->
config
[
'agreement'
])
&&
$this
->
config
[
'agreement'
]
==
1
)
?
'http'
.
mb_substr
(
$params
[
'notify_url'
],
5
,
null
,
'utf-8'
)
:
$params
[
'notify_url'
];
}
/**
* 获取支付交易类型
* @author Devil
...
...
sourcecode/alipay/pages/user-order/user-order.js
浏览文件 @
33f3ff6c
...
...
@@ -235,8 +235,9 @@ Page({
switch
(
res
.
data
.
data
.
is_payment_type
)
{
// 正常线上支付
case
0
:
var
data
=
res
.
data
.
data
;
my
.
tradePay
({
tradeNO
:
res
.
data
.
data
.
data
,
tradeNO
:
data
.
data
,
success
:
res
=>
{
if
(
res
.
resultCode
==
9000
)
{
// 数据设置
...
...
sourcecode/baidu/pages/user-order/user-order.js
浏览文件 @
33f3ff6c
...
...
@@ -230,8 +230,9 @@ Page({
switch
(
res
.
data
.
data
.
is_payment_type
)
{
// 正常线上支付
case
0
:
var
data
=
res
.
data
.
data
;
swan
.
requestPolymerPayment
({
orderInfo
:
res
.
data
.
data
.
data
,
orderInfo
:
data
.
data
,
success
:
function
(
res
)
{
// 数据设置
self
.
order_item_pay_success_handle
(
order_ids
);
...
...
sourcecode/qq/pages/goods-detail/goods-detail.js
浏览文件 @
33f3ff6c
...
...
@@ -75,9 +75,6 @@ Page({
// 初始化配置
this
.
init_config
();
// 显示分享菜单
app
.
show_share_menu
();
},
// 初始化配置
...
...
sourcecode/qq/pages/plugins/wallet/user-recharge/user-recharge.js
浏览文件 @
33f3ff6c
...
...
@@ -220,23 +220,38 @@ Page({
success
:
res
=>
{
qq
.
hideLoading
();
if
(
res
.
data
.
code
==
0
)
{
var
data
=
res
.
data
.
data
.
data
;
qq
.
requestPayment
({
package
:
data
,
success
:
function
(
res
)
{
// 数据设置
self
.
order_item_pay_success_handle
(
index
);
// 跳转支付页面
qq
.
navigateTo
({
url
:
"
/pages/paytips/paytips?code=9000&total_price=
"
+
self
.
data
.
data_list
[
index
][
'
money
'
]
var
data
=
res
.
data
.
data
;
// 是否微信支付
if
(
data
.
payment
.
payment
==
'
Weixin
'
)
{
qq
.
requestWxPayment
({
url
:
data
.
data
,
referer
:
app
.
data
.
request_url
,
success
:
function
(
res
)
{
app
.
alert
({
msg
:
'
支付成功后、请不要重复支付、如果订单状态未成功请联系客服处理
'
,
is_show_cancel
:
0
});
self
.
get_data_list
();
},
fail
:
function
(
res
)
{
app
.
showToast
(
'
支付失败
'
);
}
});
},
fail
:
function
(
res
)
{
app
.
showToast
(
'
支付失败
'
);
}
});
}
else
{
qq
.
requestPayment
({
package
:
data
.
data
,
success
:
function
(
res
)
{
// 数据设置
self
.
order_item_pay_success_handle
(
index
);
// 跳转支付页面
qq
.
navigateTo
({
url
:
"
/pages/paytips/paytips?code=9000&total_price=
"
+
self
.
data
.
data_list
[
index
][
'
money
'
]
});
},
fail
:
function
(
res
)
{
app
.
showToast
(
'
支付失败
'
);
}
});
}
}
else
{
app
.
showToast
(
res
.
data
.
msg
);
}
...
...
sourcecode/qq/pages/user-order/user-order.js
浏览文件 @
33f3ff6c
...
...
@@ -233,19 +233,15 @@ Page({
switch
(
res
.
data
.
data
.
is_payment_type
)
{
// 正常线上支付
case
0
:
var
data
=
res
.
data
.
data
;
// 是否微信支付
if
(
res
.
data
.
data
.
payment
.
payment
==
'
Weixin
'
)
{
if
(
data
.
payment
.
payment
==
'
Weixin
'
)
{
qq
.
requestWxPayment
({
url
:
res
.
data
.
data
.
data
,
url
:
data
.
data
,
referer
:
app
.
data
.
request_url
,
success
:
function
(
res
)
{
// 数据设置
self
.
order_item_pay_success_handle
(
order_ids
);
// 跳转支付页面
qq
.
navigateTo
({
url
:
"
/pages/paytips/paytips?code=9000
"
});
app
.
alert
({
msg
:
'
支付成功后、请不要重复支付、如果订单状态未成功请联系客服处理
'
,
is_show_cancel
:
0
});
self
.
get_data_list
();
},
fail
:
function
(
res
)
{
app
.
showToast
(
'
支付失败
'
);
...
...
@@ -253,7 +249,7 @@ Page({
});
}
else
{
qq
.
requestPayment
({
package
:
res
.
data
.
data
.
data
,
package
:
data
.
data
,
success
:
function
(
res
)
{
// 数据设置
self
.
order_item_pay_success_handle
(
order_ids
);
...
...
sourcecode/toutiao/pages/user-order/user-order.js
浏览文件 @
33f3ff6c
...
...
@@ -256,9 +256,10 @@ Page({
switch
(
res
.
data
.
data
.
is_payment_type
)
{
// 正常线上支付
case
0
:
var
data
=
res
.
data
.
data
;
tt
.
pay
({
orderInfo
:
res
.
data
.
data
.
order_info
,
service
:
res
.
data
.
data
.
service
,
orderInfo
:
data
.
order_info
,
service
:
data
.
service
,
success
(
res
)
{
// if (res.code == 0) {
// // 数据设置
...
...
sourcecode/weixin/pages/user-order/user-order.js
浏览文件 @
33f3ff6c
...
...
@@ -233,12 +233,13 @@ Page({
switch
(
res
.
data
.
data
.
is_payment_type
)
{
// 正常线上支付
case
0
:
var
data
=
res
.
data
.
data
;
wx
.
requestPayment
({
timeStamp
:
res
.
data
.
data
.
data
.
timeStamp
,
nonceStr
:
res
.
data
.
data
.
data
.
nonceStr
,
package
:
res
.
data
.
data
.
data
.
package
,
signType
:
res
.
data
.
data
.
data
.
signType
,
paySign
:
res
.
data
.
data
.
data
.
paySign
,
timeStamp
:
data
.
data
.
timeStamp
,
nonceStr
:
data
.
data
.
nonceStr
,
package
:
data
.
data
.
package
,
signType
:
data
.
data
.
signType
,
paySign
:
data
.
data
.
paySign
,
success
:
function
(
res
)
{
// 数据设置
self
.
order_item_pay_success_handle
(
order_ids
);
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录