Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
qq_16800119
unidocs-zh
提交
2abc52b3
unidocs-zh
项目概览
qq_16800119
/
unidocs-zh
与 Fork 源项目一致
Fork自
DCloud / unidocs-zh
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
unidocs-zh
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
2abc52b3
编写于
8月 11, 2023
作者:
VK1688
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update uni-pay.md
上级
1b8c619f
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
34 addition
and
32 deletion
+34
-32
docs/uniCloud/uni-pay.md
docs/uniCloud/uni-pay.md
+34
-32
未找到文件。
docs/uniCloud/uni-pay.md
浏览文件 @
2abc52b3
...
...
@@ -754,11 +754,13 @@ module.exports = {
1.
该页面在
`template`
内放一个
`uni-pay`
组件标签,声明ref,然后调用组件的API。如下
注意:vue3下ref不可以等于组件名,因此这里
`ref="pay"`
而不能是
`ref="uniPay"`
```
html
<template>
<view>
<button
@
click=
"open"
>
唤起收银台支付
</button>
<uni-pay
ref=
"
uniP
ay"
></uni-pay>
<uni-pay
ref=
"
p
ay"
></uni-pay>
</view>
</template>
...
...
@@ -791,7 +793,7 @@ module.exports = {
this
.
order_no
=
`test`
+
Date
.
now
();
// 模拟生成订单号
this
.
out_trade_no
=
`
${
this
.
order_no
}
-1`
;
// 模拟生成插件支付单号
// 打开支付收银台
this
.
$refs
.
uniP
ay
.
open
({
this
.
$refs
.
p
ay
.
open
({
total_fee
:
this
.
total_fee
,
// 支付金额,单位分 100 = 1元
order_no
:
this
.
order_no
,
// 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
...
...
@@ -865,7 +867,7 @@ module.exports = async (obj) => {
```
js
// 打开支付收银台
this
.
$refs
.
uniP
ay
.
open
({
this
.
$refs
.
p
ay
.
open
({
type
:
"
recharge
"
,
// 支付回调类型 recharge 代表余额充值(当然你可以自己自定义)
});
```
...
...
@@ -1196,7 +1198,7 @@ public class CryptoUtil {
#### 组件方法
通过
`let res = await this.$refs.
uniP
ay.xxx();`
方式调用,详情调用方式参考下方的【前端完整示例代码】
通过
`let res = await this.$refs.
p
ay.xxx();`
方式调用,详情调用方式参考下方的【前端完整示例代码】
| 方法名 | 说明 |
|---------------------------|---------------------|
...
...
@@ -1245,8 +1247,8 @@ public class CryptoUtil {
<!-- #ifdef H5 -->
<button
v-if=
"h5Env === 'h5-weixin'"
@
click=
"getWeiXinJsCode('snsapi_base')"
>
公众号获取openid示例
</button>
<!-- #endif -->
<!-- 统一支付组件 -->
<uni-pay
ref=
"
uniP
ay"
:adpid=
"adpid"
return-url=
"/pages/order-detail/order-detail"
logo=
"/static/logo.png"
@
success=
"onSuccess"
@
create=
"onCreate"
></uni-pay>
<!-- 统一支付组件
,注意:vue3下ref不可以等于组件名,因此这里ref="pay" 而不能是 ref="uniPay"
-->
<uni-pay
ref=
"
p
ay"
:adpid=
"adpid"
return-url=
"/pages/order-detail/order-detail"
logo=
"/static/logo.png"
@
success=
"onSuccess"
@
create=
"onCreate"
></uni-pay>
</view>
</template>
...
...
@@ -1288,7 +1290,7 @@ public class CryptoUtil {
this
.
order_no
=
`test`
+
Date
.
now
();
this
.
out_trade_no
=
`
${
this
.
order_no
}
-1`
;
// 打开支付收银台
this
.
$refs
.
uniP
ay
.
open
({
this
.
$refs
.
p
ay
.
open
({
total_fee
:
this
.
total_fee
,
// 支付金额,单位分 100 = 1元
order_no
:
this
.
order_no
,
// 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
...
...
@@ -1307,7 +1309,7 @@ public class CryptoUtil {
this
.
order_no
=
`test`
+
Date
.
now
();
this
.
out_trade_no
=
`
${
this
.
order_no
}
-1`
;
// 发起支付
this
.
$refs
.
uniP
ay
.
createOrder
({
this
.
$refs
.
p
ay
.
createOrder
({
provider
:
provider
,
// 支付供应商
total_fee
:
this
.
total_fee
,
// 支付金额,单位分 100 = 1元
order_no
:
this
.
order_no
,
// 业务系统订单号(即你自己业务系统的订单表的订单号)
...
...
@@ -1327,7 +1329,7 @@ public class CryptoUtil {
this
.
order_no
=
`test`
+
Date
.
now
();
this
.
out_trade_no
=
`
${
this
.
order_no
}
-1`
;
// 发起支付
this
.
$refs
.
uniP
ay
.
createOrder
({
this
.
$refs
.
p
ay
.
createOrder
({
provider
:
provider
,
// 支付供应商
total_fee
:
this
.
total_fee
,
// 支付金额,单位分 100 = 1元
order_no
:
this
.
order_no
,
// 业务系统订单号(即你自己业务系统的订单表的订单号)
...
...
@@ -1342,7 +1344,7 @@ public class CryptoUtil {
},
// 查询支付状态
async
getOrder
()
{
let
res
=
await
this
.
$refs
.
uniP
ay
.
getOrder
({
let
res
=
await
this
.
$refs
.
p
ay
.
getOrder
({
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
await_notify
:
true
});
...
...
@@ -1362,7 +1364,7 @@ public class CryptoUtil {
},
// 发起退款
async
refund
()
{
let
res
=
await
this
.
$refs
.
uniP
ay
.
refund
({
let
res
=
await
this
.
$refs
.
p
ay
.
refund
({
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
});
if
(
res
)
{
...
...
@@ -1374,7 +1376,7 @@ public class CryptoUtil {
},
// 查询退款状态
async
getRefund
()
{
let
res
=
await
this
.
$refs
.
uniP
ay
.
getRefund
({
let
res
=
await
this
.
$refs
.
p
ay
.
getRefund
({
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
});
if
(
res
)
{
...
...
@@ -1386,7 +1388,7 @@ public class CryptoUtil {
},
// 关闭订单
async
closeOrder
()
{
let
res
=
await
this
.
$refs
.
uniP
ay
.
closeOrder
({
let
res
=
await
this
.
$refs
.
p
ay
.
closeOrder
({
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
});
if
(
res
)
{
...
...
@@ -1398,7 +1400,7 @@ public class CryptoUtil {
},
// 获取公众号code
async
getWeiXinJsCode
(
scope
=
"
snsapi_base
"
)
{
let
res
=
await
this
.
$refs
.
uniP
ay
.
getProviderAppId
({
let
res
=
await
this
.
$refs
.
p
ay
.
getProviderAppId
({
provider
:
"
wxpay
"
,
provider_pay_type
:
"
jsapi
"
});
...
...
@@ -1412,7 +1414,7 @@ public class CryptoUtil {
},
// 获取公众号openid
async
getOpenid
(
data
)
{
let
res
=
await
this
.
$refs
.
uniP
ay
.
getOpenid
(
data
);
let
res
=
await
this
.
$refs
.
p
ay
.
getOpenid
(
data
);
if
(
res
)
{
this
.
openid
=
res
.
openid
;
uni
.
showToast
({
...
...
@@ -1551,7 +1553,7 @@ uni-pay前端组件和uni-pay-co云对象的方法是一样的。通常情况下
`open`
如果只有一种支付方式,比如微信小程序内只能用微信支付,则不会弹收银台,而是直接调用支付。
```
js
this
.
$refs
.
uniP
ay
.
open
({
this
.
$refs
.
p
ay
.
open
({
total_fee
:
1
,
// 支付金额,单位分 100 = 1元
type
:
"
recharge
"
,
// 支付回调类型
order_no
:
"
20221027011000101001010
"
,
// 业务系统订单号
...
...
@@ -1600,7 +1602,7 @@ uni.navigateTo({
不带收银台时,provider参数为必传项,代表支付供应商
```
js
this
.
$refs
.
uniP
ay
.
createOrder
({
this
.
$refs
.
p
ay
.
createOrder
({
provider
:
"
wxpay
"
,
// 支付供应商
total_fee
:
1
,
// 支付金额,单位分 100 = 1元
type
:
"
recharge
"
,
// 支付回调类型
...
...
@@ -1681,7 +1683,7 @@ await uniPayCo.createOrder({
**支付组件方法形式(推荐)**
```
js
await
this
.
$refs
.
uniP
ay
.
getOrder
({
await
this
.
$refs
.
p
ay
.
getOrder
({
out_trade_no
:
"
2022102701100010100101001
"
,
// 插件支付单号
await_notify
:
true
,
// 是否需要等待异步通知执行完成,若为了响应速度,可以设置为false,若需要等待异步回调执行完成,则设置为true
});
...
...
@@ -1734,7 +1736,7 @@ await uniPayCo.getOrder({
**支付组件方法形式(推荐)**
```
js
await
this
.
$refs
.
uniP
ay
.
refund
({
await
this
.
$refs
.
p
ay
.
refund
({
out_trade_no
:
"
2022102701100010100101001
"
,
// 插件支付单号
});
```
...
...
@@ -1767,7 +1769,7 @@ await uniPayCo.refund({
**支付组件方法形式(推荐)**
```
js
await
this
.
$refs
.
uniP
ay
.
getRefund
({
await
this
.
$refs
.
p
ay
.
getRefund
({
out_trade_no
:
"
2022102701100010100101001
"
,
// 插件支付单号
});
```
...
...
@@ -1809,7 +1811,7 @@ await uniPayCo.getRefund({
**支付组件方法形式(推荐)**
```
js
await
this
.
$refs
.
uniP
ay
.
closeOrder
({
await
this
.
$refs
.
p
ay
.
closeOrder
({
out_trade_no
:
"
2022102701100010100101001
"
,
// 插件支付单号
});
```
...
...
@@ -1841,7 +1843,7 @@ await uniPayCo.closeOrder({
**支付组件方法形式(推荐)**
```
js
await
this
.
$refs
.
uniP
ay
.
getPayProviderFromCloud
();
await
this
.
$refs
.
p
ay
.
getPayProviderFromCloud
();
```
**云对象接口形式**
...
...
@@ -1865,7 +1867,7 @@ await uniPayCo.getPayProviderFromCloud();
### 获取支付配置内的appid@get-provider-appid
```
js
await
this
.
$refs
.
uniP
ay
.
getProviderAppId
({
await
this
.
$refs
.
p
ay
.
getProviderAppId
({
provider
:
"
wxpay
"
,
provider_pay_type
:
"
jsapi
"
,
});
...
...
@@ -1901,7 +1903,7 @@ await uniPayCo.getProviderAppId({
小程序不需要调用此方法,组件内部已自动静默获取openid
```
js
await
this
.
$refs
.
uniP
ay
.
getOpenid
({
await
this
.
$refs
.
p
ay
.
getOpenid
({
provider
:
"
wxpay
"
,
code
:
options
.
code
});
...
...
@@ -1946,7 +1948,7 @@ IAP 全称:In-App Purchase,是指苹果 App Store 的应用内购买,是
```
js
// 发起ios内购支付
this
.
$refs
.
uniP
ay
.
createOrder
({
this
.
$refs
.
p
ay
.
createOrder
({
provider
:
"
appleiap
"
,
// 支付供应商(这里固定未appleiap,代表ios内购支付)
order_no
:
"
20221027011000101001010
"
,
// 业务系统订单号
out_trade_no
:
"
2022102701100010100101001
"
,
// 插件支付单号
...
...
@@ -1976,8 +1978,8 @@ this.$refs.uniPay.createOrder({
<button
class=
"btn-pay"
@
click=
"createOrder"
:loading=
"loading"
:disabled=
"disabled"
>
立即支付
</button>
</view>
<!-- 统一支付组件 -->
<uni-pay
ref=
"
uniP
ay"
:debug=
"true"
:adpid=
"adpid"
return-url=
"/pages/order-detail/order-detail"
@
mounted=
"onMounted"
@
success=
"onSuccess"
></uni-pay>
<!-- 统一支付组件
,注意:vue3下ref不可以等于组件名,因此这里ref="pay" 而不能是 ref="uniPay"
-->
<uni-pay
ref=
"
p
ay"
:debug=
"true"
:adpid=
"adpid"
return-url=
"/pages/order-detail/order-detail"
@
mounted=
"onMounted"
@
success=
"onSuccess"
></uni-pay>
</view>
</template>
...
...
@@ -2013,9 +2015,9 @@ this.$refs.uniPay.createOrder({
},
onShow
()
{
if
(
this
.
$refs
.
uniPay
&&
this
.
$refs
.
uniP
ay
.
appleiapRestore
)
{
if
(
this
.
$refs
.
pay
&&
this
.
$refs
.
p
ay
.
appleiapRestore
)
{
// ios内购支付漏单重试
this
.
$refs
.
uniP
ay
.
appleiapRestore
();
this
.
$refs
.
p
ay
.
appleiapRestore
();
}
},
onUnload
()
{},
...
...
@@ -2029,9 +2031,9 @@ this.$refs.uniPay.createOrder({
this
.
productList
[
0
].
checked
=
true
;
this
.
productid
=
this
.
productList
[
0
].
productid
;
this
.
disabled
=
false
;
if
(
this
.
$refs
.
uniPay
&&
this
.
$refs
.
uniP
ay
.
appleiapRestore
)
{
if
(
this
.
$refs
.
pay
&&
this
.
$refs
.
p
ay
.
appleiapRestore
)
{
// ios内购支付漏单重试
this
.
$refs
.
uniP
ay
.
appleiapRestore
();
this
.
$refs
.
p
ay
.
appleiapRestore
();
}
},
/**
...
...
@@ -2042,7 +2044,7 @@ this.$refs.uniPay.createOrder({
this
.
order_no
=
`test`
+
Date
.
now
();
this
.
out_trade_no
=
this
.
order_no
;
// 发起支付
this
.
$refs
.
uniP
ay
.
createOrder
({
this
.
$refs
.
p
ay
.
createOrder
({
provider
:
"
appleiap
"
,
// 支付供应商(这里固定未appleiap,代表ios内购支付)
order_no
:
this
.
order_no
,
// 业务系统订单号(即你自己业务系统的订单表的订单号)
out_trade_no
:
this
.
out_trade_no
,
// 插件支付单号
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录