diff --git a/biome.json b/biome.json index 4372589..7ea7989 100644 --- a/biome.json +++ b/biome.json @@ -50,11 +50,28 @@ } } }, + "overrides": [ + { + "include": ["src/utils/*"], + "linter": { + "rules": { + "style": { + "useFilenamingConvention": { + "level": "error", + "options": { + "filenameCases": ["camelCase", "export"] + } + } + } + } + } + } + ], "vcs": { "enabled": true, "clientKind": "git" }, "files": { - "ignore": ["babel.config.js", "src/utils/*"] + "ignore": ["babel.config.js"] } } diff --git a/src/utils/requests/orangePayment.ts b/src/utils/requests/orangePayment.ts index b2403d7..e7bcce2 100644 --- a/src/utils/requests/orangePayment.ts +++ b/src/utils/requests/orangePayment.ts @@ -2,67 +2,74 @@ import { LOG } from "@logger"; import axiosRequest from "../axios-request"; export interface IorangePaymentStarter { - type_paiement : number, - marchand : "1", - service : "1", - montant : number, - commentaire : string, - numero : string + // biome-ignore lint/style/useNamingConvention: + type_paiement: number; + marchand: "1"; + service: "1"; + montant: number; + commentaire: string; + numero: string; } - -export interface IOrangeResponse { - status : number, - message : string, - pay_token : string, - payment_url : string, - notif_token : string, - order_id : string, +export interface IorangeResponse { + status: number; + message: string; + // biome-ignore lint/style/useNamingConvention: + pay_token: string; + // biome-ignore lint/style/useNamingConvention: + payment_url: string; + // biome-ignore lint/style/useNamingConvention: + notif_token: string; + // biome-ignore lint/style/useNamingConvention: + order_id: string; } - type OrangeStatus = "INITIATED" | "SUCCESS" | "FAILED"; export interface IorangePaymentStatus { - status : OrangeStatus, - code : number, - message : { - status : OrangeStatus, - order_id : string, - txnid ?: string - } + status: OrangeStatus; + code: number; + message: { + status: OrangeStatus; + // biome-ignore lint/style/useNamingConvention: + order_id: string; + txnid?: string; + }; } const log = LOG.extend("orangePayment"); -export const getTransactionsData = async (payload : IorangePaymentStarter) => { - log.http("getTransactionsData", payload); - // const basictoken = base64.encode("admin:admin"); - const response = await axiosRequest({ +export const getTransactionsData = async (payload: IorangePaymentStarter) => { + log.http("getTransactionsData", payload); + // const basictoken = base64.encode("admin:admin"); + const response = await axiosRequest({ url: "/transactions/", method: "POST", - data: payload - + data: payload, }); - log.http("getTransactionsData |", JSON.stringify(response, null, 2)); + log.http("getTransactionsData |", JSON.stringify(response, null, 2)); - return response + return response; }; +export const getTransactionStatus = async (orderId: string) => { + log.http("getTransactionStatus |", { orderId }); -export const getTransactionStatus = async(orderId : string) => { - log.http("getTransactionStatus |", {orderId}); - let response = await axiosRequest({ - url: `/api/TransactionCheckStatus/${orderId}/`, - method: "GET", - }) + try { + const response = await axiosRequest({ + url: `/api/TransactionCheckStatus/${orderId}/`, + method: "GET", + }); - log.http("getTransactionStatus |", JSON.stringify(response, null, 2)); - if (response.status === "INITIATED"){ - log.http("Payment is still in progress, throwing error for mutation to catch"); - throw new Error("Payment is still in progress"); - } else { - log.http("getTransactionStatus |", JSON.stringify(response, null, 2)); - return response - } -} \ No newline at end of file + log.http("getTransactionStatus |", JSON.stringify(response, null, 2)); + if (response.status === "INITIATED") { + log.warn("Payment is still in progress, throwing error for mutation to catch"); + throw new Error("Payment is still in progress"); + } + log.http("getTransactionStatus |", JSON.stringify(response, null, 2)); + return response; + } catch (error) { + log.error("getTransactionStatus |", error); + throw error; + } +};