{% import “./macro/weixin-tenpay.md” as WeixinTenpay %}

企业付款

企业付款为企业提供付款至用户零钱的能力,支持通过API接口付款,具体的场景介绍参考微信企业付款场景介绍

企业付款需要到微信支付商户平台中,产品大全 -> 企业付款到零钱 -> 产品设置,配置发起方式,勾选 “使用 API 接口发起付款”,并将以下 IP 加入到接口调用 IP。

  1. 52.80.43.200
  2. 52.80.37.170
  3. 52.80.57.80

info 使用以下接口时必须根据上述步骤进行配置

BaaS.wxPromotionTransfer({userID, openid, amount, description, checkName, reUserName, gatewayType})

参数说明

参数名 类型 说明
userID Number 用户 ID (对应 _userprofile 表中的 id 字段)
openid string 【可选】用户在公众号下的 openid(gatewayType 为 weixin_tenpay_app 的时候必填)
amount Number 付款金额
description String 付款描述
checkName Boolean 是否检测真实名字
reUserName String 【可选】真实名字(checkName 为 false 时,可不填)
gatewayType GatewayType 【可选】微信支付商户类型(默认为微信小程序)

{{WeixinTenpay.getGatewayType()}}

示例代码

  1. BaaS.wxPromotionTransfer({
  2. userID: "xxxx",
  3. amount: 0.3,
  4. description: "test",
  5. checkName: true,
  6. reUserName: "xxxx",
  7. }).then(res => {
  8. // success
  9. }).catch(e => {
  10. // err
  11. })

返回示例

调用结果会直接将微信的结果进行返回,开发者可根据返回的信息做处理。(请参考微信企业付款文档)

成功:HTTP:1.1 OK

  1. {
  2. "return_code": "SUCCESS",
  3. "partner_trale_no": "xxx",
  4. "payment_no": "xxx",
  5. "payment_time": "2018-01-01 00:00:00"
  6. }

失败:HTTP:1.1 OK

  1. {
  2. "err_code": "xxx",
  3. "err_code_des": "xxxx"
  4. }