Skip to content

Commit af6f154

Browse files
Newdev0@outlook.comNewdev0@outlook.com
authored andcommitted
Plugin store
1 parent da33d56 commit af6f154

File tree

3 files changed

+26
-7
lines changed

3 files changed

+26
-7
lines changed

ultroid/app/page.tsx

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,11 +132,21 @@ export default function Home() {
132132
}, [miniAppSettings.donationAmounts]);
133133

134134
// Handle donation button click
135-
const handleDonate = (amount: string) => {
136-
showPopup({
137-
message: `Thanks for donating ${amount} stars! ✨`,
138-
buttons: [{ type: 'ok' }]
139-
});
135+
const handleDonate = async (amount: string) => {
136+
try {
137+
const response = await api.api.createInvoice({ amount: parseInt(amount, 10) });
138+
if (response.url) {
139+
window.open(response.url, '_blank');
140+
} else {
141+
throw new Error('Invalid response from server');
142+
}
143+
} catch (error) {
144+
console.error('Donation failed:', error);
145+
showPopup({
146+
message: 'Failed to create invoice. Please try again later.',
147+
buttons: [{ type: 'ok' }],
148+
});
149+
}
140150
};
141151

142152
const actionButtons: ActionButton[] = [

ultroid/public/config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
{
2-
"apiUrl": "https://tough-nails-grow.loca.lt"
2+
"apiUrl": "https://silver-bottles-clean.loca.lt"
33
}

ultroid/utils/api.ts

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,11 @@ export type UserData = {
6060
auth_date?: number;
6161
};
6262

63+
// API
64+
export type InvoiceData = {
65+
amount: number;
66+
};
67+
6368
// MiniApp settings type
6469
export type MiniAppSettings = {
6570
showStarDonation?: boolean;
@@ -239,7 +244,11 @@ export const api = {
239244
console.error('Error saving mini app setting:', error);
240245
throw error;
241246
}
242-
}
247+
},
248+
249+
async createInvoice(data: InvoiceData): Promise<{ url: string }> {
250+
return makeApiRequest('/api/miniapp/create_invoice', 'POST', data, true);
251+
},
243252
};
244253

245254
// API client for the Ultroid Central API via local proxy

0 commit comments

Comments
 (0)