diff --git a/src/components/AIProviderConfigDialog.tsx b/src/components/AIProviderConfigDialog.tsx
index 94a11e9c..e99eff56 100644
--- a/src/components/AIProviderConfigDialog.tsx
+++ b/src/components/AIProviderConfigDialog.tsx
@@ -895,6 +895,231 @@ export function AIProviderConfigDialog({
}
};
+ const escapeHtml = (str: string): string =>
+ str.replace(/&/g, '&').replace(//g, '>').replace(/"/g, '"').replace(/'/g, ''');
+
+ const handlePrintReceipt = (payment: Payment) => {
+ const receiptDate = new Date((payment.completed_at ?? payment.created_at) * 1000);
+ const formattedDate = new Intl.DateTimeFormat('en-US', {
+ year: 'numeric',
+ month: 'long',
+ day: 'numeric',
+ }).format(receiptDate);
+ const formattedTime = new Intl.DateTimeFormat('en-US', {
+ hour: '2-digit',
+ minute: '2-digit',
+ }).format(receiptDate);
+
+ const paymentMethodDisplay = payment.method === 'stripe' ? t('creditCard') : t('lightning');
+ const statusDisplay = payment.status.charAt(0).toUpperCase() + payment.status.slice(1);
+
+ const printWindow = window.open('', '_blank');
+ if (!printWindow) {
+ toast({
+ title: t('printFailed'),
+ description: t('failedToOpenPrintWindow'),
+ variant: 'destructive',
+ });
+ return;
+ }
+
+ const printHTML = `
+
+
+
+ ${t('receipt')} - ${escapeHtml(payment.id)}
+
+
+
+
+
+
+
${t('receipt')}
+
+
+ - ${t('receiptNumber')}
+ - ${escapeHtml(payment.id)}
+ - ${t('date')}
+ - ${formattedDate} ${formattedTime}
+ - ${t('status')}
+ - ${escapeHtml(statusDisplay)}
+ - ${t('paymentMethodLabel')}
+ - ${paymentMethodDisplay}
+ ${payment.description ? `- ${t('description')}
- ${escapeHtml(payment.description)}
` : ''}
+
+
+
+
+
+
+ ${t('credits')}
+ ${formatCurrency(payment.amount)}
+
+ ${payment.fee > 0 ? `
+
+ ${t('processingFee')}
+ ${formatCurrency(payment.fee)}
+
+ ` : ''}
+
+ ${t('totalCharged')}
+ ${formatCurrency(payment.total)}
+
+
+
+
+
+
+
+ `;
+
+ printWindow.document.write(printHTML);
+ printWindow.document.close();
+
+ printWindow.onload = () => {
+ setTimeout(() => {
+ printWindow.print();
+ }, 250);
+ };
+ };
+
const handleDownloadCSV = () => {
if (!giftcards || giftcards.length === 0) return;
@@ -1307,6 +1532,17 @@ export function AIProviderConfigDialog({
)}
)}
+ {payment.status === 'completed' && (
+
+ )}
))}
diff --git a/src/locales/en.json b/src/locales/en.json
index e33e1769..e9923e2e 100644
--- a/src/locales/en.json
+++ b/src/locales/en.json
@@ -573,5 +573,13 @@
"failedToDuplicateProject": "Failed to duplicate project",
"newProjectName": "New Project Name",
"duplicateProjectDescription": "Create a copy of this project with a new name",
- "resume": "Resume"
+ "resume": "Resume",
+ "printReceipt": "Print Receipt",
+ "receipt": "Receipt",
+ "receiptNumber": "Receipt #",
+ "date": "Date",
+ "status": "Status",
+ "paymentMethodLabel": "Payment Method",
+ "totalCharged": "Total Charged",
+ "thankYouForPurchase": "Thank you for your purchase!"
}
diff --git a/src/locales/ha.json b/src/locales/ha.json
index bd95306b..b5d34bb9 100644
--- a/src/locales/ha.json
+++ b/src/locales/ha.json
@@ -487,5 +487,13 @@
"failedToDuplicateProject": "An kasa kwafin aikin",
"newProjectName": "Sunan Sabon Aikin",
"duplicateProjectDescription": "Ƙirƙiri kwafin wannan aikin da sabon suna",
- "resume": "Ci gaba"
+ "resume": "Ci gaba",
+ "printReceipt": "Buga Rasidi",
+ "receipt": "Rasidi",
+ "receiptNumber": "Rasidi #",
+ "date": "Kwanan wata",
+ "status": "Matsayi",
+ "paymentMethodLabel": "Hanyar Biyan Kuɗi",
+ "totalCharged": "Jimlar da aka Caji",
+ "thankYouForPurchase": "Mun gode da sayan ku!"
}
diff --git a/src/locales/ig.json b/src/locales/ig.json
index 58b24e41..66848ace 100644
--- a/src/locales/ig.json
+++ b/src/locales/ig.json
@@ -484,5 +484,13 @@
"failedToDuplicateProject": "Ọ dara ada imepụta ọrụ",
"newProjectName": "Aha Ọrụ Ọhụrụ",
"duplicateProjectDescription": "Mepụta oyiri nke ọrụ a na aha ọhụrụ",
- "resume": "Gaa n'ihu"
+ "resume": "Gaa n'ihu",
+ "printReceipt": "Bipụta Risịịtị",
+ "receipt": "Risịịtị",
+ "receiptNumber": "Risịịtị #",
+ "date": "Ụbọchị",
+ "status": "Ọnọdụ",
+ "paymentMethodLabel": "Ụzọ Ịkwụ Ụgwọ",
+ "totalCharged": "Nchịkọta Ego a Gbara",
+ "thankYouForPurchase": "Daalụ maka ịzụta gị!"
}
diff --git a/src/locales/pt.json b/src/locales/pt.json
index b3e97f27..b207028a 100644
--- a/src/locales/pt.json
+++ b/src/locales/pt.json
@@ -496,5 +496,13 @@
"failedToDuplicateProject": "Falha ao duplicar projeto",
"newProjectName": "Nome do Novo Projeto",
"duplicateProjectDescription": "Criar uma cópia deste projeto com um novo nome",
- "resume": "Retomar"
+ "resume": "Retomar",
+ "printReceipt": "Imprimir Recibo",
+ "receipt": "Recibo",
+ "receiptNumber": "Recibo Nº",
+ "date": "Data",
+ "status": "Status",
+ "paymentMethodLabel": "Método de Pagamento",
+ "totalCharged": "Total Cobrado",
+ "thankYouForPurchase": "Obrigado pela sua compra!"
}
diff --git a/src/locales/yo.json b/src/locales/yo.json
index 2a83cf7a..f18a585e 100644
--- a/src/locales/yo.json
+++ b/src/locales/yo.json
@@ -484,5 +484,13 @@
"failedToDuplicateProject": "O kuna lati ṣe ẹda iṣẹ akanṣe",
"newProjectName": "Orukọ Iṣẹ Akanṣe Tuntun",
"duplicateProjectDescription": "Ṣẹda ẹda ti iṣẹ akanṣe yii pẹlu orukọ tuntun",
- "resume": "Tẹsiwaju"
+ "resume": "Tẹsiwaju",
+ "printReceipt": "Tẹ Ìwé Ẹ̀rí",
+ "receipt": "Ìwé Ẹ̀rí",
+ "receiptNumber": "Ìwé Ẹ̀rí #",
+ "date": "Ọjọ́",
+ "status": "Ipò",
+ "paymentMethodLabel": "Ọ̀nà Ìsanwó",
+ "totalCharged": "Àpapọ̀ tí a gba",
+ "thankYouForPurchase": "A dúpẹ́ fún rírà rẹ!"
}
diff --git a/src/locales/zh.json b/src/locales/zh.json
index 45af437d..a5c936da 100644
--- a/src/locales/zh.json
+++ b/src/locales/zh.json
@@ -496,5 +496,13 @@
"failedToDuplicateProject": "复制项目失败",
"newProjectName": "新项目名称",
"duplicateProjectDescription": "使用新名称创建此项目的副本",
- "resume": "继续"
+ "resume": "继续",
+ "printReceipt": "打印收据",
+ "receipt": "收据",
+ "receiptNumber": "收据编号",
+ "date": "日期",
+ "status": "状态",
+ "paymentMethodLabel": "支付方式",
+ "totalCharged": "总收费",
+ "thankYouForPurchase": "感谢您的购买!"
}