Skip to content

Commit

Permalink
OwenServices.ts: prettier
Browse files Browse the repository at this point in the history
  • Loading branch information
allgood committed Jul 12, 2024
1 parent 00c46a6 commit 723fa29
Showing 1 changed file with 17 additions and 17 deletions.
34 changes: 17 additions & 17 deletions backend/src/services/PaymentGatewayServices/OwenServices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import { getIO } from "../../libs/socket";
import Invoices from "../../models/Invoices";
import Company from "../../models/Company";
import AppError from "../../errors/AppError";
import GetPublicSettingService from "../SettingServices/GetPublicSettingService";

const owenBaseURL = "https://pix.owenbrasil.com.br";

Expand All @@ -20,11 +19,11 @@ export const owenWebhook = async (
const invoice = await Invoices.findOne({
where: {
txId: qrcodeId,
status: "open",
status: "open"
},
include: { model: Company, as: "company" }
});

if (!invoice || data.valor < invoice.value) {
return res.json({ ok: true });
}
Expand All @@ -45,24 +44,19 @@ export const owenWebhook = async (
io.to(`company-${invoice.companyId}-mainchannel`)
.to("super")
.emit(`company-${invoice.companyId}-payment`, {
action: "CONCLUIDA",
company: invoice.company,
invoiceId: invoice.id,
});

action: "CONCLUIDA",
company: invoice.company,
invoiceId: invoice.id
});
}
return res.json({ ok: true });
}

};

export const owenCreateSubscription = async (
req: Request,
res: Response
): Promise<Response> => {
const {
price,
invoiceId
} = req.body;
const { price, invoiceId } = req.body;

const config = {
params: {
Expand All @@ -80,7 +74,10 @@ export const owenCreateSubscription = async (
if (!invoice) {
throw new Error("Invoice not found");
}
const qrResult = await axios.get( `${owenBaseURL}/api/v1/qrdinamico`, config);
const qrResult = await axios.get(
`${owenBaseURL}/api/v1/qrdinamico`,
config
);
invoice.update({
txId: qrResult.data.data.qrcodeId,
payGw: "owen",
Expand All @@ -89,9 +86,12 @@ export const owenCreateSubscription = async (
return res.json({
qrcode: { qrcode: qrResult.data.data.qrcode },
valor: { original: price }
})
});
} catch (error) {
logger.error({ error }, "owenCreateSubscription error");
throw new AppError("Problema encontrado, entre em contato com o suporte!", 400);
throw new AppError(
"Problema encontrado, entre em contato com o suporte!",
400
);
}
};

0 comments on commit 723fa29

Please sign in to comment.