mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 13:40:57 +00:00
receipt template
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user