当前位置: 首页>>代码示例>>Golang>>正文


Golang core.Client类代码示例

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


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


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