前端聚合码支付(详细代码)

聚合支付:也称“融合支付”,是指只从事“支付、结算、清算”服务之外的“支付服务”,依托银行、非银机构或清算组织,借助银行、非银机构或清算组织的支付通道与清结算能力,利用自身的技术与服务集成能力,将一个以上的银行、非银机构或清算组织的支付服务,整合到一起,为商户提供支付服务。

 部分代码

1调接口--跳转到特定页面

    async getH5Pay(form) {
      const params = {
        ...form,
        mchUserId: "",
        gmtCreator: "0",
        gmtUpdater: "0",
        mchOrderNo: this.mchOrderNo,
        currency: "CNY",
        subject: "",
        body: "",
        notifyUrl: "",
        redirectUrl: "",
        expiredTime: dayjs().add(15, "minute"),
        divisionMode: 0,
        version: "1.0",
        reqTime: new Date().getTime(),
        mchType: 1,
        sign: "",
        signType: "md5",
        gmtCreated: "jack",
      };
      let res = await this.$request.api.callCashH5(params);
      const { code, data } = res.data;

      if (code == "SUCCESS") {
        const routerParams = {
          ...form,
          expireTime: Date.parse(data[0].expireTime),
          mchOrderNo: this.mchOrderNo,
          payWayList: data[0].payWayResultDTOList,
        };
        const routerName = data[0].cashPageH5Url.split("/").reverse()[0];
        this.$router.push({ name: routerName, params: { ...routerParams } });
      } else {
        this.$notify({
          title: "提示",
          message: "接口调用失败",
          type: "warning",
          duration: 5000,
        });
      }
    },

 2获取跳转路径、参数及二维码路径在该页面进行渲然二维码进行扫码

    countDown(times) {
      return countDown(times);
    },
    // 二维码失效倒计时
    payTimeoutCount() {
      let _this = this;

      var interval = setInterval(() => {
        _this.expireTime--;
        setTimeout(() => {
          if (_this.expireTime <= Date.now()) {
            _this.codeStatus = 0;
            clearInterval(interval);
          }
        }, 0);
      }, 1000);
    },
    handleUnifiedPay() {
      const params = {
        mchOrderNo: this.mchOrderNo,
        wayCode: this.payWay,
        amount: this.amount,
        appId: this.appId,
        mchNo: this.mchNo,
        mchUserId: "",
        gmtCreator: 0,
        gmtUpdater: 0,
        currency: "CNY",
        subject: "test",
        body: "testbody",
        notifyUrl: "",
        redirectUrl: "",
        expiredTime: dayjs().add(15, "minute"),
        divisionMode: 0,
        version: "1.0",
        channelCode: "wxpay",
        reqTime: new Date().getTime(),
        mchType: 1,
        isvNo: "",
        sign: "",
        signType: "md5",
        gmtCreated: "",
      };

      this.$request.api.unifiedPay(params).then((res) => {
        if (res.code == "SUCCESS") {
          this.route =
            window.location.href.split("h5-cashier")[0] + "pay-success";
          const { reqUrl } = res.data;

          if (this.payWay.toString() === "WX_H5") {
            window.location.replace(
              reqUrl + `&redirect_uri=${encodeURIComponent(this.route)}`
            );
          } else if (this.payWay.toString() === "ALI_WAP") {
            window.location.replace(reqUrl);
          } else {
            this.$notify({
              title: "提示",
              message: "请使用微信或支付宝扫二维码",
              type: "warning",
              duration: 5000,
            });
          }
        } else {
          this.$notify({
            title: "提示",
            message: "调用失败",
            type: "warning",
            duration: 5000,
          });
        }
      });
    },

 

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小可爱的小飞云

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值