-
Notifications
You must be signed in to change notification settings - Fork 149
/
Copy pathapi_transactions.go
110 lines (91 loc) · 3.59 KB
/
api_transactions.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
// Copyright 2021 Tencent Inc. All rights reserved.
//
// 公共出行平台代扣服务对外API
//
// 公共出行平台代扣服务对外API
//
// API version: 1.0.0
// Code generated by WechatPay APIv3 Generator based on [OpenAPI Generator](https://openapi-generator.tech); DO NOT EDIT.
package weixinpayscanandride
import (
"context"
"fmt"
nethttp "net/http"
neturl "net/url"
"strings"
"github.com/wechatpay-apiv3/wechatpay-go/core"
"github.com/wechatpay-apiv3/wechatpay-go/core/consts"
"github.com/wechatpay-apiv3/wechatpay-go/services"
)
type TransactionsApiService services.Service
// CreateTransaction 扣费受理
//
// 商户请求扣费受理接口,会完成订单受理。微信支付进行异步扣款,支付完成后,会将订单支付结果发送给商户。
func (a *TransactionsApiService) CreateTransaction(ctx context.Context, req CreateTransactionRequest) (resp *TransactionsEntity, result *core.APIResult, err error) {
var (
localVarHTTPMethod = nethttp.MethodPost
localVarPostBody interface{}
localVarQueryParams neturl.Values
localVarHeaderParams = nethttp.Header{}
)
localVarPath := consts.WechatPayAPIServer + "/v3/qrcode/transactions"
// Make sure All Required Params are properly set
// Setup Body Params
localVarPostBody = req
// Determine the Content-Type Header
localVarHTTPContentTypes := []string{"application/json"}
// Setup Content-Type
localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
// Perform Http Request
result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
if err != nil {
return nil, result, err
}
// Extract TransactionsEntity from Http Response
resp = new(TransactionsEntity)
err = core.UnMarshalResponse(result.Response, resp)
if err != nil {
return nil, result, err
}
return resp, result, nil
}
// QueryTransaction 查询订单
//
// 商户通过商户订单号,来查询订单信息
func (a *TransactionsApiService) QueryTransaction(ctx context.Context, req QueryTransactionRequest) (resp *TransactionsEntity, result *core.APIResult, err error) {
var (
localVarHTTPMethod = nethttp.MethodGet
localVarPostBody interface{}
localVarQueryParams neturl.Values
localVarHeaderParams = nethttp.Header{}
)
// Make sure Path Params are properly set
if req.OutTradeNo == nil {
return nil, nil, fmt.Errorf("field `OutTradeNo` is required and must be specified in QueryTransactionRequest")
}
localVarPath := consts.WechatPayAPIServer + "/v3/qrcode/transactions/out-trade-no/{out_trade_no}"
// Build Path with Path Params
localVarPath = strings.Replace(localVarPath, "{"+"out_trade_no"+"}", neturl.PathEscape(core.ParameterToString(*req.OutTradeNo, "")), -1)
// Make sure All Required Params are properly set
// Setup Query Params
localVarQueryParams = neturl.Values{}
if req.SubMchid != nil {
localVarQueryParams.Add("sub_mchid", core.ParameterToString(*req.SubMchid, ""))
}
// Determine the Content-Type Header
localVarHTTPContentTypes := []string{}
// Setup Content-Type
localVarHTTPContentType := core.SelectHeaderContentType(localVarHTTPContentTypes)
// Perform Http Request
result, err = a.Client.Request(ctx, localVarHTTPMethod, localVarPath, localVarHeaderParams, localVarQueryParams, localVarPostBody, localVarHTTPContentType)
if err != nil {
return nil, result, err
}
// Extract TransactionsEntity from Http Response
resp = new(TransactionsEntity)
err = core.UnMarshalResponse(result.Response, resp)
if err != nil {
return nil, result, err
}
return resp, result, nil
}