-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathapi_request.go
52 lines (45 loc) · 1.56 KB
/
api_request.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
package ecpay
import (
"context"
"github.com/Laysi/go-ecpay-sdk/base"
"net/http"
"time"
)
func defaultContext(contexts ...context.Context) context.Context {
if len(contexts) == 0 {
return context.Background()
}
return contexts[0]
}
func (c Client) QueryCreditCardPeriodInfo(merchantTradeNo string, timeStamp time.Time, cs ...context.Context) (ecpayBase.CreditCardPeriodInfo, *http.Response, error) {
params := ecpayBase.QueryCreditCardPeriodInfoRequest{
MerchantID: c.merchantID,
MerchantTradeNo: merchantTradeNo,
TimeStamp: int(timeStamp.Unix()),
}
params.CheckMacValue = c.GenerateCheckMacValue(StructToParamsMap(params))
return c.apiClient.ECPayApi.
QueryCreditCardPeriodInfo(c.WithContext(defaultContext(cs...))).
MerchantID(params.MerchantID).
MerchantTradeNo(params.MerchantTradeNo).
TimeStamp(params.TimeStamp).
CheckMacValue(params.CheckMacValue).
Execute()
}
func (c Client) QueryTradeInfo(merchantTradeNo string, timeStamp time.Time, cs ...context.Context) (ecpayBase.TradeInfo, *http.Response, error) {
params := ecpayBase.QueryTradeInfoRequest{
MerchantID: c.merchantID,
MerchantTradeNo: merchantTradeNo,
TimeStamp: int(timeStamp.Unix()),
PlatformID: c.platformID,
CheckMacValue: "",
}
params.CheckMacValue = c.GenerateCheckMacValue(StructToParamsMap(params))
return c.apiClient.ECPayApi.
QueryTradeInfo(c.WithContext(defaultContext(cs...))).
MerchantID(params.MerchantID).
MerchantTradeNo(params.MerchantTradeNo).
TimeStamp(params.TimeStamp).
CheckMacValue(params.CheckMacValue).
Execute()
}