51 Star 290 Fork 100

北京小程科技有限公司/微信

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
report_jsapi.go 3.21 KB
一键复制 编辑 原始数据 按行查看 历史
shallot 提交于 2022-08-10 17:52 +08:00 . 移除warning代码。
/*
Copyright 2020 XiaochengTech
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package wxpay
import (
"encoding/xml"
"gitee.com/xiaochengtech/wechat/util"
)
// 交易保障(JSAPI)
func (c *Client) ReportJsApi(body ReportJsApiBody) (wxRsp ReportJsApiResponse, err error) {
// 处理参数
if body.InterfaceUrl, err = util.EscapedPath(body.InterfaceUrl); err != nil {
return
}
// 业务逻辑
bytes, err := c.doWeChat("payitil/report", body)
if err != nil {
return
}
// 解析返回值
err = xml.Unmarshal(bytes, &wxRsp)
return
}
// 交易保障(JSAPI)的参数
type ReportJsApiBody struct {
SignType string `json:"sign_type,omitempty"` // 签名类型,目前支持HMAC-SHA256和MD5,默认为MD5
DeviceInfo string `json:"device_info,omitempty"` // (非必填) 微信支付分配的终端设备号,商户自定义
InterfaceUrl string `json:"interface_url"` // 上报对应的接口的完整URL,类似:https://api.mch.weixin.qq.com/pay/unifiedorder 对于刷卡支付,为更好的和商户共同分析一次业务行为的整体耗时情况,对于两种接入模式,请都在门店侧对一次刷卡行为进行一次单独的整体上报,上报URL指定为:https://api.mch.weixin.qq.com/pay/micropay/total 关于两种接入模式具体可参考本文档章节:刷卡支付商户接入模式 其它接口调用仍然按照调用一次,上报一次来进行。
ExecuteTime int64 `json:"execute_time"` // 接口耗时情况,单位为毫秒
ReturnCode string `json:"return_code"` // SUCCESS/FAIL 此字段是通信标识,非交易标识,交易是否成功需要查看trade_state来判断
ReturnMsg string `json:"return_msg,omitempty"` // (非必填) 返回信息,如非空,为错误原因 签名失败 参数格式校验错误
ResultCode string `json:"result_code"` // SUCCESS/FAIL
ErrCode string `json:"err_code,omitempty"` // (非必填) ORDERNOTEXIST—订单不存在 SYSTEMERROR—系统错误
ErrCodeDes string `json:"err_code_des,omitempty"` // (非必填) 结果信息描述
OutTradeNo string `json:"out_trade_no,omitempty"` // (非必填) 商户系统内部的订单号,商户可以在上报时提供相关商户订单号方便微信支付更好的提高服务质量。
UserIp string `json:"user_ip"` // 发起接口调用时的机器IP
Time string `json:"time,omitempty"` // (非必填) 系统时间,格式为yyyyMMddHHmmss,如2009年12月27日9点10分10秒表示为20091227091010。其他详见时间规则
}
// 交易保障(JSAPI)的返回值
type ReportJsApiResponse struct {
ResponseModel
// 当return_code为SUCCESS时
ResultCode string `xml:"result_code"` // SUCCESS/FAIL
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Go
1
https://gitee.com/xiaochengtech/wechat.git
git@gitee.com:xiaochengtech/wechat.git
xiaochengtech
wechat
微信
3adb7df2544f

搜索帮助