From c8f343456f9a0994ea2d157928fedaa5dfaca258 Mon Sep 17 00:00:00 2001 From: G Date: Tue, 21 May 2024 15:53:28 +0000 Subject: [PATCH] - add order_id to IOrangeResponse - interface for paymentStatus - getTransactions status function --- src/utils/requests/orangePayment.ts | 30 ++++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/src/utils/requests/orangePayment.ts b/src/utils/requests/orangePayment.ts index 1e0c9d6..b1b58f0 100644 --- a/src/utils/requests/orangePayment.ts +++ b/src/utils/requests/orangePayment.ts @@ -15,7 +15,20 @@ export interface IOrangeResponse { message : string, pay_token : string, payment_url : string, - notif_token : string + notif_token : string, + order_id : string, +} + + +type OrangeStatus = "INITIATED" | "SUCCESS" | "FAILED"; +export interface IorangePaymentStatus { + status : OrangeStatus, + code : number, + message : { + status : OrangeStatus, + order_id : string, + txnid ?: string + } } @@ -27,4 +40,17 @@ export const getTransactionsData = async (payload : IorangePaymentStarter) => { data: payload }); -}; \ No newline at end of file +}; + + +export const getTransactionStatus = async(orderId : string) => { + let response = await axiosRequest({ + url: `/api/TransactionCheckStatus/${orderId}/`, + method: "GET", + }) + if (response.status === "INITIATED"){ + throw new Error("Payment is still in progress"); + } else { + return response + } +} \ No newline at end of file -- libgit2 0.27.1