-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathapi_payment_terminal.go
120 lines (97 loc) · 3.51 KB
/
api_payment_terminal.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
package sdk
import "errors"
// RequestCreatePaymentQuickPay :
type RequestCreatePaymentQuickPay struct {
StoreID string `json:"storeId"`
AuthCode string `json:"authCode"`
IPAddress string `json:"ipAddress"`
Order struct {
ID string `json:"id"`
Title string `json:"title"`
CurrencyType string `json:"currencyType"`
Amount int64 `json:"amount"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
} `json:"order"`
Voucher *RequestCreatePaymentQuickPayVoucher `json:"voucher,omitempty"`
}
// RequestCreatePaymentQuickPayVoucher :
type RequestCreatePaymentQuickPayVoucher struct {
Code string `json:"code"`
}
// ResponseCreatePaymentQuickPay :
type ResponseCreatePaymentQuickPay struct {
Item PaymentTransaction `json:"item"`
Code string `json:"code"`
Err *Error `json:"error"`
}
// CreatePaymentQuickPay :
func (c Client) CreatePaymentQuickPay(request RequestCreatePaymentQuickPay) (*ResponseCreatePaymentQuickPay, error) {
if c.err != nil {
return nil, c.err
}
method := pathAPICreatePaymentQuickPay.method
requestURL := c.prepareAPIURL(pathAPICreatePaymentQuickPay)
response := new(ResponseCreatePaymentQuickPay)
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
}
type RequestCreateTerminalPaymentType string
const (
RequestCreateTerminalPaymentTypeWallet = "E-WALLET"
RequestCreateTerminalPaymentTypeCard = "CARD"
)
type RequestCreateTerminalPaymentReceiptType uint
const (
RequestCreateTerminalPaymentReceiptTypeMerchantAndCustomer RequestCreateTerminalPaymentReceiptType = 1
RequestCreateTerminalPaymentReceiptTypeCustomer RequestCreateTerminalPaymentReceiptType = 2
RequestCreateTerminalPaymentReceiptTypeNone RequestCreateTerminalPaymentReceiptType = 3
)
type RequestCreateTerminalPaymentCameraType string
const (
RequestCreateTerminalPaymentCameraTypeFront = "FRONT"
RequestCreateTerminalPaymentCameraTypeBack = "BACK"
)
// RequestCreateTerminalPaymentOrder :
type RequestCreateTerminalPaymentOrder struct {
ID string `json:"id"`
Title string `json:"title"`
CurrencyType string `json:"currencyType"`
Amount uint `json:"amount"`
Detail string `json:"detail"`
AdditionalData string `json:"additionalData"`
}
// RequestCreateTerminalPayment :
type RequestCreateTerminalPayment struct {
TerminalID string `json:"terminalId"`
Type RequestCreateTerminalPaymentType `json:"type"`
CameraType RequestCreateTerminalPaymentCameraType `json:"cameraType"`
ReceiptType uint `json:"receiptType"`
Order RequestCreateTerminalPaymentOrder `json:"order"`
}
// ResponseCreatePaymentQuickPay :
type ResponseCreateTerminalPayment struct {
PaymentTransaction
Err *Error `json:"error"`
}
// CreateTerminalPayment :
func (c Client) CreateTerminalPayment(request RequestCreateTerminalPayment) (*ResponseCreateTerminalPayment, error) {
if c.err != nil {
return nil, c.err
}
method := pathAPICreateTerminalPayment.method
requestURL := c.prepareAPIURL(pathAPICreateTerminalPayment)
response := new(ResponseCreateTerminalPayment)
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
}