-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpayments.go
139 lines (114 loc) · 3.64 KB
/
payments.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
package telegram
import "context"
// SendInvoiceResponse interface
type SendInvoiceResponse interface {
Response
GetMessage() *Message
}
type sendInvoiceResponse struct {
response
Result *Message `json:"result,omitempty"`
}
func (r *sendInvoiceResponse) GetMessage() *Message {
return r.Result
}
func (b *bot) SendInvoice(ctx context.Context, options ...MethodOption) (SendInvoiceResponse, error) {
var res sendInvoiceResponse
err := b.doRequest(ctx, "sendInvoice", &res, options...)
if err != nil {
return nil, err
}
return &res, nil
}
// AnswerShippingQueryResponse interface
type AnswerShippingQueryResponse interface {
Response
}
type answerShippingQueryResponse struct {
response
}
func (b *bot) AnswerShippingQuery(ctx context.Context, options ...MethodOption) (AnswerShippingQueryResponse, error) {
var res answerShippingQueryResponse
err := b.doRequest(ctx, "answerShippingQuery", &res, options...)
if err != nil {
return nil, err
}
return &res, nil
}
// AnswerPreCheckoutQueryResponse interface
type AnswerPreCheckoutQueryResponse interface {
Response
}
type answerPreCheckoutQueryResponse struct {
response
}
func (b *bot) AnswerPreCheckoutQuery(ctx context.Context, options ...MethodOption) (AnswerPreCheckoutQueryResponse, error) {
var res answerPreCheckoutQueryResponse
err := b.doRequest(ctx, "answerPreCheckoutQuery", &res, options...)
if err != nil {
return nil, err
}
return &res, nil
}
// LabeledPrice struct
type LabeledPrice struct {
Label string `json:"label"`
Amount int `json:"amount"`
}
// Invoice struct
type Invoice struct {
Title string `json:"title"`
Description string `json:"description"`
StartParameter string `json:"start_parameter"`
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
}
// ShippingAddress struct
type ShippingAddress struct {
CountryCode string `json:"country_code"`
State string `json:"state"`
City string `json:"city"`
StreetLine1 string `json:"street_line_1"`
StreetLine2 string `json:"street_line_2"`
PostCode string `json:"post_code"`
}
// OrderInfo struct
type OrderInfo struct {
Name string `json:"name"`
PhoneNumber *string `json:"phone_number,omitempty"`
Email *string `json:"email,omitempty"`
ShippingAddress *ShippingAddress `json:"shipping_address,omitempty"`
}
// ShippingOption struct
type ShippingOption struct {
ID string `json:"id"`
Title string `json:"title"`
Prices []LabeledPrice `json:"prices"`
}
// SuccessfulPayment struct
type SuccessfulPayment struct {
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
InvoicePayload string `json:"invoice_payload"`
ShippingOptionID *string `json:"shipping_option_id,omitempty"`
OrderInfo *OrderInfo `json:"order_info,omitempty"`
TelegramPaymentChargeID string `json:"telegram_payment_charge_id"`
ProviderPaymentChargeID string
}
// ShippingQuery struct
type ShippingQuery struct {
ID string `json:"id"`
From User `json:"from"`
InvoicePayload string `json:"invoice_payload"`
ShippingAddress ShippingAddress `json:"shipping_address"`
}
// PreCheckoutQuery struct
type PreCheckoutQuery struct {
ID string `json:"id"`
From User `json:"from"`
Currency string `json:"currency"`
TotalAmount int `json:"total_amount"`
InvoicePayload string `json:"invoice_payload"`
ShippingOptionID *string `json:"shipping_option_id"`
OrderInfo *OrderInfo `json:"order_info"`
}