2.0.0 • Published 7 years ago
@femessage/payment v2.0.0
Introduce
说明:
- 基于 vant Toast 以及 Actionsheet 组件,请确保已经引入 Toast 以及 Actionsheet;如果指定了某种支付方式,则不需要 Actionsheet。
 
   Vue.use(Toast)
   Vue.use(Actionsheet)- 组件内部需要根据渠道请求对应的支付参数(相对路径),所以需要传入 this.$axios 进行请求以及 baseUrl。
 - 当前已支付支付渠道有微信 JSAPI 支付以及银联 GATEWAY 支付。
 
Install
// Step1 安装
yarn add @femessage/payment
// Step2 使用
<template>
    <button @click="pay">支付</button>
</template>
<script>
import paymentRequest from '@femessage/payment'
export default {
  methods: {
    pay() {
      paymentRequest({
        specifyPayWay: '指定支付方式的code',
        tenantId: '租户id',
        tranNo: '交易流水号',
        orderId: '订单id',
        payChannel: {
          JSAPI: {
            openid: 'openid',
            signature: '签名'
          },
          GATEWAY: {
            terminalType: '类型',
            signature: '签名'
          }
        },
        paySysAccessAuthCode: '系统编码',
        paySysBizTypeCode: '业务编码',
        payApplicationCode: '支付应用编码',
        request: this.$axios,
        applyDeductionAmount: '支付金额',
        callback: {
          success(res) {
            alert('success回调')
          },
          cancel(e) {
            alert('cancel回调')
          },
          fail(e) {
            alert('fail回调')
          }
        }
      })
    }
  }
}
</script>Props
| 参数 | 说明 | 类型 | 
|---|---|---|
| specifyPayWay | 指定支付方式的 code | String | 
| tenantId | 租户 ID | String,Number | 
| tranNo | 交易流水号 | String,Number | 
| orderId | 订单 ID | String,Number | 
| paySysAccessAuthCode | 系统编码 | String,Number | 
| paySysBizTypeCode | 业务编码 | String,Number | 
| payApplicationCode | 支付应用编码 | String,Number | 
| request | ajax 请求库,传入 this.$axios | |
| baseUrl | 请求的 baseUrl | |
| applyDeductionAmount | 支付金额 | String,Number | 
| payChannel | 支付渠道以及渠道所需参数 | Object | 
| callback | 回调参数 | Object | 
回调函数:
callback: {
    success(res) {
        alert("success回调")
    },
    cancel(e) {
        alert("cancel回调")
    },
    fail(e) {
        alert("fail回调")
    }
}支付渠道
payChannel: {
    //微信jspai支付
    JSAPI: {
        openid: 'openid',
        signature: '签名'
    },
    //银联网关支付
    GATEWAY: {
        terminalType: 'PC', //pc端传入'PC',移动端传入'APP'
        signature:'签名'
    }
}指定支付方式
specifyPayWay:来源于支付渠道的 key 值,当前可选JSAPI或者GATEWAY,若传入值则不会弹出支付列表,而是直接请求支付