Documentation ¶
Index ¶
- type AvailableMerchantCollection
- type AvailableSingleitemCollection
- type BackgroundColor
- type CallBackUrlApiService
- type Callback
- type CardLimitation
- type Coupon
- type CouponApiService
- func (a *CouponApiService) ListCouponsByFilter(ctx context.Context, req ListCouponsByFilterRequest) (resp *CouponCollection, result *core.APIResult, err error)
- func (a *CouponApiService) QueryCoupon(ctx context.Context, req QueryCouponRequest) (resp *Coupon, result *core.APIResult, err error)
- func (a *CouponApiService) SendCoupon(ctx context.Context, req SendCouponRequest) (resp *SendCouponResponse, result *core.APIResult, err error)
- type CouponCollection
- type CouponRule
- type CreateCouponStockRequest
- type CreateCouponStockResponse
- type CutTypeMsg
- type DeductBalanceMethod
- type FavorAvailableTime
- type FixedAvailableTime
- type FixedValueStockMsg
- type FormFile
- type ImageMeta
- type JumpTarget
- type ListAvailableMerchantsRequest
- type ListAvailableSingleitemsRequest
- type ListCouponsByFilterRequest
- type ListStocksRequest
- type MediaImageRequest
- type MediaImageResponse
- type ModifyAvailableMerchantRequest
- type ModifyAvailableMerchantResponse
- type ModifyAvailableSingleitemRequest
- type ModifyAvailableSingleitemResponse
- type ModifyStockBudgetRequest
- type ModifyStockBudgetResponse
- type PatternInfo
- type PauseStockBody
- type PauseStockRequest
- type PauseStockResponse
- type PlatformFavorStockStatus
- type QueryCallbackRequest
- type QueryCouponRequest
- type QueryStockRequest
- type RefundFlowRequest
- type RefundFlowResponse
- type RestartStockBody
- type RestartStockRequest
- type RestartStockResponse
- type SendCouponBody
- type SendCouponRequest
- type SendCouponResponse
- type SetCallbackRequest
- type SetCallbackResponse
- type StartStockBody
- type StartStockRequest
- type StartStockResponse
- type Stock
- type StockApiService
- func (a *StockApiService) CreateCouponStock(ctx context.Context, req CreateCouponStockRequest) (resp *CreateCouponStockResponse, result *core.APIResult, err error)
- func (a *StockApiService) ListAvailableMerchants(ctx context.Context, req ListAvailableMerchantsRequest) (resp *AvailableMerchantCollection, result *core.APIResult, err error)
- func (a *StockApiService) ListAvailableSingleitems(ctx context.Context, req ListAvailableSingleitemsRequest) (resp *AvailableSingleitemCollection, result *core.APIResult, err error)
- func (a *StockApiService) ListStocks(ctx context.Context, req ListStocksRequest) (resp *StockCollection, result *core.APIResult, err error)
- func (a *StockApiService) PauseStock(ctx context.Context, req PauseStockRequest) (resp *PauseStockResponse, result *core.APIResult, err error)
- func (a *StockApiService) QueryStock(ctx context.Context, req QueryStockRequest) (resp *Stock, result *core.APIResult, err error)
- func (a *StockApiService) RefundFlow(ctx context.Context, req RefundFlowRequest) (resp *RefundFlowResponse, result *core.APIResult, err error)
- func (a *StockApiService) RestartStock(ctx context.Context, req RestartStockRequest) (resp *RestartStockResponse, result *core.APIResult, err error)
- func (a *StockApiService) StartStock(ctx context.Context, req StartStockRequest) (resp *StartStockResponse, result *core.APIResult, err error)
- func (a *StockApiService) StopStock(ctx context.Context, req StopStockRequest) (resp *StopStockResponse, result *core.APIResult, err error)
- func (a *StockApiService) UseFlow(ctx context.Context, req UseFlowRequest) (resp *UseFlowResponse, result *core.APIResult, err error)
- type StockCollection
- type StockRule
- type StockUseRule
- type StopStockBody
- type StopStockRequest
- type StopStockResponse
- type TradeType
- type UseFlowRequest
- type UseFlowResponse
Examples ¶
- CallBackUrlApiService.QueryCallback
- CallBackUrlApiService.SetCallback
- CouponApiService.ListCouponsByFilter
- CouponApiService.QueryCoupon
- CouponApiService.SendCoupon
- StockApiService.CreateCouponStock
- StockApiService.ListAvailableMerchants
- StockApiService.ListAvailableSingleitems
- StockApiService.ListStocks
- StockApiService.PauseStock
- StockApiService.QueryStock
- StockApiService.RefundFlow
- StockApiService.RestartStock
- StockApiService.StartStock
- StockApiService.StopStock
- StockApiService.UseFlow
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AvailableMerchantCollection ¶
type AvailableMerchantCollection struct { // 可用商户总数量 TotalCount *int64 `json:"total_count"` // 可用商户列表 Data []string `json:"data,omitempty"` // 分页页码 Offset *int64 `json:"offset"` // 分页大小 Limit *int64 `json:"limit"` // 批次号 StockId *string `json:"stock_id"` }
AvailableMerchantCollection
func (AvailableMerchantCollection) Clone ¶
func (o AvailableMerchantCollection) Clone() *AvailableMerchantCollection
func (AvailableMerchantCollection) MarshalJSON ¶
func (o AvailableMerchantCollection) MarshalJSON() ([]byte, error)
func (AvailableMerchantCollection) String ¶
func (o AvailableMerchantCollection) String() string
type AvailableSingleitemCollection ¶
type AvailableSingleitemCollection struct { // 可用单品编码总数 TotalCount *int64 `json:"total_count"` // 可用单品编码 Data []string `json:"data,omitempty"` // 分页页码 Offset *int64 `json:"offset"` // 分页大小 Limit *int64 `json:"limit"` // 批次号 StockId *string `json:"stock_id"` }
AvailableSingleitemCollection
func (AvailableSingleitemCollection) Clone ¶
func (o AvailableSingleitemCollection) Clone() *AvailableSingleitemCollection
func (AvailableSingleitemCollection) MarshalJSON ¶
func (o AvailableSingleitemCollection) MarshalJSON() ([]byte, error)
func (AvailableSingleitemCollection) String ¶
func (o AvailableSingleitemCollection) String() string
type BackgroundColor ¶
type BackgroundColor string
BackgroundColor
const ( BACKGROUNDCOLOR_COLOR010 BackgroundColor = "COLOR010" BACKGROUNDCOLOR_COLOR020 BackgroundColor = "COLOR020" BACKGROUNDCOLOR_COLOR030 BackgroundColor = "COLOR030" BACKGROUNDCOLOR_COLOR040 BackgroundColor = "COLOR040" BACKGROUNDCOLOR_COLOR050 BackgroundColor = "COLOR050" BACKGROUNDCOLOR_COLOR060 BackgroundColor = "COLOR060" BACKGROUNDCOLOR_COLOR070 BackgroundColor = "COLOR070" BACKGROUNDCOLOR_COLOR080 BackgroundColor = "COLOR080" BACKGROUNDCOLOR_COLOR081 BackgroundColor = "COLOR081" BACKGROUNDCOLOR_COLOR082 BackgroundColor = "COLOR082" BACKGROUNDCOLOR_COLOR090 BackgroundColor = "COLOR090" BACKGROUNDCOLOR_COLOR100 BackgroundColor = "COLOR100" BACKGROUNDCOLOR_COLOR101 BackgroundColor = "COLOR101" BACKGROUNDCOLOR_COLOR102 BackgroundColor = "COLOR102" )
Enums of BackgroundColor
func (BackgroundColor) Ptr ¶
func (e BackgroundColor) Ptr() *BackgroundColor
type CallBackUrlApiService ¶
func (*CallBackUrlApiService) QueryCallback ¶
func (a *CallBackUrlApiService) QueryCallback(ctx context.Context, req QueryCallbackRequest) (resp *Callback, result *core.APIResult, err error)
QueryCallback 查询代金券消息通知地址
通过此接口查询营销事件通知的回调URL地址
接口频率:2000QPS
前置条件:开通营销事件推送产品权限
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.CallBackUrlApiService{Client: client} resp, result, err := svc.QueryCallback(ctx, cashcoupons.QueryCallbackRequest{ Mchid: core.String("9856888"), }, ) if err != nil { // 处理错误 log.Printf("call QueryCallback err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*CallBackUrlApiService) SetCallback ¶
func (a *CallBackUrlApiService) SetCallback(ctx context.Context, req SetCallbackRequest) (resp *SetCallbackResponse, result *core.APIResult, err error)
SetCallback 设置代金券消息通知地址
通过此接口设置营销事件通知的回调URL地址
接口频率:1000/min
前置条件:开通营销事件推送产品权限
可接收营销相关的事件通知:核销通知
注意:
1. 该接口只能创建商户号进行设置
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.CallBackUrlApiService{Client: client} resp, result, err := svc.SetCallback(ctx, cashcoupons.SetCallbackRequest{ Mchid: core.String("9856888"), NotifyUrl: core.String("https://pay.weixin.qq.com"), Switch: core.Bool(true), }, ) if err != nil { // 处理错误 log.Printf("call SetCallback err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type Callback ¶
type Callback struct { // 通知地址 NotifyUrl *string `json:"notify_url"` // 商户号 Mchid *string `json:"mchid"` }
Callback
func (Callback) MarshalJSON ¶
type CardLimitation ¶
type CardLimitation struct { // 当批次指定支付方式为银行卡且配置了指定银行卡信息,该字段必填,最多4个中文字符。并将在微信支付收银台中展示给用户。 Name *string `json:"name"` // 当批次指定支付方式为银行卡且配置了指定银行卡信息,该字段必填,按json格式。特殊规则:单个卡BIN的字符长度为[6,9],条目个数限制为[1,10] Bin []string `json:"bin"` }
CardLimitation
func (CardLimitation) Clone ¶
func (o CardLimitation) Clone() *CardLimitation
func (CardLimitation) MarshalJSON ¶
func (o CardLimitation) MarshalJSON() ([]byte, error)
func (CardLimitation) String ¶
func (o CardLimitation) String() string
type Coupon ¶
type Coupon struct { // 微信为创建方商户分配的商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次id StockId *string `json:"stock_id"` // 单品优惠特定信息 CutToMessage *CutTypeMsg `json:"cut_to_message,omitempty"` // 代金券名称 CouponName *string `json:"coupon_name"` // 代金券状态:SENDED-可用,USED-已实扣,EXPIRED-已过期 Status *string `json:"status"` // 代金券描述说明字段 Description *string `json:"description"` // 领券时间 CreateTime *string `json:"create_time"` // NORMAL-满减券;CUT_TO-减至券 CouponType *string `json:"coupon_type"` // true-是;false-否 NoCash *bool `json:"no_cash"` // 可用开始时间 AvailableBeginTime *string `json:"available_begin_time"` // 可用结束时间 AvailableEndTime *string `json:"available_end_time"` // TRUE-是;FALSE-否 Singleitem *bool `json:"singleitem"` // 普通满减券面额、门槛信息 NormalCouponInformation *FixedValueStockMsg `json:"normal_coupon_information,omitempty"` }
Coupon
func (Coupon) MarshalJSON ¶
type CouponApiService ¶
func (*CouponApiService) ListCouponsByFilter ¶
func (a *CouponApiService) ListCouponsByFilter(ctx context.Context, req ListCouponsByFilterRequest) (resp *CouponCollection, result *core.APIResult, err error)
ListCouponsByFilter 根据过滤条件查询用户的券
根据过滤条件查询用户的券(商户号角色、批次、状态)
接口频率:500qps
前置条件:已发代金券
注意事项:
1. 创建方只能查自制批次的券,发券商户只能查询自发批次的券
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.CouponApiService{Client: client} resp, result, err := svc.ListCouponsByFilter(ctx, cashcoupons.ListCouponsByFilterRequest{ Openid: core.String("Openid_example"), Appid: core.String("Appid_example"), StockId: core.String("9865000"), Status: core.String("USED"), CreatorMchid: core.String("9865002"), SenderMchid: core.String("9865001"), AvailableMchid: core.String("9865000"), Offset: core.Int64(0), Limit: core.Int64(20), }, ) if err != nil { // 处理错误 log.Printf("call ListCouponsByFilter err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*CouponApiService) QueryCoupon ¶
func (a *CouponApiService) QueryCoupon(ctx context.Context, req QueryCouponRequest) (resp *Coupon, result *core.APIResult, err error)
QueryCoupon 查询代金券详情
查询用户的券详情
接口频率:500qps
前置条件:用户的券已发放
注意:
1. 该接口支持批次创建商户号与批次发放商户调用
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.CouponApiService{Client: client} resp, result, err := svc.QueryCoupon(ctx, cashcoupons.QueryCouponRequest{ CouponId: core.String("9856888"), Appid: core.String("Appid_example"), Openid: core.String("Openid_example"), }, ) if err != nil { // 处理错误 log.Printf("call QueryCoupon err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*CouponApiService) SendCoupon ¶
func (a *CouponApiService) SendCoupon(ctx context.Context, req SendCouponRequest) (resp *SendCouponResponse, result *core.APIResult, err error)
SendCoupon 发放指定批次的代金券
发放指定批次的代金券
接口频率:500qps
前置条件:已创建并激活代金券批次
是否支持幂等:是
注意:
1. 商户可在H5活动页面、商户小程序、商户APP等自有场景内调用该接口完成发券,商户默认只允许发放本商户号(调用发券接口的商户号)创建的代金券,如需发放其他商户商户创建的代金券,请参考常见问题Q1。 2. 跨商户发券时,请求参数中除了stock\_id和stock\_creator\_mchid为创建方提供的数据,其他的所有调用数据都由发放方提供。
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.CouponApiService{Client: client} resp, result, err := svc.SendCoupon(ctx, cashcoupons.SendCouponRequest{ Openid: core.String("Openid_example"), StockId: core.String("example_stock_id"), OutRequestNo: core.String("example_out_request_no"), Appid: core.String("example_appid"), StockCreatorMchid: core.String("example_stock_creator_mchid"), CouponValue: core.Int64(1), CouponMinimum: core.Int64(1), }, ) if err != nil { // 处理错误 log.Printf("call SendCoupon err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type CouponCollection ¶
type CouponCollection struct { // 结果集 Data []Coupon `json:"data,omitempty"` // 查询结果总数 TotalCount *int64 `json:"total_count"` // 分页大小 Limit *int64 `json:"limit"` // 分页页码 Offset *int64 `json:"offset"` }
CouponCollection
func (CouponCollection) Clone ¶
func (o CouponCollection) Clone() *CouponCollection
func (CouponCollection) MarshalJSON ¶
func (o CouponCollection) MarshalJSON() ([]byte, error)
func (CouponCollection) String ¶
func (o CouponCollection) String() string
type CouponRule ¶
type CouponRule struct { // 需要指定领取后延时生效可选填 CouponAvailableTime *FavorAvailableTime `json:"coupon_available_time,omitempty"` // stock_type为NORMAL时必填 FixedNormalCoupon *FixedValueStockMsg `json:"fixed_normal_coupon,omitempty"` // 订单优惠标记 GoodsTag []string `json:"goods_tag,omitempty"` // 支付方式 TradeType []TradeType `json:"trade_type,omitempty"` // true-是;false-否 CombineUse *bool `json:"combine_use,omitempty"` // 可核销商品编码 AvailableItems []string `json:"available_items,omitempty"` UnavailableItems []string `json:"unavailable_items,omitempty"` // 可核销商户号 AvailableMerchants []string `json:"available_merchants,omitempty"` // 当批次指定支付方式为某张银行卡时才生效,可选的 LimitCard *CardLimitation `json:"limit_card,omitempty"` // 限定该批次的指定支付方式,如零钱、指定银行卡等,需填入支付方式编码, 条目个数限制为[1,1] 。当前支持的支付方式,及其编码枚举值,请参考该文档: https://docs.qq.com/sheet/DWGpMbWx3b1JCbldy?c=E3A0A0 LimitPay []string `json:"limit_pay,omitempty"` }
CouponRule
func (CouponRule) Clone ¶
func (o CouponRule) Clone() *CouponRule
func (CouponRule) MarshalJSON ¶
func (o CouponRule) MarshalJSON() ([]byte, error)
func (CouponRule) String ¶
func (o CouponRule) String() string
type CreateCouponStockRequest ¶
type CreateCouponStockRequest struct { // 批次名称 StockName *string `json:"stock_name"` // 仅配置商户可见,用于自定义信息 Comment *string `json:"comment,omitempty"` // 批次归属商户号 BelongMerchant *string `json:"belong_merchant"` // 批次开始时间 AvailableBeginTime *string `json:"available_begin_time"` // 批次结束时间 AvailableEndTime *string `json:"available_end_time"` // 批次使用规则 StockUseRule *StockRule `json:"stock_use_rule"` // 代金券详情页 PatternInfo *PatternInfo `json:"pattern_info,omitempty"` // CouponUseRule *CouponRule `json:"coupon_use_rule"` // 是否无资金流,true-是;false-否 NoCash *bool `json:"no_cash"` // 批次类型,NORMAL-固定面额满减券批次;DISCOUNT-折扣券批次;EXCHAHGE-换购券批次;RANDOM-千人千面券批次 StockType *string `json:"stock_type"` // 商户创建批次凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性 OutRequestNo *string `json:"out_request_no"` // 扩展属性字段,按json格式,暂时无需填写 ExtInfo *string `json:"ext_info,omitempty"` }
CreateCouponStockRequest
func (CreateCouponStockRequest) Clone ¶
func (o CreateCouponStockRequest) Clone() *CreateCouponStockRequest
func (CreateCouponStockRequest) MarshalJSON ¶
func (o CreateCouponStockRequest) MarshalJSON() ([]byte, error)
func (CreateCouponStockRequest) String ¶
func (o CreateCouponStockRequest) String() string
type CreateCouponStockResponse ¶
type CreateCouponStockResponse struct { // 批次号 StockId *string `json:"stock_id"` // 创建时间 CreateTime *string `json:"create_time"` }
CreateCouponStockResponse
func (CreateCouponStockResponse) Clone ¶
func (o CreateCouponStockResponse) Clone() *CreateCouponStockResponse
func (CreateCouponStockResponse) MarshalJSON ¶
func (o CreateCouponStockResponse) MarshalJSON() ([]byte, error)
func (CreateCouponStockResponse) String ¶
func (o CreateCouponStockResponse) String() string
type CutTypeMsg ¶
type CutTypeMsg struct { // 可用优惠的商品最高单价,单位分 SinglePriceMax *int64 `json:"single_price_max"` // 减至后的优惠单价 CutToPrice *int64 `json:"cut_to_price"` }
CutTypeMsg
func (CutTypeMsg) Clone ¶
func (o CutTypeMsg) Clone() *CutTypeMsg
func (CutTypeMsg) MarshalJSON ¶
func (o CutTypeMsg) MarshalJSON() ([]byte, error)
func (CutTypeMsg) String ¶
func (o CutTypeMsg) String() string
type DeductBalanceMethod ¶
type DeductBalanceMethod string
DeductBalanceMethod
const ( DEDUCTBALANCEMETHOD_BATCH_DEDUCT DeductBalanceMethod = "BATCH_DEDUCT" DEDUCTBALANCEMETHOD_REALTIME_DEDUCT DeductBalanceMethod = "REALTIME_DEDUCT" )
Enums of DeductBalanceMethod
func (DeductBalanceMethod) Ptr ¶
func (e DeductBalanceMethod) Ptr() *DeductBalanceMethod
type FavorAvailableTime ¶
type FavorAvailableTime struct { // 固定时间段可用 FixAvailableTime *FixedAvailableTime `json:"fix_available_time,omitempty"` // true-是;false-否 SecondDayAvailable *bool `json:"second_day_available,omitempty"` // 领取后有效时间,单位分钟 AvailableTimeAfterReceive *int64 `json:"available_time_after_receive,omitempty"` }
FavorAvailableTime
func (FavorAvailableTime) Clone ¶
func (o FavorAvailableTime) Clone() *FavorAvailableTime
func (FavorAvailableTime) MarshalJSON ¶
func (o FavorAvailableTime) MarshalJSON() ([]byte, error)
func (FavorAvailableTime) String ¶
func (o FavorAvailableTime) String() string
type FixedAvailableTime ¶
type FixedAvailableTime struct { // 0-周日;1-周一;以此类推 AvailableWeekDay []int64 `json:"available_week_day,omitempty"` // 当天开始时间,单位秒 BeginTime *int64 `json:"begin_time"` // 当天结束时间,单位秒,默认为23点59分59秒 EndTime *int64 `json:"end_time,omitempty"` }
FixedAvailableTime
func (FixedAvailableTime) Clone ¶
func (o FixedAvailableTime) Clone() *FixedAvailableTime
func (FixedAvailableTime) MarshalJSON ¶
func (o FixedAvailableTime) MarshalJSON() ([]byte, error)
func (FixedAvailableTime) String ¶
func (o FixedAvailableTime) String() string
type FixedValueStockMsg ¶
type FixedValueStockMsg struct { // 面额,单位分 CouponAmount *int64 `json:"coupon_amount"` // 使用券金额门槛,单位分 TransactionMinimum *int64 `json:"transaction_minimum"` }
FixedValueStockMsg
func (FixedValueStockMsg) Clone ¶
func (o FixedValueStockMsg) Clone() *FixedValueStockMsg
func (FixedValueStockMsg) MarshalJSON ¶
func (o FixedValueStockMsg) MarshalJSON() ([]byte, error)
func (FixedValueStockMsg) String ¶
func (o FixedValueStockMsg) String() string
type FormFile ¶
type FormFile struct { Filename *string `json:"filename,omitempty"` ContentType *string `json:"content_type,omitempty"` Content *string `json:"content,omitempty"` }
FormFile
func (FormFile) MarshalJSON ¶
type ImageMeta ¶
type ImageMeta struct { // 商户上传的媒体图片的名称,商户自定义,必须以JPG、BMP、PNG为后缀。 Filename *string `json:"filename,omitempty"` // 图片文件的文件摘要,即对图片文件的二进制内容进行sha256计算得到的值。 Sha256 *string `json:"sha256,omitempty"` }
ImageMeta
func (ImageMeta) MarshalJSON ¶
type JumpTarget ¶
type JumpTarget string
JumpTarget
const ( JUMPTARGET_PAYMENT_CODE JumpTarget = "PAYMENT_CODE" JUMPTARGET_MINI_PROGRAM JumpTarget = "MINI_PROGRAM" JUMPTARGET_DEFAULT_PAGE JumpTarget = "DEFAULT_PAGE" )
Enums of JumpTarget
func (JumpTarget) Ptr ¶
func (e JumpTarget) Ptr() *JumpTarget
type ListAvailableMerchantsRequest ¶
type ListAvailableMerchantsRequest struct { // 分页页码,最大1000 Offset *int64 `json:"offset"` // 分页大小,最大50 Limit *int64 `json:"limit"` // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次号 StockId *string `json:"stock_id"` }
ListAvailableMerchantsRequest
func (ListAvailableMerchantsRequest) Clone ¶
func (o ListAvailableMerchantsRequest) Clone() *ListAvailableMerchantsRequest
func (ListAvailableMerchantsRequest) MarshalJSON ¶
func (o ListAvailableMerchantsRequest) MarshalJSON() ([]byte, error)
func (ListAvailableMerchantsRequest) String ¶
func (o ListAvailableMerchantsRequest) String() string
type ListAvailableSingleitemsRequest ¶
type ListAvailableSingleitemsRequest struct { // 分页页码,最大500 Offset *int64 `json:"offset"` // 分页大小,最大100 Limit *int64 `json:"limit"` // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次号 StockId *string `json:"stock_id"` }
ListAvailableSingleitemsRequest
func (ListAvailableSingleitemsRequest) Clone ¶
func (o ListAvailableSingleitemsRequest) Clone() *ListAvailableSingleitemsRequest
func (ListAvailableSingleitemsRequest) MarshalJSON ¶
func (o ListAvailableSingleitemsRequest) MarshalJSON() ([]byte, error)
func (ListAvailableSingleitemsRequest) String ¶
func (o ListAvailableSingleitemsRequest) String() string
type ListCouponsByFilterRequest ¶
type ListCouponsByFilterRequest struct { // 用户在商户appid 下的唯一标识 Openid *string `json:"openid"` // 微信为发券方商户分配的公众账号ID,接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),不能为APP的appid(在open.weixin.qq.com申请的)。 Appid *string `json:"appid"` // 批次号,是否指定批次号查询,填写available_mchid,该字段不生效 StockId *string `json:"stock_id,omitempty"` // 代金券状态:SENDED-可用,USED-已实扣,填写available_mchid,该字段不生效 Status *string `json:"status,omitempty"` // 批次创建方商户号。创建批次的商户号,批次发放商户号,可用商户号三个参数,任意选填一个。 CreatorMchid *string `json:"creator_mchid,omitempty"` // 批次发放商户号。创建批次的商户号,批次发放商户号,可用商户号三个参数,任意选填一个。 SenderMchid *string `json:"sender_mchid,omitempty"` // 可用商户号。 创建批次的商户号,批次发放商户号,可用商户号三个参数,任意选填一个。 AvailableMchid *string `json:"available_mchid,omitempty"` // 分页页码,默认0,填写available_mchid,该字段不生效 Offset *int64 `json:"offset,omitempty"` // 分页大小,默认20,填写available_mchid,该字段不生效 Limit *int64 `json:"limit,omitempty"` }
ListCouponsByFilterRequest
func (ListCouponsByFilterRequest) Clone ¶
func (o ListCouponsByFilterRequest) Clone() *ListCouponsByFilterRequest
func (ListCouponsByFilterRequest) MarshalJSON ¶
func (o ListCouponsByFilterRequest) MarshalJSON() ([]byte, error)
func (ListCouponsByFilterRequest) String ¶
func (o ListCouponsByFilterRequest) String() string
type ListStocksRequest ¶
type ListStocksRequest struct { // 页码从0开始,默认第0页 Offset *int64 `json:"offset"` // 分页大小,最大10 Limit *int64 `json:"limit"` // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 起始创建时间 CreateStartTime *string `json:"create_start_time,omitempty"` // 终止创建时间 CreateEndTime *string `json:"create_end_time,omitempty"` // 批次状态: unactivated-未激活;audit-审核中;running-运行中;stoped-已停止;paused-暂停发放 Status *string `json:"status,omitempty"` }
ListStocksRequest
func (ListStocksRequest) Clone ¶
func (o ListStocksRequest) Clone() *ListStocksRequest
func (ListStocksRequest) MarshalJSON ¶
func (o ListStocksRequest) MarshalJSON() ([]byte, error)
func (ListStocksRequest) String ¶
func (o ListStocksRequest) String() string
type MediaImageRequest ¶
type MediaImageRequest struct { // 将媒体图片进行二进制转换,得到的媒体图片二进制内容,在请求body中上传此二进制内容。媒体图片只支持JPG、BMP、PNG格式,文件大小不能超过2M。 File *FormFile `json:"file"` // Meta *ImageMeta `json:"meta"` }
MediaImageRequest
func (MediaImageRequest) Clone ¶
func (o MediaImageRequest) Clone() *MediaImageRequest
func (MediaImageRequest) MarshalJSON ¶
func (o MediaImageRequest) MarshalJSON() ([]byte, error)
func (MediaImageRequest) String ¶
func (o MediaImageRequest) String() string
type MediaImageResponse ¶
type MediaImageResponse struct { // 微信返回的媒体文件url地址。 MediaUrl *string `json:"media_url"` }
MediaImageResponse
func (MediaImageResponse) Clone ¶
func (o MediaImageResponse) Clone() *MediaImageResponse
func (MediaImageResponse) MarshalJSON ¶
func (o MediaImageResponse) MarshalJSON() ([]byte, error)
func (MediaImageResponse) String ¶
func (o MediaImageResponse) String() string
type ModifyAvailableMerchantRequest ¶
type ModifyAvailableMerchantRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 增加可用商户列表 AddMchidList []string `json:"add_mchid_list,omitempty"` // 删除可用商户列表 DeleteMchidList []string `json:"delete_mchid_list,omitempty"` }
ModifyAvailableMerchantRequest
func (ModifyAvailableMerchantRequest) Clone ¶
func (o ModifyAvailableMerchantRequest) Clone() *ModifyAvailableMerchantRequest
func (ModifyAvailableMerchantRequest) MarshalJSON ¶
func (o ModifyAvailableMerchantRequest) MarshalJSON() ([]byte, error)
func (ModifyAvailableMerchantRequest) String ¶
func (o ModifyAvailableMerchantRequest) String() string
type ModifyAvailableMerchantResponse ¶
type ModifyAvailableMerchantResponse struct { // 生效时间 EffectTime *string `json:"effect_time"` // 批次号 StockId *string `json:"stock_id"` }
ModifyAvailableMerchantResponse
func (ModifyAvailableMerchantResponse) Clone ¶
func (o ModifyAvailableMerchantResponse) Clone() *ModifyAvailableMerchantResponse
func (ModifyAvailableMerchantResponse) MarshalJSON ¶
func (o ModifyAvailableMerchantResponse) MarshalJSON() ([]byte, error)
func (ModifyAvailableMerchantResponse) String ¶
func (o ModifyAvailableMerchantResponse) String() string
type ModifyAvailableSingleitemRequest ¶
type ModifyAvailableSingleitemRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 增加单品编码列表 AddGoodsIdList []string `json:"add_goods_id_list,omitempty"` // 删除单品编码列表 DeleteGoodsIdList []string `json:"delete_goods_id_list,omitempty"` }
ModifyAvailableSingleitemRequest
func (ModifyAvailableSingleitemRequest) Clone ¶
func (o ModifyAvailableSingleitemRequest) Clone() *ModifyAvailableSingleitemRequest
func (ModifyAvailableSingleitemRequest) MarshalJSON ¶
func (o ModifyAvailableSingleitemRequest) MarshalJSON() ([]byte, error)
func (ModifyAvailableSingleitemRequest) String ¶
func (o ModifyAvailableSingleitemRequest) String() string
type ModifyAvailableSingleitemResponse ¶
type ModifyAvailableSingleitemResponse struct { // 生效时间 EffectTime *string `json:"effect_time"` // 批次号 StockId *string `json:"stock_id"` }
ModifyAvailableSingleitemResponse
func (ModifyAvailableSingleitemResponse) Clone ¶
func (o ModifyAvailableSingleitemResponse) Clone() *ModifyAvailableSingleitemResponse
func (ModifyAvailableSingleitemResponse) MarshalJSON ¶
func (o ModifyAvailableSingleitemResponse) MarshalJSON() ([]byte, error)
func (ModifyAvailableSingleitemResponse) String ¶
func (o ModifyAvailableSingleitemResponse) String() string
type ModifyStockBudgetRequest ¶
type ModifyStockBudgetRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 预算修改目标额度,单位分 TargetMaxAmount *int64 `json:"target_max_amount"` // 当前预算额度,单位分 CurrentMaxAmount *int64 `json:"current_max_amount"` }
ModifyStockBudgetRequest
func (ModifyStockBudgetRequest) Clone ¶
func (o ModifyStockBudgetRequest) Clone() *ModifyStockBudgetRequest
func (ModifyStockBudgetRequest) MarshalJSON ¶
func (o ModifyStockBudgetRequest) MarshalJSON() ([]byte, error)
func (ModifyStockBudgetRequest) String ¶
func (o ModifyStockBudgetRequest) String() string
type ModifyStockBudgetResponse ¶
type ModifyStockBudgetResponse struct { // 批次预算额度,单位分 MaxAmount *int64 `json:"max_amount"` // 批次号 StockId *string `json:"stock_id"` }
ModifyStockBudgetResponse
func (ModifyStockBudgetResponse) Clone ¶
func (o ModifyStockBudgetResponse) Clone() *ModifyStockBudgetResponse
func (ModifyStockBudgetResponse) MarshalJSON ¶
func (o ModifyStockBudgetResponse) MarshalJSON() ([]byte, error)
func (ModifyStockBudgetResponse) String ¶
func (o ModifyStockBudgetResponse) String() string
type PatternInfo ¶
type PatternInfo struct { // 用于说明详细的活动规则,会展示在代金券详情页 Description *string `json:"description"` // 商户logo MerchantLogo *string `json:"merchant_logo,omitempty"` // 商户名称 MerchantName *string `json:"merchant_name,omitempty"` // 背景颜色 BackgroundColor *BackgroundColor `json:"background_color,omitempty"` // 券详情图片 CouponImage *string `json:"coupon_image,omitempty"` // 枚举值:PAYMENT_CODE:跳转至微信支付付款码,点击“立即使用”跳转至微信支付付款码 MINI_PROGRAM:跳转至小程序,点击“立即使用”跳转至配置的商家小程序(需要指定小程序appid和path) DEFAULT_PAGE:跳转至默认页, 点击“立即使用”跳转至默认页面 如未传该参数,则默认跳转至默认页。 JumpTarget *JumpTarget `json:"jump_target,omitempty"` // 跳转的小程序appid,跳转至小程序时必填。跳转的小程序appid需至少和一个可核销商户有绑定关系。 MiniProgramAppid *string `json:"mini_program_appid,omitempty"` // 跳转的小程序path,跳转至小程序时必填。 MiniProgramPath *string `json:"mini_program_path,omitempty"` }
PatternInfo
func (PatternInfo) Clone ¶
func (o PatternInfo) Clone() *PatternInfo
func (PatternInfo) MarshalJSON ¶
func (o PatternInfo) MarshalJSON() ([]byte, error)
func (PatternInfo) String ¶
func (o PatternInfo) String() string
type PauseStockBody ¶
type PauseStockBody struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` }
PauseStockBody
func (PauseStockBody) Clone ¶
func (o PauseStockBody) Clone() *PauseStockBody
func (PauseStockBody) MarshalJSON ¶
func (o PauseStockBody) MarshalJSON() ([]byte, error)
func (PauseStockBody) String ¶
func (o PauseStockBody) String() string
type PauseStockRequest ¶
type PauseStockRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次号 StockId *string `json:"stock_id"` }
PauseStockRequest
func (PauseStockRequest) Clone ¶
func (o PauseStockRequest) Clone() *PauseStockRequest
func (PauseStockRequest) MarshalJSON ¶
func (o PauseStockRequest) MarshalJSON() ([]byte, error)
func (PauseStockRequest) String ¶
func (o PauseStockRequest) String() string
type PauseStockResponse ¶
type PauseStockResponse struct { // 暂停时间,遵循[rfc3339标准格式](https://datatracker.ietf.org/doc/html/rfc3339),格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 PauseTime *string `json:"pause_time"` // 批次号 StockId *string `json:"stock_id"` }
PauseStockResponse
func (PauseStockResponse) Clone ¶
func (o PauseStockResponse) Clone() *PauseStockResponse
func (PauseStockResponse) MarshalJSON ¶
func (o PauseStockResponse) MarshalJSON() ([]byte, error)
func (PauseStockResponse) String ¶
func (o PauseStockResponse) String() string
type PlatformFavorStockStatus ¶
type PlatformFavorStockStatus string
PlatformFavorStockStatus
const ( PLATFORMFAVORSTOCKSTATUS_UNACTIVATED PlatformFavorStockStatus = "UNACTIVATED" PLATFORMFAVORSTOCKSTATUS_RUNNING PlatformFavorStockStatus = "RUNNING" PLATFORMFAVORSTOCKSTATUS_PAUSED PlatformFavorStockStatus = "PAUSED" PLATFORMFAVORSTOCKSTATUS_EXPIRED PlatformFavorStockStatus = "EXPIRED" )
Enums of PlatformFavorStockStatus
func (PlatformFavorStockStatus) Ptr ¶
func (e PlatformFavorStockStatus) Ptr() *PlatformFavorStockStatus
type QueryCallbackRequest ¶
type QueryCallbackRequest struct { // 商户号 Mchid *string `json:"mchid"` }
QueryCallbackRequest
func (QueryCallbackRequest) Clone ¶
func (o QueryCallbackRequest) Clone() *QueryCallbackRequest
func (QueryCallbackRequest) MarshalJSON ¶
func (o QueryCallbackRequest) MarshalJSON() ([]byte, error)
func (QueryCallbackRequest) String ¶
func (o QueryCallbackRequest) String() string
type QueryCouponRequest ¶
type QueryCouponRequest struct { // 代金券id CouponId *string `json:"coupon_id"` // 微信为发券方商户分配的公众账号ID,接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),不能为APP的appid(在open.weixin.qq.com申请的)。 Appid *string `json:"appid"` // Openid信息,用户在appid下的唯一标识 Openid *string `json:"openid"` }
QueryCouponRequest
func (QueryCouponRequest) Clone ¶
func (o QueryCouponRequest) Clone() *QueryCouponRequest
func (QueryCouponRequest) MarshalJSON ¶
func (o QueryCouponRequest) MarshalJSON() ([]byte, error)
func (QueryCouponRequest) String ¶
func (o QueryCouponRequest) String() string
type QueryStockRequest ¶
type QueryStockRequest struct { // 批次id StockId *string `json:"stock_id"` // 批次创建时的商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` }
QueryStockRequest
func (QueryStockRequest) Clone ¶
func (o QueryStockRequest) Clone() *QueryStockRequest
func (QueryStockRequest) MarshalJSON ¶
func (o QueryStockRequest) MarshalJSON() ([]byte, error)
func (QueryStockRequest) String ¶
func (o QueryStockRequest) String() string
type RefundFlowRequest ¶
type RefundFlowRequest struct { // 批次号 StockId *string `json:"stock_id"` }
RefundFlowRequest
func (RefundFlowRequest) Clone ¶
func (o RefundFlowRequest) Clone() *RefundFlowRequest
func (RefundFlowRequest) MarshalJSON ¶
func (o RefundFlowRequest) MarshalJSON() ([]byte, error)
func (RefundFlowRequest) String ¶
func (o RefundFlowRequest) String() string
type RefundFlowResponse ¶
type RefundFlowResponse struct { // 流水文件下载链接,30s内有效 Url *string `json:"url"` // 文件内容的哈希值,防止篡改 HashValue *string `json:"hash_value"` // 哈希算法类型,目前支持sha1 HashType *string `json:"hash_type"` }
RefundFlowResponse
func (RefundFlowResponse) Clone ¶
func (o RefundFlowResponse) Clone() *RefundFlowResponse
func (RefundFlowResponse) MarshalJSON ¶
func (o RefundFlowResponse) MarshalJSON() ([]byte, error)
func (RefundFlowResponse) String ¶
func (o RefundFlowResponse) String() string
type RestartStockBody ¶
type RestartStockBody struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` }
RestartStockBody
func (RestartStockBody) Clone ¶
func (o RestartStockBody) Clone() *RestartStockBody
func (RestartStockBody) MarshalJSON ¶
func (o RestartStockBody) MarshalJSON() ([]byte, error)
func (RestartStockBody) String ¶
func (o RestartStockBody) String() string
type RestartStockRequest ¶
type RestartStockRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次号 StockId *string `json:"stock_id"` }
RestartStockRequest
func (RestartStockRequest) Clone ¶
func (o RestartStockRequest) Clone() *RestartStockRequest
func (RestartStockRequest) MarshalJSON ¶
func (o RestartStockRequest) MarshalJSON() ([]byte, error)
func (RestartStockRequest) String ¶
func (o RestartStockRequest) String() string
type RestartStockResponse ¶
type RestartStockResponse struct { // 生效时间 RestartTime *string `json:"restart_time"` // 批次号 StockId *string `json:"stock_id"` }
RestartStockResponse
func (RestartStockResponse) Clone ¶
func (o RestartStockResponse) Clone() *RestartStockResponse
func (RestartStockResponse) MarshalJSON ¶
func (o RestartStockResponse) MarshalJSON() ([]byte, error)
func (RestartStockResponse) String ¶
func (o RestartStockResponse) String() string
type SendCouponBody ¶
type SendCouponBody struct { // 微信为每个批次分配的唯一id StockId *string `json:"stock_id"` // 商户此次发放凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性 OutRequestNo *string `json:"out_request_no"` // 微信为发券方商户分配的公众账号ID,接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),不能为APP的appid(在open.weixin.qq.com申请的)。 Appid *string `json:"appid"` // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 指定面额发券场景,券面额,其他场景不需要填,单位分 CouponValue *int64 `json:"coupon_value,omitempty"` // 指定面额发券批次门槛,其他场景不需要,单位分 CouponMinimum *int64 `json:"coupon_minimum,omitempty"` }
SendCouponBody
func (SendCouponBody) Clone ¶
func (o SendCouponBody) Clone() *SendCouponBody
func (SendCouponBody) MarshalJSON ¶
func (o SendCouponBody) MarshalJSON() ([]byte, error)
func (SendCouponBody) String ¶
func (o SendCouponBody) String() string
type SendCouponRequest ¶
type SendCouponRequest struct { // 微信为每个批次分配的唯一id StockId *string `json:"stock_id"` // Openid信息,用户在appid下的唯一标识 Openid *string `json:"openid"` // 商户此次发放凭据号(格式:商户id+日期+流水号),商户侧需保持唯一性 OutRequestNo *string `json:"out_request_no"` // 微信为发券方商户分配的公众账号ID,接口传入的所有appid应该为公众号的appid(在mp.weixin.qq.com申请的),不能为APP的appid(在open.weixin.qq.com申请的)。 Appid *string `json:"appid"` // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 指定面额发券场景,券面额,其他场景不需要填,单位分 CouponValue *int64 `json:"coupon_value,omitempty"` // 指定面额发券批次门槛,其他场景不需要,单位分 CouponMinimum *int64 `json:"coupon_minimum,omitempty"` }
SendCouponRequest
func (SendCouponRequest) Clone ¶
func (o SendCouponRequest) Clone() *SendCouponRequest
func (SendCouponRequest) MarshalJSON ¶
func (o SendCouponRequest) MarshalJSON() ([]byte, error)
func (SendCouponRequest) String ¶
func (o SendCouponRequest) String() string
type SendCouponResponse ¶
type SendCouponResponse struct { // 发放给用户的代金券id CouponId *string `json:"coupon_id"` }
SendCouponResponse
func (SendCouponResponse) Clone ¶
func (o SendCouponResponse) Clone() *SendCouponResponse
func (SendCouponResponse) MarshalJSON ¶
func (o SendCouponResponse) MarshalJSON() ([]byte, error)
func (SendCouponResponse) String ¶
func (o SendCouponResponse) String() string
type SetCallbackRequest ¶
type SetCallbackRequest struct { // 微信支付商户号 Mchid *string `json:"mchid"` // 支付通知商户url地址 NotifyUrl *string `json:"notify_url"` // true-开启推送;false-停止推送 Switch *bool `json:"switch,omitempty"` }
SetCallbackRequest
func (SetCallbackRequest) Clone ¶
func (o SetCallbackRequest) Clone() *SetCallbackRequest
func (SetCallbackRequest) MarshalJSON ¶
func (o SetCallbackRequest) MarshalJSON() ([]byte, error)
func (SetCallbackRequest) String ¶
func (o SetCallbackRequest) String() string
type SetCallbackResponse ¶
type SetCallbackResponse struct { // 修改时间 UpdateTime *string `json:"update_time"` // 通知地址 NotifyUrl *string `json:"notify_url"` }
SetCallbackResponse
func (SetCallbackResponse) Clone ¶
func (o SetCallbackResponse) Clone() *SetCallbackResponse
func (SetCallbackResponse) MarshalJSON ¶
func (o SetCallbackResponse) MarshalJSON() ([]byte, error)
func (SetCallbackResponse) String ¶
func (o SetCallbackResponse) String() string
type StartStockBody ¶
type StartStockBody struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` }
StartStockBody
func (StartStockBody) Clone ¶
func (o StartStockBody) Clone() *StartStockBody
func (StartStockBody) MarshalJSON ¶
func (o StartStockBody) MarshalJSON() ([]byte, error)
func (StartStockBody) String ¶
func (o StartStockBody) String() string
type StartStockRequest ¶
type StartStockRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次号 StockId *string `json:"stock_id"` }
StartStockRequest
func (StartStockRequest) Clone ¶
func (o StartStockRequest) Clone() *StartStockRequest
func (StartStockRequest) MarshalJSON ¶
func (o StartStockRequest) MarshalJSON() ([]byte, error)
func (StartStockRequest) String ¶
func (o StartStockRequest) String() string
type StartStockResponse ¶
type StartStockResponse struct { // 生效时间,遵循[rfc3339标准格式](https://datatracker.ietf.org/doc/html/rfc3339),格式为yyyy-MM-DDTHH:mm:ss.sss+TIMEZONE,yyyy-MM-DD表示年月日,T出现在字符串中,表示time元素的开头,HH:mm:ss表示时分秒,TIMEZONE表示时区(+08:00表示东八区时间,领先UTC 8小时,即北京时间)。例如:2015-05-20T13:29:35+08:00表示,北京时间2015年5月20日 13点29分35秒。 StartTime *string `json:"start_time"` // 批次号 StockId *string `json:"stock_id"` }
StartStockResponse
func (StartStockResponse) Clone ¶
func (o StartStockResponse) Clone() *StartStockResponse
func (StartStockResponse) MarshalJSON ¶
func (o StartStockResponse) MarshalJSON() ([]byte, error)
func (StartStockResponse) String ¶
func (o StartStockResponse) String() string
type Stock ¶
type Stock struct { // 批次id StockId *string `json:"stock_id"` // 微信为创建方商户分配的商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次名称 StockName *string `json:"stock_name"` // 批次状态: unactivated-未激活;audit-审核中;running-运行中;stoped-已停止;paused-暂停发放 Status *string `json:"status"` // 批次创建时间 CreateTime *string `json:"create_time"` // 批次描述信息 Description *string `json:"description"` // 普通发券批次特定信息 StockUseRule *StockUseRule `json:"stock_use_rule,omitempty"` // 可用开始时间 AvailableBeginTime *string `json:"available_begin_time"` // 可用结束时间 AvailableEndTime *string `json:"available_end_time"` // 已发券数量 DistributedCoupons *int64 `json:"distributed_coupons"` // 是否无资金流,ture-是;false-否 NoCash *bool `json:"no_cash"` // 批次激活开启时间 StartTime *string `json:"start_time,omitempty"` // 批次永久停止时间 StopTime *string `json:"stop_time,omitempty"` // 单品优惠特定信息 CutToMessage *CutTypeMsg `json:"cut_to_message,omitempty"` // true-是;false-否 Singleitem *bool `json:"singleitem"` // NORMAL-代金券批次;DISCOUNT_CUT-立减与折扣;OTHER-其他 StockType *string `json:"stock_type"` // 微信卡包ID CardId *string `json:"card_id,omitempty"` }
Stock
func (Stock) MarshalJSON ¶
type StockApiService ¶
func (*StockApiService) CreateCouponStock ¶
func (a *StockApiService) CreateCouponStock(ctx context.Context, req CreateCouponStockRequest) (resp *CreateCouponStockResponse, result *core.APIResult, err error)
CreateCouponStock 创建代金券批次
商户通过这个接口创建代金券批次
前置条件:商户开通了代金券产品权限
是否支持幂等:是
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.CreateCouponStock(ctx, cashcoupons.CreateCouponStockRequest{ StockName: core.String("微信支付代金券批次"), Comment: core.String("零售批次"), BelongMerchant: core.String("98568865"), AvailableBeginTime: core.String("2015-05-20T13:29:35.120+08:00"), AvailableEndTime: core.String("2015-05-20T13:29:35.120+08:00"), StockUseRule: &cashcoupons.StockRule{ MaxCoupons: core.Int64(100), MaxAmount: core.Int64(5000), MaxAmountByDay: core.Int64(400), MaxCouponsPerUser: core.Int64(3), NaturalPersonLimit: core.Bool(false), PreventApiAbuse: core.Bool(false), }, PatternInfo: &cashcoupons.PatternInfo{ Description: core.String("微信支付营销代金券"), MerchantLogo: core.String("CDN地址"), MerchantName: core.String("微信支付"), BackgroundColor: cashcoupons.BACKGROUNDCOLOR_COLOR010.Ptr(), CouponImage: core.String("图片cdn地址"), JumpTarget: cashcoupons.JUMPTARGET_PAYMENT_CODE.Ptr(), MiniProgramAppid: core.String("wx23232232323"), MiniProgramPath: core.String("/path/index/index"), }, CouponUseRule: &cashcoupons.CouponRule{ CouponAvailableTime: &cashcoupons.FavorAvailableTime{ FixAvailableTime: &cashcoupons.FixedAvailableTime{ AvailableWeekDay: []int64{int64(1)}, BeginTime: core.Int64(0), EndTime: core.Int64(3600), }, SecondDayAvailable: core.Bool(false), AvailableTimeAfterReceive: core.Int64(1440), }, FixedNormalCoupon: &cashcoupons.FixedValueStockMsg{ CouponAmount: core.Int64(100), TransactionMinimum: core.Int64(100), }, GoodsTag: []string{"123321"}, TradeType: []cashcoupons.TradeType{cashcoupons.TRADETYPE_MICROAPP}, CombineUse: core.Bool(false), AvailableItems: []string{"123321"}, UnavailableItems: []string{"789987"}, AvailableMerchants: []string{"9856000"}, LimitCard: &cashcoupons.CardLimitation{ Name: core.String("精粹白金"), Bin: []string{"62542688"}, }, LimitPay: []string{"BCZ_DEBIT"}, }, NoCash: core.Bool(false), StockType: core.String("NORMAL"), OutRequestNo: core.String("example_out_request_no"), ExtInfo: core.String("{'exinfo1':'1234','exinfo2':'3456'}"), }, ) if err != nil { // 处理错误 log.Printf("call CreateCouponStock err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) ListAvailableMerchants ¶
func (a *StockApiService) ListAvailableMerchants(ctx context.Context, req ListAvailableMerchantsRequest) (resp *AvailableMerchantCollection, result *core.APIResult, err error)
ListAvailableMerchants 查询代金券可用商户
查使用代金券业务的商户询代金券可用商户
接口频率:1000/min
前置条件:非制券方查询主批次信息以获取发券商户列表,调用方只能查询自己制的批次、自己可发的批次
是否支持幂等:是
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.ListAvailableMerchants(ctx, cashcoupons.ListAvailableMerchantsRequest{ Offset: core.Int64(10), Limit: core.Int64(10), StockCreatorMchid: core.String("9865000"), StockId: core.String("9865000"), }, ) if err != nil { // 处理错误 log.Printf("call ListAvailableMerchants err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) ListAvailableSingleitems ¶
func (a *StockApiService) ListAvailableSingleitems(ctx context.Context, req ListAvailableSingleitemsRequest) (resp *AvailableSingleitemCollection, result *core.APIResult, err error)
ListAvailableSingleitems 查询可核销商品编码
查询可核销商品编码
接口频率:600/min
前置条件:调用方只能查询自己制的批次、自己可发的批次的可核销商品编码
是否支持幂等:是
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.ListAvailableSingleitems(ctx, cashcoupons.ListAvailableSingleitemsRequest{ Offset: core.Int64(10), Limit: core.Int64(10), StockCreatorMchid: core.String("9865000"), StockId: core.String("9865000"), }, ) if err != nil { // 处理错误 log.Printf("call ListAvailableSingleitems err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) ListStocks ¶
func (a *StockApiService) ListStocks(ctx context.Context, req ListStocksRequest) (resp *StockCollection, result *core.APIResult, err error)
ListStocks 条件查询批次列表
商户通过这个接口可以查询创建的批次列表
接口频率:1000/s
前置条件:商户开通了代金券产品权限,并创建过代金券
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.ListStocks(ctx, cashcoupons.ListStocksRequest{ Offset: core.Int64(1), Limit: core.Int64(8), StockCreatorMchid: core.String("9856888"), CreateStartTime: core.String("2015-05-20T13:29:35.120+08:00"), CreateEndTime: core.String("2015-05-20T13:29:35.120+08:00"), Status: core.String("paused"), }, ) if err != nil { // 处理错误 log.Printf("call ListStocks err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) PauseStock ¶
func (a *StockApiService) PauseStock(ctx context.Context, req PauseStockRequest) (resp *PauseStockResponse, result *core.APIResult, err error)
PauseStock 暂停批次
通过此接口暂停代金券批次
接口频率:1000/min
前置条件:成功激活代金券批次
注意事项:
1. 暂停后,该代金券批次暂停发放,用户无法通过任何渠道再领取该批次的券
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.PauseStock(ctx, cashcoupons.PauseStockRequest{ StockId: core.String("实例值"), StockCreatorMchid: core.String("8965000"), }, ) if err != nil { // 处理错误 log.Printf("call PauseStock err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) QueryStock ¶
func (a *StockApiService) QueryStock(ctx context.Context, req QueryStockRequest) (resp *Stock, result *core.APIResult, err error)
QueryStock 查询批次详情
查询代金券批次详情信息
接口频率:500qps
前置条件:已创建代金券批次
注意:
1. 该接口支持批次创建商户号与批次发放商户调用
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.QueryStock(ctx, cashcoupons.QueryStockRequest{ StockId: core.String("9856888"), StockCreatorMchid: core.String("123456"), }, ) if err != nil { // 处理错误 log.Printf("call QueryStock err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) RefundFlow ¶
func (a *StockApiService) RefundFlow(ctx context.Context, req RefundFlowRequest) (resp *RefundFlowResponse, result *core.APIResult, err error)
RefundFlow 下载批次退款明细
通过此接口获取指定批次的退款明细数据,包括订单号、单品信息、银行流水号等,用于对账/数据分析
接口频率:1000/min
前置条件:批次过期10小时
注意:
1. 账单文件的下载地址的有效时间为30s。 2. 强烈建议商户将实际账单文件的哈希值和之前从接口获取到的哈希值进行比对,以确认数据的完整性。 3. 该接口响应的信息请求头中不包含微信接口响应的签名值,因此需要跳过验签的流程 4. 该接口需要活动结束后次日10点才可以下载 5. 该接口只能使用创建活动方进行调用”
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.RefundFlow(ctx, cashcoupons.RefundFlowRequest{ StockId: core.String("9865000"), }, ) if err != nil { // 处理错误 log.Printf("call RefundFlow err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) RestartStock ¶
func (a *StockApiService) RestartStock(ctx context.Context, req RestartStockRequest) (resp *RestartStockResponse, result *core.APIResult, err error)
RestartStock 重启批次
商户通过这个接口重新激活已暂停的代金券批次
接口频率:1000/min
前置条件:商户开通了代金券产品权限,且批次处于暂停状态
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.RestartStock(ctx, cashcoupons.RestartStockRequest{ StockId: core.String("8965000"), StockCreatorMchid: core.String("9865000"), }, ) if err != nil { // 处理错误 log.Printf("call RestartStock err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) StartStock ¶
func (a *StockApiService) StartStock(ctx context.Context, req StartStockRequest) (resp *StartStockResponse, result *core.APIResult, err error)
StartStock 激活开启批次
通过此接口激活代金券批次
前置条件:成功创建代金券批次
注意事项:
1. 如果是预充值代金券,激活时会从商户账户余额中锁定本批次的营销资金
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.StartStock(ctx, cashcoupons.StartStockRequest{ StockId: core.String("9856000"), StockCreatorMchid: core.String("8956000"), }, ) if err != nil { // 处理错误 log.Printf("call StartStock err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) StopStock ¶
func (a *StockApiService) StopStock(ctx context.Context, req StopStockRequest) (resp *StopStockResponse, result *core.APIResult, err error)
StopStock 终止批次
商户通过这个接口终止未激活的代金券批次
前置条件:商户开通了代金券产品权限,且批次未激活
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.StopStock(ctx, cashcoupons.StopStockRequest{ StockId: core.String("8695000"), StockCreatorMchid: core.String("9865000"), }, ) if err != nil { // 处理错误 log.Printf("call StopStock err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
func (*StockApiService) UseFlow ¶
func (a *StockApiService) UseFlow(ctx context.Context, req UseFlowRequest) (resp *UseFlowResponse, result *core.APIResult, err error)
UseFlow 下载批次核销明细
通过此接口获取指定批次的核销明细数据,包括订单号、单品信息、银行流水号等,用于对账/数据分析
接口频率:1000/min
前置条件:批次过期10小时
注意:
1. 账单文件的下载地址的有效时间为30s。 2. 强烈建议商户将实际账单文件的哈希值和之前从接口获取到的哈希值进行比对,以确认数据的完整性。 3. 该接口响应的信息请求头中不包含微信接口响应的签名值,因此需要跳过验签的流程。 4. 该接口需要活动结束后次日10点才可以下载。 5. 该接口只能使用创建活动方进行调用。
Example ¶
package main import ( "context" "log" "github.com/wechatpay-apiv3/wechatpay-go/core" "github.com/wechatpay-apiv3/wechatpay-go/core/option" "github.com/wechatpay-apiv3/wechatpay-go/services/cashcoupons" "github.com/wechatpay-apiv3/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 := cashcoupons.StockApiService{Client: client} resp, result, err := svc.UseFlow(ctx, cashcoupons.UseFlowRequest{ StockId: core.String("9865000"), }, ) if err != nil { // 处理错误 log.Printf("call UseFlow err:%s", err) } else { // 处理返回结果 log.Printf("status=%d resp=%s", result.Response.StatusCode, resp) } }
Output:
type StockCollection ¶
type StockCollection struct { // 命中查询条件总数量 TotalCount *int64 `json:"total_count"` // 批次详情 Data []Stock `json:"data,omitempty"` // 分页大小,最大10 Limit *int64 `json:"limit"` // 页码从0开始,默认第0页 Offset *int64 `json:"offset"` }
StockCollection
func (StockCollection) Clone ¶
func (o StockCollection) Clone() *StockCollection
func (StockCollection) MarshalJSON ¶
func (o StockCollection) MarshalJSON() ([]byte, error)
func (StockCollection) String ¶
func (o StockCollection) String() string
type StockRule ¶
type StockRule struct { // 最大发券数 MaxCoupons *int64 `json:"max_coupons"` // 总消耗金额,单位分 MaxAmount *int64 `json:"max_amount"` // 单天最高消耗金额,单位分 MaxAmountByDay *int64 `json:"max_amount_by_day,omitempty"` // 单个用户可领个数 MaxCouponsPerUser *int64 `json:"max_coupons_per_user"` // true-是;false-否,默认否 NaturalPersonLimit *bool `json:"natural_person_limit"` // true-是;false-否,默认否 PreventApiAbuse *bool `json:"prevent_api_abuse"` }
StockRule
func (StockRule) MarshalJSON ¶
type StockUseRule ¶
type StockUseRule struct { // 最大发券数 MaxCoupons *int64 `json:"max_coupons"` // 总消耗金额,单位分 MaxAmount *int64 `json:"max_amount"` // 单天最高消耗金额,单位分 MaxAmountByDay *int64 `json:"max_amount_by_day"` // 固定面额发券批次特定信息 FixedNormalCoupon *FixedValueStockMsg `json:"fixed_normal_coupon,omitempty"` // 单个用户可领个数 MaxCouponsPerUser *int64 `json:"max_coupons_per_user"` // NORMAL-满减券;CUT_TO-减至券 CouponType *string `json:"coupon_type,omitempty"` // 订单优惠标记 GoodsTag []string `json:"goods_tag,omitempty"` // 默认不限制,可设置以下各种组合方式 1、付款码支付 2、小程序支付 3、其他支付 4、付款码支付&小程序支付 5、付款码支付&其他支付 TradeType []TradeType `json:"trade_type,omitempty"` // true-是;false-否 CombineUse *bool `json:"combine_use,omitempty"` }
StockUseRule
func (StockUseRule) Clone ¶
func (o StockUseRule) Clone() *StockUseRule
func (StockUseRule) MarshalJSON ¶
func (o StockUseRule) MarshalJSON() ([]byte, error)
func (StockUseRule) String ¶
func (o StockUseRule) String() string
type StopStockBody ¶
type StopStockBody struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` }
StopStockBody
func (StopStockBody) Clone ¶
func (o StopStockBody) Clone() *StopStockBody
func (StopStockBody) MarshalJSON ¶
func (o StopStockBody) MarshalJSON() ([]byte, error)
func (StopStockBody) String ¶
func (o StopStockBody) String() string
type StopStockRequest ¶
type StopStockRequest struct { // 批次创建方商户号 StockCreatorMchid *string `json:"stock_creator_mchid"` // 批次号 StockId *string `json:"stock_id"` }
StopStockRequest
func (StopStockRequest) Clone ¶
func (o StopStockRequest) Clone() *StopStockRequest
func (StopStockRequest) MarshalJSON ¶
func (o StopStockRequest) MarshalJSON() ([]byte, error)
func (StopStockRequest) String ¶
func (o StopStockRequest) String() string
type StopStockResponse ¶
type StopStockResponse struct { // 暂停时间 StopTime *string `json:"stop_time"` // 批次号 StockId *string `json:"stock_id"` }
StopStockResponse
func (StopStockResponse) Clone ¶
func (o StopStockResponse) Clone() *StopStockResponse
func (StopStockResponse) MarshalJSON ¶
func (o StopStockResponse) MarshalJSON() ([]byte, error)
func (StopStockResponse) String ¶
func (o StopStockResponse) String() string
type TradeType ¶
type TradeType string
TradeType
type UseFlowRequest ¶
type UseFlowRequest struct { // 批次号 StockId *string `json:"stock_id"` }
UseFlowRequest
func (UseFlowRequest) Clone ¶
func (o UseFlowRequest) Clone() *UseFlowRequest
func (UseFlowRequest) MarshalJSON ¶
func (o UseFlowRequest) MarshalJSON() ([]byte, error)
func (UseFlowRequest) String ¶
func (o UseFlowRequest) String() string
type UseFlowResponse ¶
type UseFlowResponse struct { // 流水文件下载链接,30s内有效 Url *string `json:"url"` // 文件内容的哈希值,防止篡改 HashValue *string `json:"hash_value"` // 哈希算法类型,目前只支持sha1 HashType *string `json:"hash_type"` }
UseFlowResponse
func (UseFlowResponse) Clone ¶
func (o UseFlowResponse) Clone() *UseFlowResponse
func (UseFlowResponse) MarshalJSON ¶
func (o UseFlowResponse) MarshalJSON() ([]byte, error)
func (UseFlowResponse) String ¶
func (o UseFlowResponse) String() string