2017-10-05 11:50:53 +00:00
|
|
|
package telegram
|
|
|
|
|
|
|
|
import json "github.com/pquerna/ffjson/ffjson"
|
|
|
|
|
|
|
|
type AnswerPreCheckoutQueryParameters struct {
|
|
|
|
// Unique identifier for the query to be answered
|
2017-10-06 07:55:54 +00:00
|
|
|
PreCheckoutQueryID string `json:"pre_checkout_query_id"`
|
2017-10-05 11:50:53 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Specify True if everything is alright (goods are available, etc.) and the
|
|
|
|
// bot is ready to proceed with the order. Use False if there are any
|
|
|
|
// problems.
|
2017-10-06 08:46:30 +00:00
|
|
|
Ok bool `json:"ok"`
|
2017-10-05 11:50:53 +00:00
|
|
|
|
2017-10-06 07:55:54 +00:00
|
|
|
// Required if ok is False. Error message in human readable form that
|
|
|
|
// explains the reason for failure to proceed with the checkout (e.g. "Sorry,
|
|
|
|
// somebody just bought the last of our amazing black T-shirts while you were
|
|
|
|
// busy filling out your payment details. Please choose a different color or
|
|
|
|
// garment!"). Telegram will display this message to the user.
|
|
|
|
ErrorMessage string `json:"error_message,omitempty"`
|
2017-10-05 11:50:53 +00:00
|
|
|
}
|
|
|
|
|
2017-10-17 11:08:09 +00:00
|
|
|
func NewAnswerPreCheckoutQuery(preCheckoutQueryID string, ok bool) *AnswerPreCheckoutQueryParameters {
|
|
|
|
return &AnswerPreCheckoutQueryParameters{
|
|
|
|
PreCheckoutQueryID: preCheckoutQueryID,
|
|
|
|
Ok: ok,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-10-05 11:50:53 +00:00
|
|
|
// AnswerPreCheckoutQuery respond to such pre-checkout queries.
|
|
|
|
//
|
2017-10-06 07:55:54 +00:00
|
|
|
// Once the user has confirmed their payment and shipping details, the Bot API
|
|
|
|
// sends the final confirmation in the form of an Update with the field
|
|
|
|
// pre_checkout_query. Use this method to respond to such pre-checkout queries.
|
|
|
|
// On success, True is returned.
|
2017-10-05 11:50:53 +00:00
|
|
|
//
|
2017-10-06 07:55:54 +00:00
|
|
|
// Note: The Bot API must receive an answer within 10 seconds after the
|
|
|
|
// pre-checkout query was sent.
|
2017-10-05 11:50:53 +00:00
|
|
|
func (bot *Bot) AnswerPreCheckoutQuery(params *AnswerShippingQueryParameters) (bool, error) {
|
|
|
|
dst, err := json.Marshal(*params)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
resp, err := bot.request(dst, "answerPreCheckoutQuery", nil)
|
|
|
|
if err != nil {
|
|
|
|
return false, err
|
|
|
|
}
|
|
|
|
|
|
|
|
var data bool
|
|
|
|
err = json.Unmarshal(*resp.Result, &data)
|
|
|
|
return data, err
|
|
|
|
}
|