| 12
 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
 
 | import { _decorator, Component, Node ,Button} from 'cc';const { ccclass, property } = _decorator;
 
 interface InvoiceData {
 chat_id: string;
 title: string;
 description: string;
 payload: string;
 provider_token: string;
 start_parameter: string;
 currency: string;
 prices: string;
 }
 
 @ccclass('NewComponent')
 export class NewComponent extends Component {
 @property(Button)
 button: Button = null;
 @property(Button)
 webAppButton: Button = null;
 private apiUrl: string;
 private invoiceData: InvoiceData;
 start() {
 
 this.apiUrl = `https://api.telegram.org/bot${你机器人的token}/sendInvoice`;
 
 
 this.invoiceData = {
 chat_id: '',
 title: 'Product Title',
 description: 'Product Description',
 payload: 'UniquePayload',
 provider_token: '',
 start_parameter: 'start',
 currency: 'USD',
 prices: JSON.stringify([{ label: 'Product', amount: 1000 }]),
 };
 }
 
 update(deltaTime: number) {
 
 }
 async openBot () {
 try {
 const response = await fetch(this.apiUrl, {
 method: 'POST',
 headers: {
 'Content-Type': 'application/json',
 },
 body: JSON.stringify(this.invoiceData),
 });
 
 const data = await response.json();
 
 if (data.ok) {
 console.log('Invoice sent successfully:', data);
 const botUsername = '';
 window.location.href = `https://t.me/${botUsername}`;
 } else {
 console.error('Failed to send invoice:', data);
 }
 } catch (error) {
 console.error('Error sending invoice:', error);
 }
 }
 }
 
 |