Check WebApp version before opening invoice

This commit is contained in:
Egor
2026-01-28 21:02:16 +03:00
committed by GitHub
parent f2e03ffb33
commit 56c2d7be90

View File

@@ -207,8 +207,12 @@ export default function Wheel() {
const starsInvoiceMutation = useMutation({
mutationFn: wheelApi.createStarsInvoice,
onSuccess: (data) => {
if (window.Telegram?.WebApp?.openInvoice) {
window.Telegram.WebApp.openInvoice(data.invoice_url, async (status) => {
const webApp = window.Telegram?.WebApp;
// openInvoice requires WebApp version 6.1+
const supportsInvoice =
webApp?.openInvoice && webApp?.isVersionAtLeast && webApp.isVersionAtLeast('6.1');
if (supportsInvoice) {
webApp.openInvoice(data.invoice_url, async (status) => {
if (status === 'paid') {
// Mark this as a Stars spin so handleSpinComplete knows to use the pending result
isStarsSpinRef.current = true;