-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapi_payment_transaction_qrcode.go
124 lines (110 loc) · 3.72 KB
/
api_payment_transaction_qrcode.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
package sdk
import (
"errors"
"fmt"
"time"
)
// RequestCreatePaymentTransactionQRCode :
type RequestCreatePaymentTransactionQRCode struct {
Amount uint64 `json:"amount"`
CurrencyType string `json:"currencyType"`
Method []string `json:"method"`
Expiry struct {
Type string `json:"type"`
ExpiredDateTime time.Time `json:"expiredAt"`
} `json:"expiry"`
Order struct {
Title string `json:"title"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
} `json:"order"`
RedirectURL string `json:"redirectUrl"`
Type string `json:"type"`
StoreID string `json:"storeId"`
IsPreFillAmount bool `json:"isPreFillAmount"`
}
// ResponsePaymentTransactionQRCodeItem :
type ResponsePaymentTransactionQRCodeItem struct {
Item PaymentTransactionQRCode `json:"item"`
Code string `json:"code"`
Err *Error `json:"error"`
}
// CreatePaymentTransactionQRCode :
func (c Client) CreatePaymentTransactionQRCode(request RequestCreatePaymentTransactionQRCode) (*ResponsePaymentTransactionQRCodeItem, error) {
if c.err != nil {
return nil, c.err
}
method := pathAPICreatePaymentTransactionQRURL.method
requestURL := c.prepareAPIURL(pathAPICreatePaymentTransactionQRURL)
response := new(ResponsePaymentTransactionQRCodeItem)
if err := c.httpAPI(method, requestURL, request, response); err != nil {
return nil, err
}
if response.Err != nil {
return response, errors.New(response.Err.Message)
}
return response, nil
}
// ResponseGetPaymentTransactionQRCode :
type ResponseGetPaymentTransactionQRCode struct {
Item *struct {
Store struct {
ID string `json:"id"`
Name string `json:"name"`
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"`
Type string `json:"type"`
IsPreFillAmount bool `json:"isPreFillAmount"`
CurrencyType string `json:"currencyType"`
Amount int `json:"amount"`
Platform string `json:"platform"`
Method []string `json:"method"`
Expiry struct {
Type string `json:"type"`
Day int `json:"day"`
ExpiredAt time.Time `json:"expiredAt"`
} `json:"expiry"`
Code string `json:"code"`
Status string `json:"status"`
QrCodeURL string `json:"qrCodeUrl"`
RedirectURL string `json:"redirectUrl"`
Order struct {
Title string `json:"title"`
Detail string `json:"detail"`
} `json:"order"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
Err *Error `json:"error"`
}
// GetPaymentTransactionQRByCode :
func (c Client) GetPaymentTransactionQRByCode(code string) (*ResponseGetPaymentTransactionQRCode, error) {
if c.err != nil {
return nil, c.err
}
method := pathAPIGetPaymentTransactionQRURL.method
requestURL := c.prepareAPIURL(pathAPIGetPaymentTransactionQRURL)
response := new(ResponseGetPaymentTransactionQRCode)
if err := c.httpAPI(method, fmt.Sprintf("%s/%s", requestURL, code), nil, response); err != nil {
return nil, err
}
if response.Err != nil {
return response, errors.New(response.Err.Message)
}
return response, nil
}