uniapp 微信公众号支付
时间: 2023-09-05 18:14:54 浏览: 209
uniapp微信公众号支付需要通过网页授权获取微信的code来实现。首先,需要在配置中设置回调域名。然后,通过后端接口获取支付配置信息。对于微信支付,可以使用以下代码获取配置信息:
```
await this.$http({
apiName: "wxPayConfig",
type: "POST",
data: {
orderId: this.orderId
}
}).then(res => {
// 处理返回的支付配置信息
}).catch(_ => {
// 处理异常情况
});
```
对于支付宝支付,需要单独从接口获取配置信息,得到的是一长串字符串:
```
await this.$http({
apiName: "aliPay",
type: "POST",
data: {
orderNo: this.orderId
}
}).then(res => {
// 处理返回的支付配置信息
}).catch(_ => {
// 处理异常情况
});
```
通过以上步骤,可以在uniapp中实现微信公众号支付。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [uniapp微信H5公众号授权与支付](https://blog.csdn.net/qq_63358859/article/details/127021504)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [uniapp之APP/微信小程序/公众号支付](https://blog.csdn.net/weixin_36185028/article/details/106328412)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文