• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang core.Client类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/chanxuehong/wechat/v2/mch/core.Client的典型用法代码示例。如果您正苦于以下问题:Golang Client类的具体用法?Golang Client怎么用?Golang Client使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



在下文中一共展示了Client类的18个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: GetTransferInfo

// 查询企业付款.
//  NOTE: 请求需要双向证书
func GetTransferInfo(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/gettransferinfo", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:5,代码来源:gettransferinfo.go


示例2: Refund

// 申请退款.
//  NOTE: 请求需要双向证书.
func Refund(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/secapi/pay/refund", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:5,代码来源:refund.go


示例3: Refund2

func Refund2(clt *core.Client, req *RefundRequest) (resp *RefundResponse, err error) {
	m1 := make(map[string]string, 16)
	m1["appid"] = clt.AppId()
	m1["mch_id"] = clt.MchId()
	if req.DeviceInfo != "" {
		m1["device_info"] = req.DeviceInfo
	}
	if req.NonceStr != "" {
		m1["nonce_str"] = req.NonceStr
	} else {
		m1["nonce_str"] = string(rand.NewHex())
	}
	if req.TransactionId != "" {
		m1["transaction_id"] = req.TransactionId
	}
	if req.OutTradeNo != "" {
		m1["out_trade_no"] = req.OutTradeNo
	}
	m1["out_refund_no"] = req.OutRefundNo
	m1["total_fee"] = strconv.FormatInt(req.TotalFee, 10)
	m1["refund_fee"] = strconv.FormatInt(req.RefundFee, 10)
	if req.RefundFeeType != "" {
		m1["refund_fee_type"] = req.RefundFeeType
	}
	if req.OperUserId != "" {
		m1["op_user_id"] = req.OperUserId
	} else {
		m1["op_user_id"] = clt.MchId()
	}
	m1["sign"] = core.Sign(m1, clt.ApiKey(), md5.New)

	m2, err := Refund(clt, m1)
	if err != nil {
		return
	}

	// 判断业务状态
	resultCode, ok := m2["result_code"]
	if !ok {
		err = core.ErrNotFoundResultCode
		return
	}
	if resultCode != core.ResultCodeSuccess {
		err = &core.BizError{
			ResultCode:  resultCode,
			ErrCode:     m2["err_code"],
			ErrCodeDesc: m2["err_code_des"],
		}
		return
	}

	resp = &RefundResponse{
		AppId: m2["appid"],
		MchId: m2["mch_id"],

		TransactionId: m2["transaction_id"],
		OutTradeNo:    m2["out_trade_no"],
		OutRefundNo:   m2["out_refund_no"],
		RefundId:      m2["refund_id"],

		DeviceInfo:    m2["device_info"],
		RefundChannel: m2["refund_channel"],
		FeeType:       m2["fee_type"],
	}

	var (
		n   int64
		str string
	)
	if n, err = strconv.ParseInt(m2["refund_fee"], 10, 64); err != nil {
		err = fmt.Errorf("parse refund_fee:%q to int64 failed: %s", m2["refund_fee"], err.Error())
		return
	} else {
		resp.RefundFee = n
	}
	if n, err = strconv.ParseInt(m2["total_fee"], 10, 64); err != nil {
		err = fmt.Errorf("parse total_fee:%q to int64 failed: %s", m2["total_fee"], err.Error())
		return
	} else {
		resp.TotalFee = n
	}
	if n, err = strconv.ParseInt(m2["cash_fee"], 10, 64); err != nil {
		err = fmt.Errorf("parse cash_fee:%q to int64 failed: %s", m2["cash_fee"], err.Error())
		return
	} else {
		resp.CashFee = n
	}
	if str = m2["settlement_refund_fee"]; str != "" {
		if n, err = strconv.ParseInt(str, 10, 64); err != nil {
			err = fmt.Errorf("parse settlement_refund_fee:%q to int64 failed: %s", str, err.Error())
			return
		} else {
			resp.SettlementRefundFee = util.Int64(n)
		}
	}
	if str = m2["settlement_total_fee"]; str != "" {
		if n, err = strconv.ParseInt(str, 10, 64); err != nil {
			err = fmt.Errorf("parse settlement_total_fee:%q to int64 failed: %s", str, err.Error())
			return
		} else {
//.........这里部分代码省略.........
开发者ID:btbxbob,项目名称:wechat,代码行数:101,代码来源:refund.go


示例4: OrderQuery

// 查询订单.
func OrderQuery(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/pay/orderquery", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:4,代码来源:orderquery.go


示例5: OrderQuery2

func OrderQuery2(clt *core.Client, req *OrderQueryRequest) (resp *OrderQueryResponse, err error) {
	m1 := make(map[string]string, 8)
	m1["appid"] = clt.AppId()
	m1["mch_id"] = clt.MchId()
	if req.TransactionId != "" {
		m1["transaction_id"] = req.TransactionId
	}
	if req.OutTradeNo != "" {
		m1["out_trade_no"] = req.OutTradeNo
	}
	if req.NonceStr != "" {
		m1["nonce_str"] = req.NonceStr
	} else {
		m1["nonce_str"] = string(rand.NewHex())
	}
	m1["sign"] = core.Sign(m1, clt.ApiKey(), md5.New)

	m2, err := OrderQuery(clt, m1)
	if err != nil {
		return
	}

	// 判断业务状态
	resultCode, ok := m2["result_code"]
	if !ok {
		err = core.ErrNotFoundResultCode
		return
	}
	if resultCode != core.ResultCodeSuccess {
		err = &core.BizError{
			ResultCode:  resultCode,
			ErrCode:     m2["err_code"],
			ErrCodeDesc: m2["err_code_des"],
		}
		return
	}

	resp = &OrderQueryResponse{
		AppId: m2["appid"],
		MchId: m2["mch_id"],

		OpenId:         m2["openid"],
		TradeType:      m2["trade_type"],
		TradeState:     m2["trade_state"],
		BankType:       m2["bank_type"],
		TransactionId:  m2["transaction_id"],
		OutTradeNo:     m2["out_trade_no"],
		TimeEnd:        m2["time_end"],
		TradeStateDesc: m2["trade_state_desc"],
	}

	var (
		n   int64
		id  int
		str string
	)
	if n, err = strconv.ParseInt(m2["total_fee"], 10, 64); err != nil {
		err = fmt.Errorf("parse total_fee:%q to int64 failed: %s", m2["total_fee"], err.Error())
		return
	} else {
		resp.TotalFee = n
	}
	if n, err = strconv.ParseInt(m2["cash_fee"], 10, 64); err != nil {
		err = fmt.Errorf("parse cash_fee:%q to int64 failed: %s", m2["cash_fee"], err.Error())
		return
	} else {
		resp.CashFee = n
	}

	resp.DeviceInfo = m2["device_info"]
	if str = m2["is_subscribe"]; str != "" {
		if str == "Y" || str == "y" {
			resp.IsSubscribe = util.Bool(true)
		} else {
			resp.IsSubscribe = util.Bool(false)
		}
	}
	if str = m2["settlement_total_fee"]; str != "" {
		if n, err = strconv.ParseInt(str, 10, 64); err != nil {
			err = fmt.Errorf("parse settlement_total_fee:%q to int64 failed: %s", str, err.Error())
			return
		} else {
			resp.SettlementTotalFee = util.Int64(n)
		}
	}
	resp.FeeType = m2["fee_type"]
	resp.CashFeeType = m2["cash_fee_type"]
	if str = m2["coupon_fee"]; str != "" {
		if n, err = strconv.ParseInt(str, 10, 64); err != nil {
			err = fmt.Errorf("parse coupon_fee:%q to int64 failed: %s", str, err.Error())
			return
		} else {
			resp.CouponFee = util.Int64(n)
		}
	}
	if str = m2["coupon_count"]; str != "" {
		if n, err = strconv.ParseInt(str, 10, 32); err != nil {
			err = fmt.Errorf("parse coupon_count:%q to int failed: %s", str, err.Error())
			return
		} else {
//.........这里部分代码省略.........
开发者ID:btbxbob,项目名称:wechat,代码行数:101,代码来源:orderquery.go


示例6: UnifiedOrder

// 统一下单.
func UnifiedOrder(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.core.weixin.qq.com/pay/unifiedorder", req)
}
开发者ID:yansuan,项目名称:wechat.v2,代码行数:4,代码来源:common.go


示例7: MicroPay

// 提交刷卡支付.
func MicroPay(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/pay/micropay", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:4,代码来源:scanned.go


示例8: AuthCodeToOpenId

// 授权码查询OPENID接口.
func AuthCodeToOpenId(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/tools/authcodetoopenid", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:4,代码来源:authcodetoopenid.go


示例9: QueryCoupon

// 查询代金券信息.
func QueryCoupon(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.core.weixin.qq.com/promotion/query_coupon", req)
}
开发者ID:yansuan,项目名称:wechat.v2,代码行数:4,代码来源:query_coupon.go


示例10: SendRedPack

// 红包发放.
//  NOTE: 请求需要双向证书
func SendRedPack(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/sendredpack", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:5,代码来源:sendredpack.go


示例11: QueryCouponStock

// 查询代金券批次信息.
func QueryCouponStock(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/query_coupon_stock", req)
}
开发者ID:xiaomuqiao,项目名称:wechat.v2,代码行数:4,代码来源:query_coupon_stock.go


示例12: CloseOrder

// 关闭订单.
func CloseOrder(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/pay/closeorder", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:4,代码来源:common.go


示例13: Report

// 测速上报.
func Report(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/payitil/report", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:4,代码来源:report.go


示例14: RefundQuery

// 查询退款.
func RefundQuery(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.core.weixin.qq.com/pay/refundquery", req)
}
开发者ID:yansuan,项目名称:wechat.v2,代码行数:4,代码来源:common.go


示例15: ShortURL

// 转换短链接.
func ShortURL(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/tools/shorturl", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:4,代码来源:shorturl.go


示例16: Transfers

// 企业付款.
//  NOTE: 请求需要双向证书
func Transfers(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.mch.weixin.qq.com/mmpaymkttransfers/promotion/transfers", req)
}
开发者ID:btbxbob,项目名称:wechat,代码行数:5,代码来源:transfers.go


示例17: SendCoupon

// 发放代金券.
//  请求需要双向证书
func SendCoupon(clt *core.Client, req map[string]string) (resp map[string]string, err error) {
	return clt.PostXML("https://api.core.weixin.qq.com/mmpaymkttransfers/send_coupon", req)
}
开发者ID:yansuan,项目名称:wechat.v2,代码行数:5,代码来源:send_coupon.go


示例18: UnifiedOrder2

func UnifiedOrder2(clt *core.Client, req *UnifiedOrderRequest) (resp *UnifiedOrderResponse, err error) {
	m1 := make(map[string]string, 20)
	m1["appid"] = clt.AppId()
	m1["mch_id"] = clt.MchId()
	if req.DeviceInfo != "" {
		m1["device_info"] = req.DeviceInfo
	}
	if req.NonceStr != "" {
		m1["nonce_str"] = req.NonceStr
	} else {
		m1["nonce_str"] = string(rand.NewHex())
	}
	m1["body"] = req.Body
	if req.Detail != "" {
		m1["detail"] = req.Detail
	}
	if req.Attach != "" {
		m1["attach"] = req.Attach
	}
	m1["out_trade_no"] = req.OutTradeNo
	if req.FeeType != "" {
		m1["fee_type"] = req.FeeType
	}
	m1["total_fee"] = strconv.FormatInt(req.TotalFee, 10)
	m1["spbill_create_ip"] = req.SpbillCreateIP
	if req.TimeStart != "" {
		m1["time_start"] = req.TimeStart
	}
	if req.TimeExpire != "" {
		m1["time_expire"] = req.TimeExpire
	}
	if req.GoodsTag != "" {
		m1["goods_tag"] = req.GoodsTag
	}
	m1["notify_url"] = req.NotifyURL
	m1["trade_type"] = req.TradeType
	if req.ProductId != "" {
		m1["product_id"] = req.ProductId
	}
	if req.LimitPay != "" {
		m1["limit_pay"] = req.LimitPay
	}
	if req.OpenId != "" {
		m1["openid"] = req.OpenId
	}
	m1["sign"] = core.Sign(m1, clt.ApiKey(), md5.New)

	m2, err := UnifiedOrder(clt, m1)
	if err != nil {
		return
	}

	// 判断业务状态
	resultCode, ok := m2["result_code"]
	if !ok {
		err = core.ErrNotFoundResultCode
		return
	}
	if resultCode != core.ResultCodeSuccess {
		err = &core.BizError{
			ResultCode:  resultCode,
			ErrCode:     m2["err_code"],
			ErrCodeDesc: m2["err_code_des"],
		}
		return
	}

	resp = &UnifiedOrderResponse{
		AppId: m2["appid"],
		MchId: m2["mch_id"],

		TradeType:  m2["trade_type"],
		PrepayId:   m2["prepay_id"],
		DeviceInfo: m2["device_info"],
		CodeURL:    m2["code_url"],
		MWebURL:    m2["mweb_url"],
	}
	return
}
开发者ID:btbxbob,项目名称:wechat,代码行数:79,代码来源:unifiedorder.go



注:本文中的github.com/chanxuehong/wechat/v2/mch/core.Client类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang core.Client类代码示例发布时间:2022-05-23
下一篇:
Golang util.MsgSign函数代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap