2017-09-05 08:51:43 +00:00
|
|
|
package telegram
|
|
|
|
|
|
|
|
import json "github.com/pquerna/ffjson/ffjson"
|
|
|
|
|
|
|
|
type SendInvoiceParameters struct {
|
|
|
|
// Unique identifier for the target private chat
|
2017-10-06 07:55:54 +00:00
|
|
|
ChatID int64 `json:"chat_id"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Product name, 1-32 characters
|
2017-10-06 07:55:54 +00:00
|
|
|
Title string `json:"title"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Product description, 1-255 characters
|
2017-10-06 07:55:54 +00:00
|
|
|
Description string `json:"description"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Bot-defined invoice payload, 1-128 bytes. This will not be displayed to
|
|
|
|
// the user, use for your internal processes.
|
|
|
|
Payload string `json:"payload"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Payments provider token, obtained via Botfather
|
2017-10-06 07:55:54 +00:00
|
|
|
ProviderToken string `json:"provider_token"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Unique deep-linking parameter that can be used to generate this invoice
|
|
|
|
// when used as a start parameter
|
|
|
|
StartParameter string `json:"start_parameter"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Three-letter ISO 4217 currency code, see more on currencies
|
2017-10-06 07:55:54 +00:00
|
|
|
Currency string `json:"currency"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Price breakdown, a list of components (e.g. product price, tax, discount,
|
|
|
|
// delivery cost, delivery tax, bonus, etc.)
|
|
|
|
Prices []LabeledPrice `json:"prices"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// URL of the product photo for the invoice. Can be a photo of the goods or a
|
|
|
|
// marketing image for a service. People like it better when they see what
|
|
|
|
// they are paying for.
|
|
|
|
PhotoURL string `json:"photo_url,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Photo size
|
2017-10-06 07:55:54 +00:00
|
|
|
PhotoSize int `json:"photo_size,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Photo width
|
2017-10-06 07:55:54 +00:00
|
|
|
PhotoWidth int `json:"photo_width,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Photo height
|
2017-10-06 07:55:54 +00:00
|
|
|
PhotoHeight int `json:"photo_height,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Pass True, if you require the user's full name to complete the order
|
2017-10-06 07:55:54 +00:00
|
|
|
NeedName bool `json:"need_name,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Pass True, if you require the user's phone number to complete the order
|
2017-10-06 07:55:54 +00:00
|
|
|
NeedPhoneNumber bool `json:"need_phone_number,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Pass True, if you require the user's email to complete the order
|
2017-10-06 07:55:54 +00:00
|
|
|
NeedEmail bool `json:"need_email,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Pass True, if you require the user's shipping address to complete the
|
|
|
|
// order
|
|
|
|
NeedShippingAddress bool `json:"need_shipping_address,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// Pass True, if the final price depends on the shipping method
|
2017-10-06 07:55:54 +00:00
|
|
|
IsFlexible bool `json:"is_flexible,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Sends the message silently. Users will receive a notification with no
|
|
|
|
// sound.
|
|
|
|
DisableNotification bool `json:"disable_notification,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
|
|
|
// If the message is a reply, ID of the original message
|
2017-10-06 07:55:54 +00:00
|
|
|
ReplyToMessageID int `json:"reply_to_message_id,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// A JSON-serialized object for an inline keyboard. If empty, one 'Pay total
|
|
|
|
// price' button will be shown. If not empty, the first button must be a Pay
|
|
|
|
// button.
|
|
|
|
ReplyMarkup *InlineKeyboardMarkup `json:"reply_markup,omitempty"`
|
2017-09-05 08:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// SendInvoice send invoices. On success, the sent Message is returned.
|
|
|
|
func (bot *Bot) SendInvoice(params *SendInvoiceParameters) (*Message, error) {
|
|
|
|
dst, err := json.Marshal(*params)
|
|
|
|
if err != nil {
|
|
|
|
return nil, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := bot.request(dst, "sendInvoice", nil)
|
|
|
|
if err != nil {
|
2017-09-05 09:20:10 +00:00
|
|
|
return nil, err
|
2017-09-05 08:51:43 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
var data Message
|
|
|
|
err = json.Unmarshal(*resp.Result, &data)
|
|
|
|
return &data, err
|
|
|
|
}
|