uniapp 支付宝 支付流程

1.首先要在HBuilder X 找到 manifest.json  找到App 模块配置 把Payment(支付) 勾选上

2.如果跟你合作的后端技术可以 那么前端实现起来 就非常简单 话不多说 上代码

      if (this.payType == "支付宝支付") {
          userpay({//首先 调用后端的支付接口 换取订单信息 把后端需要的字段传过去
            uid: this.userInfo.id,
            bill_orderSn: this.bill_orderSn,
            pay_type: this.userInfo.pay_type,
            gate_id: this.userInfo.gate_id,
            amount: this.jine,
            mer_cust_id: this.userInfo.bank_card
          }).then(res => {
            if (res.code == 1) {
              //订单对象,从服务器获取 // 注意 如果是 支付宝支付provider固定值就是alipay
              uni.requestPayment({ //拿到订单信息后 调用 uniapp的支付接口 唤起支付
                provider: 'alipay', //微信就是 wxpay
                orderInfo: res.data, //支付宝订单数据 从后端拿到的数据
                success: function(res) {
                  this.show1 = false
                  uni.showToast({
                    title: "支付成功",
                    icon: 'success',
                    success: () => {
                      setTimeout(() => {
                        uni.switchTab({
                          url: '/pages/index/index'
                        })
                      }, 500)
                    }
                  })
                },
                fail: function(err) {
                  uni.showToast({
                    title: "支付失败请稍后再试",
                    icon: 'none',
                    success: () => {
                      setTimeout(() => {
                        uni.switchTab({
                          url: '/pages/my/my'
                        })
                      }, 500)
                    }
                  })
                  console.log('fail:' + JSON.stringify(err));
                }
              });
            }

          })
        }

注意:app项目要在真机调试下 才能正常唤起支付 并且要配置的 一定不要少配置 否则问题会让你找的很头疼

  • 5
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 4
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值