mooonwepay

package
v0.0.36 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 25, 2025 License: Apache-2.0 Imports: 10 Imported by: 0

README

写在前面

微信支付官方的 SDK 没有提供商家转账到零钱等的下载转账电子回单和下载转账账单接口。

实现分为三大部分,但均为遵照微信支付官方的API文档实现:

  • 第一部分:运营工具下的商家转账到零钱
  • 第二部分:支付产品下的资金/交易账单
  • 第三部分:扩展工具下的分账

运营工具下的商家转账到零钱

转账电子回单分为两种:

  • 转账批次(batch)电子回单:含批次中的所有转账记录
  • 转账明细(detail)电子回单:仅批次中单笔转账记录

一个转账单可批量给多人转,对应的转账账单存在以上两种。

apply_change_bill_receipt

申请商家转账到零钱的转账电子回单

query_change_bill_receipt

查询商家转账到零钱的转账电子回单

down_change_bill_receipt

下载商家转账到零钱的转账电子回单

支付产品下的资金/交易账单

apply_bill

申请转账账单,支持交易账单和资金账单

download_bill

下载账单,支持交易账单和资金账单

扩展工具下的分账

apply_sharing_bill

申请分账账单

download_sharing_bill

下载分账账单

Documentation

Overview

Package mooonwepay Wrote by yijian on 2024/08/24

Package mooonwepay Wrote by yijian on 2024/08/23

Package mooonwepay Wrote by yijian on 2024/08/24

Package mooonwepay Wrote by yijian on 2024/08/23

Package mooonwepay Wrote by yijian on 2024/08/24

Package mooonwepay Wrote by yijian on 2024/08/23

Package mooonwepay Wrote by yijian on 2024/08/24

Package mooonwepay Wrote by yijian on 2024/08/23

Index

Constants

This section is empty.

Variables

View Source
var (
	ApplyTradeBillPath = "/v3/bill/tradebill"    // 交易订单
	ApplyFundBillPath  = "/v3/bill/fundflowbill" // 资金流订单

)
View Source
var (
	ApplyChangeBillBatchReceiptPath  = "/v3/transfer/bill-receipt"
	ApplyChangeBillDetailReceiptPath = "/v3/transfer-detail/electronic-receipts"
)
View Source
var (
	QueryChangeBillBatchReceiptPath  = "/v3/transfer/bill-receipt"
	QueryChangeBillDetailReceiptPath = "/v3/transfer-detail/electronic-receipts"
)
View Source
var (
	ApplySharingBillPath = "/v3/profitsharing/bills" // 分账账单

)

Functions

func IsFundBill added in v0.0.16

func IsFundBill(billType string) bool

IsFundBill 是否为资金账单类型

func IsTradeBill added in v0.0.16

func IsTradeBill(billType string) bool

IsTradeBill 是否为交易账单类型

Types

type ApplyBillReq added in v0.0.16

type ApplyBillReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	// 交易账单类型:
	// ALL: 返回当日所有订单信息(不含充值退款订单)
	// SUCCESS: 返回当日成功支付的订单(不含充值退款订单)
	// REFUND: 返回当日退款订单(不含充值退款订单)
	// RECHARGE_REFUND: 返回当日充值退款订单
	// ALL_SPECIAL: 返回个性化账单当日所有订单信息
	// SUC_SPECIAL: 返回个性化账单当日成功支付的订单
	// REF_SPECIAL: 返回个性化账单当日退款订单
	//
	// 资金账单类型:
	// BASIC: 基本账户
	// OPERATION: 运营账户
	// FEES: 手续费账户
	BillType string // 账单类型

	CompressionType string // 压缩类型,目前仅支持取值 GZIP
	Date            string // 账单日期(格式:yyyy-MM-DD,仅支持三个月内的账单下载申请)
}

type ApplyBillResp added in v0.0.16

type ApplyBillResp struct {
	HashType    string `json:"hash_type,omitempty"`    //哈希类型,目前仅有 SHA1 一种取值
	HashValue   string `json:"hash_value,omitempty"`   // 用于校验文件的完整性
	DownloadUrl string `json:"download_url,omitempty"` // 5 分钟内有效(下载后为 gzip 压缩过的 csv 文件)

	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func ApplyBill added in v0.0.16

func ApplyBill(req *ApplyBillReq) (*ApplyBillResp, error)

ApplyBill 申请交易账单

type ApplyChangeBillReceiptReq added in v0.0.16

type ApplyChangeBillReceiptReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	OutBatchNo  string // 商家转账批次单号
	OutDetailNo string // 商家转账明细单号(如指定表示单笔转账电子回单)
	AcceptType  string // 电子回单受理类型:BATCH_TRANSFER:批量转账明细电子回单 TRANSFER_TO_POCKET:企业付款至零钱电子回单 TRANSFER_TO_BANK:企业付款至银行卡电子回单
}

ApplyChangeBillReceiptReq 转账电子回单申请受理请求,支持受理最近两年内的转账批次单 接口文档:https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/electronic-signature/create-electronic-signature.html

type ApplyChangeBillReceiptResp added in v0.0.16

type ApplyChangeBillReceiptResp struct {
	AcceptType      string `json:"accept_type,omitempty"`
	OutBatchNo      string `json:"out_batch_no,omitempty"`
	OutDetailNo     string `json:"out_detail_no,omitempty"`
	SignatureNo     string `json:"signature_no,omitempty"`     // 电子回单申请单号,申请单据的唯一标识
	SignatureStatus string `json:"signature_status,omitempty"` //  ACCEPTED:已受理,电子签章已受理成功 FINISHED:已完成。电子签章已处理完成
	HashType        string `json:"hash_type,omitempty"`        // 电子回单文件的 hash 方法,如:SHA256
	HashValue       string `json:"hash_value,omitempty"`       // 电子回单文件的 hash 值,用于下载之后验证文件的正确性
	DownloadUrl     string `json:"download_url,omitempty"`     // 电子回单文件的下载地址
	CreateTime      string `json:"create_time,omitempty"`      // 电子签章单创建时间,按照使用 rfc3339 所定义的格式,格式为 YYYY-MM-DDThh:mm:ss+TIMEZONE
	UpdateTime      string `json:"update_time,omitempty"`      // 电子签章单最近一次状态变更的时间,按照使用 rfc3339 所定义的格式,格式为 YYYY-MM-DDThh:mm:ss+TIMEZONE

	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func ApplyChangeBillReceipt added in v0.0.16

func ApplyChangeBillReceipt(req *ApplyChangeBillReceiptReq) (*ApplyChangeBillReceiptResp, error)

ApplyChangeBillReceipt 转账电子回单申请受理

type ApplySharingBillReq added in v0.0.16

type ApplySharingBillReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	CompressionType string // 压缩类型,目前仅支持取值 GZIP
	Date            string // 账单日期(格式:yyyy-MM-DD,仅支持三个月内的账单下载申请)
}

type ApplySharingBillResp added in v0.0.16

type ApplySharingBillResp struct {
	HashType    string `json:"hash_type,omitempty"`    //哈希类型,目前仅有 SHA1 一种取值
	HashValue   string `json:"hash_value,omitempty"`   // 用于校验文件的完整性
	DownloadUrl string `json:"download_url,omitempty"` // 5 分钟内有效(下载后为 gzip 压缩过的 csv 文件)

	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func ApplySharingBill added in v0.0.16

func ApplySharingBill(req *ApplySharingBillReq) (*ApplySharingBillResp, error)

ApplySharingBill 申请分账账单

type DownloadBillReq added in v0.0.16

type DownloadBillReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	// 交易账单类型:
	// ALL: 返回当日所有订单信息(不含充值退款订单)
	// SUCCESS: 返回当日成功支付的订单(不含充值退款订单)
	// REFUND: 返回当日退款订单(不含充值退款订单)
	// RECHARGE_REFUND: 返回当日充值退款订单
	// ALL_SPECIAL: 返回个性化账单当日所有订单信息
	// SUC_SPECIAL: 返回个性化账单当日成功支付的订单
	// REF_SPECIAL: 返回个性化账单当日退款订单
	//
	// 资金账单类型:
	// BASIC: 基本账户
	// OPERATION: 运营账户
	// FEES: 手续费账户
	BillType string // 账单类型

	CompressionType string // 压缩类型,目前仅支持取值 GZIP
	Date            string // 账单日期(格式:yyyy-MM-DD,仅支持三个月内的账单下载申请)

	Filepath string // 下载后存放的文件路径(下载后为 gzip 压缩过的 csv 文件)
}

type DownloadBillResp added in v0.0.16

type DownloadBillResp struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func DownloadBill added in v0.0.16

func DownloadBill(req *DownloadBillReq) (*DownloadBillResp, error)

DownloadBill 下载转账电子回单 账单文件格式,参加微信支付官方文档:https://pay.weixin.qq.com/docs/merchant/apis/bill-download/download-bill.html

type DownloadChangeBillReceiptReq

type DownloadChangeBillReceiptReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	OutBatchNo  string // 商家转账批次单号
	OutDetailNo string // 商家转账明细单号(如指定表示单笔转账电子回单)
	AcceptType  string // 电子回单受理类型:BATCH_TRANSFER:批量转账明细电子回单 TRANSFER_TO_POCKET:企业付款至零钱电子回单 TRANSFER_TO_BANK:企业付款至银行卡电子回单

	Filepath string // 下载后存放的文件路径
}

type DownloadChangeBillReceiptResp

type DownloadChangeBillReceiptResp struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func DownloadChangeBillReceipt

func DownloadChangeBillReceipt(req *DownloadChangeBillReceiptReq) (*DownloadChangeBillReceiptResp, error)

DownloadChangeBillReceipt 下载转账电子回单 转账电子回单文件格式,参加微信支付官方文档:https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/download-receipt.html

type DownloadSharingBillReq added in v0.0.16

type DownloadSharingBillReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	CompressionType string // 压缩类型,目前仅支持取值 GZIP
	Date            string // 账单日期(格式:yyyy-MM-DD,仅支持三个月内的账单下载申请)

	Filepath string // 下载后存放的文件路径(下载后为 gzip 压缩过的 csv 文件)
}

type DownloadSharingBillResp added in v0.0.16

type DownloadSharingBillResp struct {
	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func DownloadSharingBill added in v0.0.16

func DownloadSharingBill(req *DownloadSharingBillReq) (*DownloadSharingBillResp, error)

DownloadSharingBill 下载转账电子回单 账单文件格式,参加微信支付官方文档:https://pay.weixin.qq.com/docs/merchant/apis/profit-sharing/download-bill.html

type QueryChangeBillReceiptReq

type QueryChangeBillReceiptReq struct {
	Ctx        context.Context
	HttpClient *http.Client
	PrivateKey *rsa.PrivateKey

	Host      string // 主域名:https://api.mch.weixin.qq.com,备域名:https://api2.mch.weixin.qq.com
	NonceStr  string
	Timestamp int64
	Mchid     string
	SerialNo  string

	OutBatchNo  string // 商家转账批次单号
	OutDetailNo string // 商家转账明细单号(如指定表示单笔转账电子回单)
	AcceptType  string // 电子回单受理类型:BATCH_TRANSFER:批量转账明细电子回单 TRANSFER_TO_POCKET:企业付款至零钱电子回单 TRANSFER_TO_BANK:企业付款至银行卡电子回单
}

QueryChangeBillReceiptReq 查询转账电子回单申请受理结果请求,支持受理最近两年内的转账批次单 接口文档:https://pay.weixin.qq.com/docs/merchant/apis/batch-transfer-to-balance/electronic-receipt-api/create-electronic-receipt.html

type QueryChangeBillReceiptResp

type QueryChangeBillReceiptResp struct {
	AcceptType      string `json:"accept_type,omitempty"`
	OutBatchNo      string `json:"out_batch_no,omitempty"`
	OutDetailNo     string `json:"out_detail_no,omitempty"`
	SignatureNo     string `json:"signature_no,omitempty"`     // 电子回单申请单号,申请单据的唯一标识
	SignatureStatus string `json:"signature_status,omitempty"` // ACCEPTED:已受理,电子签章已受理成功 FINISHED:已完成。电子签章已处理完成
	HashType        string `json:"hash_type,omitempty"`        // 电子回单文件的 hash 方法,如:SHA256
	HashValue       string `json:"hash_value,omitempty"`       // 电子回单文件的 hash 值,用于下载之后验证文件的正确性
	DownloadUrl     string `json:"download_url,omitempty"`     // 电子回单文件的下载地址
	CreateTime      string `json:"create_time,omitempty"`      // 电子签章单创建时间,按照使用 rfc3339 所定义的格式,格式为 YYYY-MM-DDThh:mm:ss+TIMEZONE
	UpdateTime      string `json:"update_time,omitempty"`      // 电子签章单最近一次状态变更的时间,按照使用 rfc3339 所定义的格式,格式为 YYYY-MM-DDThh:mm:ss+TIMEZONE

	Code    string `json:"code,omitempty"`
	Message string `json:"message,omitempty"`

	HttpStatusCode int `json:"http_status_code,omitempty"`
}

func QueryChangeBillReceipt

func QueryChangeBillReceipt(req *QueryChangeBillReceiptReq) (*QueryChangeBillReceiptResp, error)

QueryChangeBillReceipt 查询转账电子回单

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL