transferbatch

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloseReasonType

type CloseReasonType string

CloseReasonType

const (
	CLOSEREASONTYPE_MERCHANT_REVOCATION    CloseReasonType = "MERCHANT_REVOCATION"
	CLOSEREASONTYPE_OVERDUE_CLOSE          CloseReasonType = "OVERDUE_CLOSE"
	CLOSEREASONTYPE_TRANSFER_SCENE_INVALID CloseReasonType = "TRANSFER_SCENE_INVALID"
)

Enums of CloseReasonType

func (CloseReasonType) Ptr

type FailReasonType

type FailReasonType string

FailReasonType

const (
	FAILREASONTYPE_ACCOUNT_FROZEN                          FailReasonType = "ACCOUNT_FROZEN"
	FAILREASONTYPE_REAL_NAME_CHECK_FAIL                    FailReasonType = "REAL_NAME_CHECK_FAIL"
	FAILREASONTYPE_NAME_NOT_CORRECT                        FailReasonType = "NAME_NOT_CORRECT"
	FAILREASONTYPE_OPENID_INVALID                          FailReasonType = "OPENID_INVALID"
	FAILREASONTYPE_TRANSFER_QUOTA_EXCEED                   FailReasonType = "TRANSFER_QUOTA_EXCEED"
	FAILREASONTYPE_DAY_RECEIVED_QUOTA_EXCEED               FailReasonType = "DAY_RECEIVED_QUOTA_EXCEED"
	FAILREASONTYPE_MONTH_RECEIVED_QUOTA_EXCEED             FailReasonType = "MONTH_RECEIVED_QUOTA_EXCEED"
	FAILREASONTYPE_DAY_RECEIVED_COUNT_EXCEED               FailReasonType = "DAY_RECEIVED_COUNT_EXCEED"
	FAILREASONTYPE_PRODUCT_AUTH_CHECK_FAIL                 FailReasonType = "PRODUCT_AUTH_CHECK_FAIL"
	FAILREASONTYPE_OVERDUE_CLOSE                           FailReasonType = "OVERDUE_CLOSE"
	FAILREASONTYPE_ID_CARD_NOT_CORRECT                     FailReasonType = "ID_CARD_NOT_CORRECT"
	FAILREASONTYPE_ACCOUNT_NOT_EXIST                       FailReasonType = "ACCOUNT_NOT_EXIST"
	FAILREASONTYPE_TRANSFER_RISK                           FailReasonType = "TRANSFER_RISK"
	FAILREASONTYPE_OTHER_FAIL_REASON_TYPE                  FailReasonType = "OTHER_FAIL_REASON_TYPE"
	FAILREASONTYPE_REALNAME_ACCOUNT_RECEIVED_QUOTA_EXCEED  FailReasonType = "REALNAME_ACCOUNT_RECEIVED_QUOTA_EXCEED"
	FAILREASONTYPE_RECEIVE_ACCOUNT_NOT_PERMMIT             FailReasonType = "RECEIVE_ACCOUNT_NOT_PERMMIT"
	FAILREASONTYPE_PAYEE_ACCOUNT_ABNORMAL                  FailReasonType = "PAYEE_ACCOUNT_ABNORMAL"
	FAILREASONTYPE_PAYER_ACCOUNT_ABNORMAL                  FailReasonType = "PAYER_ACCOUNT_ABNORMAL"
	FAILREASONTYPE_TRANSFER_SCENE_UNAVAILABLE              FailReasonType = "TRANSFER_SCENE_UNAVAILABLE"
	FAILREASONTYPE_TRANSFER_SCENE_INVALID                  FailReasonType = "TRANSFER_SCENE_INVALID"
	FAILREASONTYPE_TRANSFER_REMARK_SET_FAIL                FailReasonType = "TRANSFER_REMARK_SET_FAIL"
	FAILREASONTYPE_RECEIVE_ACCOUNT_NOT_CONFIGURE           FailReasonType = "RECEIVE_ACCOUNT_NOT_CONFIGURE"
	FAILREASONTYPE_BLOCK_B2_C_USERLIMITAMOUNT_BSRULE_MONTH FailReasonType = "BLOCK_B2C_USERLIMITAMOUNT_BSRULE_MONTH"
	FAILREASONTYPE_BLOCK_B2_C_USERLIMITAMOUNT_MONTH        FailReasonType = "BLOCK_B2C_USERLIMITAMOUNT_MONTH"
)

Enums of FailReasonType

func (FailReasonType) Ptr

func (e FailReasonType) Ptr() *FailReasonType

type GetTransferBatchByNoRequest

type GetTransferBatchByNoRequest struct {
	// 微信批次单号,微信商家转账系统返回的唯一标识
	BatchId *string `json:"batch_id"`
	// true-是;false-否,默认否。商户可选择是否查询指定状态的转账明细单,当转账批次单状态为“FINISHED”(已完成)时,才会返回满足条件的转账明细单
	NeedQueryDetail *bool `json:"need_query_detail"`
	// 该次请求资源的起始位置。返回的明细是按照设置的明细条数进行分页展示的,一次查询可能无法返回所有明细,我们使用该参数标识查询开始位置,默认值为0
	Offset *int64 `json:"offset,omitempty"`
	// 该次请求可返回的最大明细条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
	Limit *int64 `json:"limit,omitempty"`
	// 查询指定状态的转账明细单   ALL:全部。需要同时查询转账成功和转账失败的明细单   SUCCESS:转账成功。只查询转账成功的明细单   FAIL:转账失败。只查询转账失败的明细单
	DetailStatus *string `json:"detail_status,omitempty"`
}

GetTransferBatchByNoRequest

func (GetTransferBatchByNoRequest) Clone

func (GetTransferBatchByNoRequest) MarshalJSON

func (o GetTransferBatchByNoRequest) MarshalJSON() ([]byte, error)

func (GetTransferBatchByNoRequest) String

type GetTransferBatchByOutNoRequest

type GetTransferBatchByOutNoRequest struct {
	// 商户系统内部的商家批次单号,在商户系统内部唯一
	OutBatchNo *string `json:"out_batch_no"`
	// true-是;false-否,默认否。商户可选择是否查询指定状态的转账明细单,当转账批次单状态为“FINISHED”(已完成)时,才会返回满足条件的转账明细单
	NeedQueryDetail *bool `json:"need_query_detail"`
	// 该次请求资源(转账明细单)的起始位置,从0开始,默认值为0
	Offset *int64 `json:"offset,omitempty"`
	// 该次请求可返回的最大资源(转账明细单)条数,最小20条,最大100条,不传则默认20条。不足20条按实际条数返回
	Limit *int64 `json:"limit,omitempty"`
	// 查询指定状态的转账明细单   ALL:全部。需要同时查询转账成功和转账失败的明细单   SUCCESS:转账成功。只查询转账成功的明细单   FAIL:转账失败。只查询转账失败的明细单
	DetailStatus *string `json:"detail_status,omitempty"`
}

GetTransferBatchByOutNoRequest

func (GetTransferBatchByOutNoRequest) Clone

func (GetTransferBatchByOutNoRequest) MarshalJSON

func (o GetTransferBatchByOutNoRequest) MarshalJSON() ([]byte, error)

func (GetTransferBatchByOutNoRequest) String

type GetTransferDetailByNoRequest

type GetTransferDetailByNoRequest struct {
	// 微信批次单号,微信商家转账系统返回的唯一标识
	BatchId *string `json:"batch_id"`
	// 微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
	DetailId *string `json:"detail_id"`
}

GetTransferDetailByNoRequest

func (GetTransferDetailByNoRequest) Clone

func (GetTransferDetailByNoRequest) MarshalJSON

func (o GetTransferDetailByNoRequest) MarshalJSON() ([]byte, error)

func (GetTransferDetailByNoRequest) String

type GetTransferDetailByOutNoRequest

type GetTransferDetailByOutNoRequest struct {
	// 商户系统内部区分转账批次单下不同转账明细单的唯一标识
	OutDetailNo *string `json:"out_detail_no"`
	// 商户系统内部的商家批次单号,在商户系统内部唯一
	OutBatchNo *string `json:"out_batch_no"`
}

GetTransferDetailByOutNoRequest

func (GetTransferDetailByOutNoRequest) Clone

func (GetTransferDetailByOutNoRequest) MarshalJSON

func (o GetTransferDetailByOutNoRequest) MarshalJSON() ([]byte, error)

func (GetTransferDetailByOutNoRequest) String

type InitiateBatchTransferRequest

type InitiateBatchTransferRequest struct {
	// 申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
	Appid *string `json:"appid"`
	// 商户系统内部的商家批次单号,要求此参数只能由数字、大小写字母组成,在商户系统内部唯一
	OutBatchNo *string `json:"out_batch_no"`
	// 该笔批量转账的名称
	BatchName *string `json:"batch_name"`
	// 转账说明,UTF8编码,最多允许32个字符
	BatchRemark *string `json:"batch_remark"`
	// 转账金额单位为“分”。转账总金额必须与批次内所有明细转账金额之和保持一致,否则无法发起转账操作
	TotalAmount *int64 `json:"total_amount"`
	// 一个转账批次单最多发起一千笔转账。转账总笔数必须与批次内所有明细之和保持一致,否则无法发起转账操作
	TotalNum *int64 `json:"total_num"`
	// 发起批量转账的明细列表,最多一千笔
	TransferDetailList []TransferDetailInput `json:"transfer_detail_list,omitempty"`
	// 必填,指定该笔转账使用的转账场景ID
	TransferSceneId *string `json:"transfer_scene_id,omitempty"`
}

InitiateBatchTransferRequest

func (InitiateBatchTransferRequest) Clone

func (InitiateBatchTransferRequest) MarshalJSON

func (o InitiateBatchTransferRequest) MarshalJSON() ([]byte, error)

func (InitiateBatchTransferRequest) String

type InitiateBatchTransferResponse

type InitiateBatchTransferResponse struct {
	// 商户系统内部的商家批次单号,在商户系统内部唯一
	OutBatchNo *string `json:"out_batch_no"`
	// 微信批次单号,微信商家转账系统返回的唯一标识
	BatchId *string `json:"batch_id"`
	// 批次受理成功时返回,按照使用rfc3339所定义的格式,格式为YYYY-MM-DDThh:mm:ss+TIMEZONE
	CreateTime *time.Time `json:"create_time"`
}

InitiateBatchTransferResponse

func (InitiateBatchTransferResponse) Clone

func (InitiateBatchTransferResponse) MarshalJSON

func (o InitiateBatchTransferResponse) MarshalJSON() ([]byte, error)

func (InitiateBatchTransferResponse) String

type TransferBatchApiService

type TransferBatchApiService services.Service

func (*TransferBatchApiService) GetTransferBatchByNo

func (a *TransferBatchApiService) GetTransferBatchByNo(ctx context.Context, req GetTransferBatchByNoRequest) (resp *TransferBatchEntity, result *core.APIResult, err error)

GetTransferBatchByNo 通过微信批次单号查询批次单

## 查询接口说明

微信批次单号查单接口。商户可以通过该接口查询转账批次单以及指定状态的转账明细单。返回消息中包含微信批次单号、批次状态、批次类型、转账总金额、转账总笔数、成功金额、失败金额等信息。

Example
package main

import (
	"context"
	"log"

	"github.com/Marek-maxs/wechatpay-go/core"
	"github.com/Marek-maxs/wechatpay-go/core/option"
	"github.com/Marek-maxs/wechatpay-go/services/transferbatch"
	"github.com/Marek-maxs/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := transferbatch.TransferBatchApiService{Client: client}
	resp, result, err := svc.GetTransferBatchByNo(ctx,
		transferbatch.GetTransferBatchByNoRequest{
			BatchId:         core.String("1030000071100999991182020050700019480001"),
			NeedQueryDetail: core.Bool(true),
			Offset:          core.Int64(0),
			Limit:           core.Int64(20),
			DetailStatus:    core.String("FAIL"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call GetTransferBatchByNo err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}
Output:

func (*TransferBatchApiService) GetTransferBatchByOutNo

func (a *TransferBatchApiService) GetTransferBatchByOutNo(ctx context.Context, req GetTransferBatchByOutNoRequest) (resp *TransferBatchEntity, result *core.APIResult, err error)

GetTransferBatchByOutNo 通过商家批次单号查询批次单

## 查询接口说明

商家明细单号查单接口。商户可以通过该接口查询转账批次单以及指定状态的转账明细单。返回消息中包含微信批次单号、批次状态、批次类型、转账总金额、转账总笔数、成功金额、失败金额等信息。

Example
package main

import (
	"context"
	"log"

	"github.com/Marek-maxs/wechatpay-go/core"
	"github.com/Marek-maxs/wechatpay-go/core/option"
	"github.com/Marek-maxs/wechatpay-go/services/transferbatch"
	"github.com/Marek-maxs/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := transferbatch.TransferBatchApiService{Client: client}
	resp, result, err := svc.GetTransferBatchByOutNo(ctx,
		transferbatch.GetTransferBatchByOutNoRequest{
			OutBatchNo:      core.String("plfk2020042013"),
			NeedQueryDetail: core.Bool(true),
			Offset:          core.Int64(0),
			Limit:           core.Int64(20),
			DetailStatus:    core.String("FAIL"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call GetTransferBatchByOutNo err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}
Output:

func (*TransferBatchApiService) InitiateBatchTransfer

InitiateBatchTransfer 发起商家转账

## 发起转账接口说明

发起批量转账接口。商户可以通过该接口同时向多个用户微信零钱进行转账操作。请求消息中应包含商家批次单号、转账名称、appid、转账总金额、转账总笔数、转账openid、收款用户姓名等信息。

Example
package main

import (
	"context"
	"log"

	"github.com/Marek-maxs/wechatpay-go/core"
	"github.com/Marek-maxs/wechatpay-go/core/option"
	"github.com/Marek-maxs/wechatpay-go/services/transferbatch"
	"github.com/Marek-maxs/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := transferbatch.TransferBatchApiService{Client: client}
	resp, result, err := svc.InitiateBatchTransfer(ctx,
		transferbatch.InitiateBatchTransferRequest{
			Appid:       core.String("wxf636efh567hg4356"),
			OutBatchNo:  core.String("plfk2020042013"),
			BatchName:   core.String("2019年1月深圳分部报销单"),
			BatchRemark: core.String("2019年1月深圳分部报销单"),
			TotalAmount: core.Int64(4000000),
			TotalNum:    core.Int64(200),
			TransferDetailList: []transferbatch.TransferDetailInput{transferbatch.TransferDetailInput{
				OutDetailNo:    core.String("x23zy545Bd5436"),
				TransferAmount: core.Int64(200000),
				TransferRemark: core.String("2020年4月报销"),
				Openid:         core.String("o-MYE42l80oelYMDE34nYD456Xoy"),
				UserName:       core.String("757b340b45ebef5467rter35gf464344v3542sdf4t6re4tb4f54ty45t4yyry45"),
				UserIdCard:     core.String("8609cb22e1774a50a930e414cc71eca06121bcd266335cda230d24a7886a8d9f"),
			}},
			TransferSceneId: core.String("1000"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call InitiateBatchTransfer err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}
Output:

type TransferBatchEntity

type TransferBatchEntity struct {
	// 转账批次单基本信息
	TransferBatch *TransferBatchGet `json:"transfer_batch"`
	// 当批次状态为“FINISHED”(已完成),且成功查询到转账明细单时返回。包括微信明细单号、明细状态信息
	TransferDetailList []TransferDetailCompact `json:"transfer_detail_list,omitempty"`
}

TransferBatchEntity

func (TransferBatchEntity) Clone

func (TransferBatchEntity) MarshalJSON

func (o TransferBatchEntity) MarshalJSON() ([]byte, error)

func (TransferBatchEntity) String

func (o TransferBatchEntity) String() string

type TransferBatchGet

type TransferBatchGet struct {
	// 微信支付分配的商户号
	Mchid *string `json:"mchid"`
	// 商户系统内部的商家批次单号,在商户系统内部唯一
	OutBatchNo *string `json:"out_batch_no"`
	// 微信批次单号,微信商家转账系统返回的唯一标识
	BatchId *string `json:"batch_id"`
	// 申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
	Appid *string `json:"appid"`
	// ACCEPTED:已受理。批次已受理成功,若发起批量转账的30分钟后,转账批次单仍处于该状态,可能原因是商户账户余额不足等。商户可查询账户资金流水,若该笔转账批次单的扣款已经发生,则表示批次已经进入转账中,请再次查单确认   PROCESSING:转账中。已开始处理批次内的转账明细单   FINISHED:已完成。批次内的所有转账明细单都已处理完成   CLOSED:已关闭。可查询具体的批次关闭原因确认
	BatchStatus *string `json:"batch_status"`
	// API:API方式发起   WEB:页面方式发起
	BatchType *string `json:"batch_type"`
	// 该笔批量转账的名称
	BatchName *string `json:"batch_name"`
	// 转账说明,UTF8编码,最多允许32个字符
	BatchRemark *string `json:"batch_remark"`
	// 如果批次单状态为“CLOSED”(已关闭),则有关闭原因
	CloseReason *CloseReasonType `json:"close_reason,omitempty"`
	// 转账金额单位为“分”
	TotalAmount *int64 `json:"total_amount"`
	// 一个转账批次单最多发起三千笔转账
	TotalNum *int64 `json:"total_num"`
	// 批次受理成功时返回,按照使用rfc3339所定义的格式,格式为YYYY-MM-DDThh:mm:ss+TIMEZONE
	CreateTime *time.Time `json:"create_time,omitempty"`
	// 批次最近一次状态变更的时间,按照使用rfc3339所定义的格式,格式为YYYY-MM-DDThh:mm:ss+TIMEZONE
	UpdateTime *time.Time `json:"update_time,omitempty"`
	// 转账成功的金额,单位为“分”。当批次状态为“PROCESSING”(转账中)时,转账成功金额随时可能变化
	SuccessAmount *int64 `json:"success_amount,omitempty"`
	// 转账成功的笔数。当批次状态为“PROCESSING”(转账中)时,转账成功笔数随时可能变化
	SuccessNum *int64 `json:"success_num,omitempty"`
	// 转账失败的金额,单位为“分”
	FailAmount *int64 `json:"fail_amount,omitempty"`
	// 转账失败的笔数
	FailNum *int64 `json:"fail_num,omitempty"`
	// 指定的转账场景ID
	TransferSceneId *string `json:"transfer_scene_id,omitempty"`
}

TransferBatchGet

func (TransferBatchGet) Clone

func (TransferBatchGet) MarshalJSON

func (o TransferBatchGet) MarshalJSON() ([]byte, error)

func (TransferBatchGet) String

func (o TransferBatchGet) String() string

type TransferDetailApiService

type TransferDetailApiService services.Service

func (*TransferDetailApiService) GetTransferDetailByNo

func (a *TransferDetailApiService) GetTransferDetailByNo(ctx context.Context, req GetTransferDetailByNoRequest) (resp *TransferDetailEntity, result *core.APIResult, err error)

GetTransferDetailByNo 通过微信明细单号查询明细单

## 查询接口说明

明细单号查单接口。商户可以通过该接口查询单笔转账明细单。返回消息中包含微信明细单号、明细状态、转账金额、失败原因、收款用户姓名、用户OpenID等信息。

Example
package main

import (
	"context"
	"log"

	"github.com/Marek-maxs/wechatpay-go/core"
	"github.com/Marek-maxs/wechatpay-go/core/option"
	"github.com/Marek-maxs/wechatpay-go/services/transferbatch"
	"github.com/Marek-maxs/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := transferbatch.TransferDetailApiService{Client: client}
	resp, result, err := svc.GetTransferDetailByNo(ctx,
		transferbatch.GetTransferDetailByNoRequest{
			BatchId:  core.String("1030000071100999991182020050700019480001"),
			DetailId: core.String("1040000071100999991182020050700019500100"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call GetTransferDetailByNo err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}
Output:

func (*TransferDetailApiService) GetTransferDetailByOutNo

func (a *TransferDetailApiService) GetTransferDetailByOutNo(ctx context.Context, req GetTransferDetailByOutNoRequest) (resp *TransferDetailEntity, result *core.APIResult, err error)

GetTransferDetailByOutNo 通过商家明细单号查询明细单

## 查询接口说明

商户明细单号查单接口。商户可以通过该接口查询单笔转账明细单。返回消息中包含微信明细单号、明细状态、转账金额、失败原因、收款用户姓名、用户OpenID等信息。

Example
package main

import (
	"context"
	"log"

	"github.com/Marek-maxs/wechatpay-go/core"
	"github.com/Marek-maxs/wechatpay-go/core/option"
	"github.com/Marek-maxs/wechatpay-go/services/transferbatch"
	"github.com/Marek-maxs/wechatpay-go/utils"
)

func main() {
	var (
		mchID                      string = "190000****"                               // 商户号
		mchCertificateSerialNumber string = "3775************************************" // 商户证书序列号
		mchAPIv3Key                string = "2ab9****************************"         // 商户APIv3密钥
	)

	// 使用 utils 提供的函数从本地文件中加载商户私钥,商户私钥会用来生成请求的签名
	mchPrivateKey, err := utils.LoadPrivateKeyWithPath("/path/to/merchant/apiclient_key.pem")
	if err != nil {
		log.Printf("load merchant private key error:%s", err)
		return
	}

	ctx := context.Background()
	// 使用商户私钥等初始化 client,并使它具有自动定时获取微信支付平台证书的能力
	opts := []core.ClientOption{
		option.WithWechatPayAutoAuthCipher(mchID, mchCertificateSerialNumber, mchPrivateKey, mchAPIv3Key),
	}
	client, err := core.NewClient(ctx, opts...)
	if err != nil {
		log.Printf("new wechat pay client err:%s", err)
		return
	}

	svc := transferbatch.TransferDetailApiService{Client: client}
	resp, result, err := svc.GetTransferDetailByOutNo(ctx,
		transferbatch.GetTransferDetailByOutNoRequest{
			OutDetailNo: core.String("x23zy545Bd5436"),
			OutBatchNo:  core.String("plfk2020042013"),
		},
	)

	if err != nil {
		// 处理错误
		log.Printf("call GetTransferDetailByOutNo err:%s", err)
	} else {
		// 处理返回结果
		log.Printf("status=%d resp=%s", result.Response.StatusCode, resp)
	}
}
Output:

type TransferDetailCompact

type TransferDetailCompact struct {
	// 微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
	DetailId *string `json:"detail_id"`
	// 商户系统内部区分转账批次单下不同转账明细单的唯一标识
	OutDetailNo *string `json:"out_detail_no"`
	// PROCESSING:转账中。正在处理中,转账结果尚未明确   SUCCESS:转账成功   FAIL:转账失败。需要确认失败原因后,再决定是否重新发起对该笔明细单的转账(并非整个转账批次单)
	DetailStatus *string `json:"detail_status"`
}

TransferDetailCompact

func (TransferDetailCompact) Clone

func (TransferDetailCompact) MarshalJSON

func (o TransferDetailCompact) MarshalJSON() ([]byte, error)

func (TransferDetailCompact) String

func (o TransferDetailCompact) String() string

type TransferDetailEntity

type TransferDetailEntity struct {
	// 微信支付分配的商户号
	Mchid *string `json:"mchid"`
	// 商户系统内部的商家批次单号,在商户系统内部唯一
	OutBatchNo *string `json:"out_batch_no"`
	// 微信批次单号,微信商家转账系统返回的唯一标识
	BatchId *string `json:"batch_id"`
	// 申请商户号的appid或商户号绑定的appid(企业号corpid即为此appid)
	Appid *string `json:"appid"`
	// 商户系统内部区分转账批次单下不同转账明细单的唯一标识
	OutDetailNo *string `json:"out_detail_no"`
	// 微信支付系统内部区分转账批次单下不同转账明细单的唯一标识
	DetailId *string `json:"detail_id"`
	// PROCESSING:转账中。正在处理中,转账结果尚未明确   SUCCESS:转账成功   FAIL:转账失败。需要确认失败原因后,再决定是否重新发起对该笔明细单的转账(并非整个转账批次单)
	DetailStatus *string `json:"detail_status"`
	// 转账金额单位为“分”
	TransferAmount *int64 `json:"transfer_amount"`
	// 单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
	TransferRemark *string `json:"transfer_remark"`
	// 如果转账失败则有失败原因
	FailReason *FailReasonType `json:"fail_reason,omitempty"`
	// 商户appid下,某用户的openid
	Openid *string `json:"openid"`
	// 收款方姓名。采用标准RSA算法,公钥由微信侧提供 商户转账时传入了收款用户姓名、查询时会返回收款用户姓名
	UserName *string `json:"user_name,omitempty" encryption:"EM_APIV3"`
	// 转账发起的时间,按照使用rfc3339所定义的格式,格式为YYYY-MM-DDThh:mm:ss+TIMEZONE
	InitiateTime *time.Time `json:"initiate_time"`
	// 明细最后一次状态变更的时间,按照使用rfc3339所定义的格式,格式为YYYY-MM-DDThh:mm:ss+TIMEZONE
	UpdateTime *time.Time `json:"update_time"`
}

TransferDetailEntity

func (TransferDetailEntity) Clone

func (TransferDetailEntity) MarshalJSON

func (o TransferDetailEntity) MarshalJSON() ([]byte, error)

func (TransferDetailEntity) String

func (o TransferDetailEntity) String() string

type TransferDetailInput

type TransferDetailInput struct {
	// 商户系统内部区分转账批次单下不同转账明细单的唯一标识,要求此参数只能由数字、大小写字母组成
	OutDetailNo *string `json:"out_detail_no"`
	// 转账金额单位为“分”
	TransferAmount *int64 `json:"transfer_amount"`
	// 单条转账备注(微信用户会收到该备注),UTF8编码,最多允许32个字符
	TransferRemark *string `json:"transfer_remark"`
	// 商户appid下,某用户的openid
	Openid *string `json:"openid"`
	// 收款方姓名。支持标准RSA算法和国密算法,公钥由微信侧提供 明细转账金额<0.3元时,不允许填写收款用户姓名 明细转账金额 >= 2,000元时,该笔明细必须填写收款用户姓名 同一批次转账明细中的姓名字段传入规则需保持一致,也即全部填写、或全部不填写 若商户传入收款用户姓名,微信支付会校验用户openID与姓名是否一致,并提供电子回单
	UserName *string `json:"user_name,omitempty" encryption:"EM_APIV3"`
	// 收款方身份证号,可不用填(采用标准RSA算法,公钥由微信侧提供) 当填入收款方身份证号时,姓名字段必须填入。
	UserIdCard *string `json:"user_id_card,omitempty" encryption:"EM_APIV3"`
}

TransferDetailInput

func (TransferDetailInput) Clone

func (TransferDetailInput) MarshalJSON

func (o TransferDetailInput) MarshalJSON() ([]byte, error)

func (TransferDetailInput) String

func (o TransferDetailInput) String() string

Jump to

Keyboard shortcuts

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