api_call_back.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. // Copyright 2021 Tencent Inc. All rights reserved.
  2. //
  3. // 营销商家券对外API
  4. //
  5. // No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
  6. //
  7. // API version: 0.0.11
  8. // Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
  9. package merchantexclusivecoupon
  10. import (
  11. "context"
  12. nethttp "net/http"
  13. neturl "net/url"
  14. "git.nanodreamtech.com/sg/wechatpay-go/core"
  15. "git.nanodreamtech.com/sg/wechatpay-go/core/consts"
  16. "git.nanodreamtech.com/sg/wechatpay-go/services"
  17. )
  18. type CallBackApiService services.Service
  19. // GetCouponNotify 获取商家券事件通知地址
  20. //
  21. // 使用场景:用于查询设置的通知URL
  22. // 限制条件:仅可以查询由请求商户号设置的商家券通知URL
  23. func (a *CallBackApiService) GetCouponNotify(ctx context.Context, req GetCouponNotifyRequest) (resp *GetCouponNotifyResponse, result *core.APIResult, err error) {
  24. var (
  25. localVarHTTPMethod = nethttp.MethodGet
  26. localVarPostBody interface{}
  27. localVarQueryParams neturl.Values
  28. localVarHeaderParams = nethttp.Header{}
  29. )
  30. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/busifavor/callbacks"
  31. // Make sure All Required Params are properly set
  32. // Setup Query Params
  33. localVarQueryParams = neturl.Values{}
  34. if req.Mchid != nil {
  35. localVarQueryParams.Add("mchid", core.ParameterToString(*req.Mchid, ""))
  36. }
  37. // Determine the Content-Type Header
  38. localVarHTTPContentTypes := []string{}
  39. // Setup Content-Type
  40. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  41. // Perform Http Request
  42. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  43. if err != nil {
  44. return nil, result, err
  45. }
  46. // Extract GetCouponNotifyResponse from Http Response
  47. resp = new(GetCouponNotifyResponse)
  48. err = core.UnMarshalResponse(result.Response, resp)
  49. if err != nil {
  50. return nil, result, err
  51. }
  52. return resp, result, nil
  53. }
  54. // SetCouponNotify 设置商家券事件通知地址
  55. //
  56. // 用于设置接收商家券相关事件通知的URL,可接收商家券相关的事件通知、包括发放通知等。需要设置接收通知的URL,并在商户平台开通[营销事件推送](https://pay.weixin.qq.com/index.php/xphp/cmkt_product/index#/pages/product/product?pid=3)的能力,即可接收到相关通知。
  57. // 营销事件推送:[点击开通产品权限](https://pay.weixin.qq.com/index.php/core/home/login?return_url=%2Findex.php%2Fxphp%2Fcmkt_product%2Findex#/pages/product/product?pid=3)。由商家券批次创建方登录Pay平台,操作开通
  58. //
  59. // #### 注意
  60. // • 仅可以收到由商户自己创建的批次相关的通知
  61. // • 需要设置apiv3密钥,否则无法收到回调。
  62. // • 如果需要领券回调中的参数OpenID。需要创券时候传入notify\_appid参数。
  63. func (a *CallBackApiService) SetCouponNotify(ctx context.Context, req SetCouponNotifyRequest) (resp *SetCouponNotifyResponse, result *core.APIResult, err error) {
  64. var (
  65. localVarHTTPMethod = nethttp.MethodPost
  66. localVarPostBody interface{}
  67. localVarQueryParams neturl.Values
  68. localVarHeaderParams = nethttp.Header{}
  69. )
  70. localVarPath := consts.WechatPayAPIServer + "/v3/marketing/busifavor/callbacks"
  71. // Make sure All Required Params are properly set
  72. // Setup Body Params
  73. localVarPostBody = req
  74. // Determine the Content-Type Header
  75. localVarHTTPContentTypes := []string{"application/json"}
  76. // Setup Content-Type
  77. localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
  78. // Perform Http Request
  79. result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
  80. if err != nil {
  81. return nil, result, err
  82. }
  83. // Extract SetCouponNotifyResponse from Http Response
  84. resp = new(SetCouponNotifyResponse)
  85. err = core.UnMarshalResponse(result.Response, resp)
  86. if err != nil {
  87. return nil, result, err
  88. }
  89. return resp, result, nil
  90. }