Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

"error_code":400 Bad Request: STARS_INVOICE_INVALID #751

Open
vicabert091 opened this issue Sep 27, 2024 · 1 comment
Open

"error_code":400 Bad Request: STARS_INVOICE_INVALID #751

vicabert091 opened this issue Sep 27, 2024 · 1 comment

Comments

@vicabert091
Copy link

vicabert091 commented Sep 27, 2024

func TestStar(t *testing.T) {
	price := make([]tgbotapi.LabeledPrice, 0)

	price = []tgbotapi.LabeledPrice{
		tgbotapi.LabeledPrice{
			Label:  "XTR",
			Amount: 1,
		},
	}

	invoice := tgbotapi.NewInvoice(ChatID, "star pay", "start", "v-1",
		"", "uZzZW3MS1XcCnEyrbBvsFRE8m96dqzQL",
		"XTR", price)
	api, err := tgbotapi.NewBotAPI(token)
	if err != nil {
		t.Fatal(err)
	}
	api.Debug = true
	invoice.MaxTipAmount = 500
	invoice.SuggestedTipAmounts = []int{100, 200, 300}
	send, err := api.Send(invoice)
	if err != nil {
		t.Fatal(err)
	}
	fmt.Println(send)
}

err: Endpoint: sendInvoice, response: {"ok":false,"error_code":400,"description":"Bad Request: STARS_INVOICE_INVALID"}
star_test.go:36: Bad Request: STARS_INVOICE_INVALID

@dengaletin
Copy link

func TestStar(cmd BuyCommand) {
	price := []tg.LabeledPrice{
		{
			Label:  "XTR",
			Amount: 1,
		},
	}

	invoice := tg.NewInvoice(
		cmd.Update.Message.Chat.ID,
		"Star Pay", 
		"Purchase Stars", 
		"test",  
		"",
		"start_param_unique_v1", 
		"XTR",  
		price,
	)
	invoice.SuggestedTipAmounts = []int{}

	bot := utils.GetBot()
	sentInvoice, err := bot.Send(invoice)
	if err != nil {
		log.Printf("Error sending invoice: %v", err)
		return
	}
	fmt.Println("Invoice sent successfully:", sentInvoice)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants