-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathquery_payment.go
187 lines (180 loc) · 5.53 KB
/
query_payment.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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
package rm
import (
"context"
"time"
)
// GetPaymentByOrderIDResponse :
type GetPaymentByOrderIDResponse struct {
Item struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
ImageURL string `json:"imageUrl"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
ReferenceID string `json:"referenceId"`
TransactionID string `json:"transactionId"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
Amount uint `json:"amount"`
} `json:"order"`
TerminalID string `json:"terminalId"`
Payee struct {
} `json:"payee"`
CurrencyType string `json:"currencyType"`
BalanceAmount uint `json:"balanceAmount"`
Platform string `json:"platform"`
Method string `json:"method"`
TransactionAt time.Time `json:"transactionAt"`
Type PaymentType `json:"type"`
Status PaymentStatus `json:"status"`
Region string `json:"region"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
// GetPaymentByOrderID :
func (c *Client) GetPaymentByOrderID(
ctx context.Context,
orderID string,
) (*GetPaymentByOrderIDResponse, error) {
resp := new(GetPaymentByOrderIDResponse)
if err := c.do(
ctx,
"query_payment_by_order_id",
"get",
c.openEndpoint+"/v3/payment/transaction/order/"+orderID,
nil,
resp,
); err != nil {
return nil, err
}
return resp, nil
}
// GetPaymentByTransactionIDResponse :
type GetPaymentByTransactionIDResponse struct {
Item struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
ImageURL string `json:"imageUrl"`
AddressLine1 string `json:"addressLine1"`
AddressLine2 string `json:"addressLine2"`
PostCode string `json:"postCode"`
City string `json:"city"`
State string `json:"state"`
Country string `json:"country"`
CountryCode string `json:"countryCode"`
PhoneNumber string `json:"phoneNumber"`
GeoLocation struct {
Latitude float64 `json:"latitude"`
Longitude float64 `json:"longitude"`
} `json:"geoLocation"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"store"`
ReferenceID string `json:"referenceId"`
TransactionID string `json:"transactionId"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
Amount uint `json:"amount"`
} `json:"order"`
TerminalID string `json:"terminalId"`
Payee struct {
} `json:"payee"`
CurrencyType string `json:"currencyType"`
BalanceAmount int `json:"balanceAmount"`
Voucher interface{} `json:"voucher"`
Platform string `json:"platform"`
Method string `json:"method"`
TransactionAt time.Time `json:"transactionAt"`
Type string `json:"type"`
Status PaymentStatus `json:"status"`
Region string `json:"region"`
Source string `json:"source"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
// GetPaymentByTransactionID :
func (c *Client) GetPaymentByTransactionID(
ctx context.Context,
transactionID string,
) (*GetPaymentByTransactionIDResponse, error) {
resp := new(GetPaymentByTransactionIDResponse)
if err := c.do(
ctx,
"query_payment_by_transaction_id",
"get",
c.openEndpoint+"/v3/payment/transaction/"+transactionID,
nil,
resp,
); err != nil {
return nil, err
}
return resp, nil
}
type GetPaymentByCheckoutIDResponse struct {
Item struct {
ID string `json:"id"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
CurrencyType string `json:"currencyType"`
Amount uint `json:"amount"`
} `json:"order"`
Type string `json:"type"`
TransactionID string `json:"transactionId"`
Platform string `json:"platform"`
Method []string `json:"method"`
RedirectURL string `json:"redirectUrl"`
NotifyURL string `json:"notifyUrl"`
StartAt time.Time `json:"startAt"`
EndAt time.Time `json:"endAt"`
Status string `json:"status"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
// GetPaymentByCheckoutID :
func (c *Client) GetPaymentByCheckoutID(
ctx context.Context,
checkoutID string,
) (*GetPaymentByCheckoutIDResponse, error) {
resp := new(GetPaymentByCheckoutIDResponse)
if err := c.do(
ctx,
"query_payment_by_checkout_id",
"get",
c.openEndpoint+"/v3/payment/online?checkoutId="+checkoutID,
nil,
resp,
); err != nil {
return nil, err
}
return resp, nil
}