receipt template

This commit is contained in:
Tria
2026-06-05 17:23:21 +03:00
parent 620607e50c
commit 6786bdd210
12 changed files with 381 additions and 112 deletions

View File

@@ -4,6 +4,9 @@ import { Public } from "@edr/api-common";
import { randomUUID } from "crypto";
import { Response } from "express"
import * as fs from 'fs';
import * as path from 'path';
import Handlebars from 'handlebars';
@Public()
@@ -22,7 +25,9 @@ export class PaymentController {
async initiatePayment() {
//Only for testing..
const data = await this.paymentService.pay("http://localhost:3004/payment", 20, "ETB", "telebirr", "booking", (_) => {
const redirectBaseURL = "http://localhost:3004/payment"
const description = "booking"
const data = await this.paymentService.pay(redirectBaseURL, 20, "ETB", "telebirr", description, (_) => {
return new Promise((resp, _) => {
resp({
id: randomUUID(),
@@ -41,6 +46,7 @@ export class PaymentController {
if (!payment) {
throw new NotFoundException('payment not found')
}
return res.send(`
<!DOCTYPE html>
<html>
@@ -59,5 +65,25 @@ export class PaymentController {
}
@Get("test")
handleTest(@Res() res: Response) {
const filePath = path.join(__dirname, "templates", "payment.hbs");
console.log(filePath)
console.log(__dirname)
if (fs.existsSync(filePath)) {
const source = fs.readFileSync(filePath, "utf8");
const template = Handlebars.compile(source);
const html = template({
url: "https://example.com"
});
res.send(html)
}
}
}