-
Notifications
You must be signed in to change notification settings - Fork 1
/
exchanges.go
174 lines (145 loc) · 4.95 KB
/
exchanges.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
package go_yandex_checkout
import "time"
type ProcessingResponse struct {
Type string `json:"type"`
Description string `json:"description"`
RetryAfter *uint `json:"retry_after"` // in milliseconds
Id *string `json:"id"`
Code *string `json:"code"`
Parameter *string `json:"parameter"`
}
func (pr ProcessingResponse) GetSleepTime() time.Duration {
if nil == pr.RetryAfter {
return 0
}
return time.Millisecond * time.Duration(*pr.RetryAfter)
}
const (
CARD_TYPE__MASTER_CARD = "MasterCard"
)
type Amount struct {
Value StrFloat64 `json:"value"`
Currency string `json:"currency"`
}
type Card struct {
Last4 string `json:"last4"`
ExpiryMonth StrInt64 `json:"expiry_month"`
ExpiryYear StrInt64 `json:"expiry_year"`
CardType string `json:"card_type"`
}
type Receipt struct {
Items []struct {
Description string `json:"description"`
Quantity string `json:"quantity"`
Amount Amount `json:"amount"`
VatCode int `json:"vat_code"` // https://kassa.yandex.ru/docs/guides/#kody-stawok-nds
} `json:"items"`
TaxSystemCode *int `json:"tax_system_code"`
Phone string `json:"phone"` // https://ru.wikipedia.org/wiki/E.164
Email string
}
const (
CONFIRMATION_TYPE__REDIRECT = "redirect"
CONFIRMATION_TYPE__EXTERNAL = "external"
)
type Confirmation struct {
Type string `json:"type"`
Enforce bool `json:"enforce"`
ReturnUrl string `json:"return_url"`
ConfirmationUrl string `json:"confirmation_url"`
}
type Metadata map[string]interface{}
const (
PAYMENT_METHOD_TYPE__SBERBANK = "sberbank"
PAYMENT_METHOD_TYPE__BANK_CARD = "bank_card"
PAYMENT_METHOD_TYPE__CASH = "cash"
PAYMENT_METHOD_TYPE__YANDEX_MONEY = "yandex_money"
PAYMENT_METHOD_TYPE__QIWI = "qiwi"
PAYMENT_METHOD_TYPE__ALFABANK = "alfabank"
PAYMENT_METHOD_TYPE__WEBMONEY = "webmoney"
PAYMENT_METHOD_TYPE__APPLE_PAY = "apple_pay"
PAYMENT_METHOD_TYPE__MOBILE_BALANCE = "mobile_balance"
)
type PaymentMethod struct {
Type string `json:"type"`
ID string `json:"id"`
Saved bool `json:"saved"`
Card Card `json:"card"`
Title string `json:"title"`
}
type CreatePaymentRequest struct {
Amount Amount `json:"amount"`
PaymentMethodData struct {
Type string `json:"type"`
} `json:"payment_method_data"`
Confirmation Confirmation `json:"confirmation"`
}
type CreatePaymentResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Paid bool `json:"paid"`
Amount Amount `json:"amount"`
CreatedAt time.Time `json:"created_at"`
Metadata Metadata `json:"metadata"`
PaymentMethod PaymentMethod `json:"payment_method"`
}
const (
PAYMENT_STATUS__WAIT = "waiting_for_capture"
PAYMENT_STATUS__PENDING = "pending"
PAYMENT_STATUS__SUCCEEDED = "succeeded"
PAYMENT_STATUS__CANCELED = "canceled"
)
type Recipient struct {
GatewayID string `json:"gateway_id"`
}
type PaymentResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Amount Amount `json:"amount"`
Description *string `json:"description"`
Recipient *Recipient `json:"recipient"`
PaymentMethod PaymentMethod `json:"payment_method"`
CapturedAt *time.Time `json:"captured_at"`
CreatedAt time.Time `json:"created_at"`
ExpiresAt *time.Time `json:"expires_at"`
Confirmation *Confirmation `json:"confirmation"`
Test *bool `json:"test"`
RefundedAmount *Amount `json:"refunded_amount"`
Paid bool `json:"paid"`
ReceiptRegistration *string `json:"receipt_registration"`
Metadata Metadata `json:"metadata"`
}
type GetPaymentResponse PaymentResponse
type CapturePaymentRequest struct {
Amount Amount `json:"amount"`
Receipt Receipt `json:"receipt"`
}
type CapturePaymentResponse PaymentResponse
type CancelPaymentRequest struct{}
type CancelPaymentResponse PaymentResponse
type CreateRefundRequest struct {
PaymentID string `json:"PaymentID"`
Amount Amount `json:"amount"`
Description *string `json:"description"`
Receipt Receipt `json:"receipt"`
}
const (
REFUND_STATUS__CANCELED = "canceled"
REFUND_STATUS__SUCCEEDED = "succeeded"
)
const (
REFUND_RECEIPT_REGISTRATION_PENDING = "pending"
REFUND_RECEIPT_REGISTRATION_SUCCEEDED = "succeeded"
REFUND_RECEIPT_REGISTRATION_CANCELED = "canceled"
)
type RefundResponse struct {
ID string `json:"id"`
PaymentID string `json:"PaymentID"`
Status string `json:"status"`
CreatedAt time.Time `json:"created_at"`
Amount Amount `json:"amount"`
ReceiptRegistration string `json:"receipt_registration"`
Description *string `json:"description"`
}
type CreateRefundResponse RefundResponse
type GetRefundResponse RefundResponse