-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathtransaction_qr.go
103 lines (97 loc) · 2.99 KB
/
transaction_qr.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
package rm
import (
"context"
"time"
)
// CreateTransactionQRType :
type CreateTransactionQRType string
const (
CreateTransactionQRTypeStatic CreateTransactionQRType = "STATIC"
)
// CreateTransactionQRRequest :
type CreateTransactionQRRequest struct {
Type CreateTransactionQRType `json:"type"`
CurrencyType string `json:"currencyType"`
Amount int `json:"amount"`
IsPreFillAmount bool `json:"isPreFillAmount"`
Method []string `json:"method"`
Order struct {
AdditionalData string `json:"additionalData"`
Details string `json:"details"`
Title string `json:"title"`
} `json:"order"`
Expiry struct {
Type string `json:"type"`
} `json:"expiry"`
RedirectURL string `json:"redirectUrl"`
StoreID string `json:"storeId"`
}
// CreateTransactionQRResponse :
type CreateTransactionQRResponse 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"`
Type string `json:"type"`
IsPreFillAmount bool `json:"isPreFillAmount"`
CurrencyType string `json:"currencyType"`
Amount int `json:"amount"`
Platform string `json:"platform"`
Method interface{} `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"`
AdditionalData string `json:"additionalData"`
} `json:"order"`
CreatedAt time.Time `json:"createdAt"`
UpdatedAt time.Time `json:"updatedAt"`
} `json:"item"`
Code string `json:"code"`
}
// CreateTransactionQR :
func (c *Client) CreateTransactionQR(
ctx context.Context,
req CreateTransactionQRRequest,
) (*CreateTransactionQRResponse, error) {
if req.CurrencyType == "" {
req.CurrencyType = "MYR"
}
resp := new(CreateTransactionQRResponse)
if err := c.do(
ctx,
"create_transaction_qrcode",
"post",
c.openEndpoint+"/v3/payment/transaction/qrcode",
req,
resp,
); err != nil {
return nil, err
}
return resp, nil
}