From f04af7eeb34f4ceef1a0ac7e45b699f93ea1fed3 Mon Sep 17 00:00:00 2001 From: G Date: Thu, 23 May 2024 16:16:04 +0000 Subject: [PATCH] refactor into a clear instructions flow for orange payment --- src/screens/PaymentAmountInputScreen.tsx | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/src/screens/PaymentAmountInputScreen.tsx b/src/screens/PaymentAmountInputScreen.tsx index eeb9a65..b025236 100644 --- a/src/screens/PaymentAmountInputScreen.tsx +++ b/src/screens/PaymentAmountInputScreen.tsx @@ -55,20 +55,27 @@ const PaymentAmountInputScreen: PaymentStackScreenComponentProps<"paymentAmountI log.info("OM so we stays on screen !!"); log.info("Calling api with amount :: ", amountToPay); - await orangeTransactionInitializerMutation.mutateAsync(amountToPay); - log.info( - `Was the transaction initialization a success ? ${orangeTransactionInitializerMutation.isSuccess}`, - ); - if (orangeTransactionInitializerMutation.isSuccess) { - log.info("initilization was a success, checking for status"); - await transactionsStatusMutation.mutateAsync( - orangeTransactionInitializerMutation.data.order_id, - ); - log.info( - "result of transactions", - JSON.stringify(transactionsStatusMutation.data, null, 2), - ); - } + const { payment_url, order_id } = + await orangeTransactionInitializerMutation.mutateAsync(amountToPay); + log.info("Url de paiement orange", payment_url); + log.info("Ouverture du navigateur sur la page de paiement..."); + await handlePaymentUsingBrowser(payment_url); + log.info("Verifying transaction status..."); + const response = await transactionsStatusMutation.mutateAsync(order_id); + log.info("result of transactions", JSON.stringify(response, null, 2)); + // log.info( + // `Was the transaction initialization a success ? ${orangeTransactionInitializerMutation.isSuccess}`, + // ); + // if (orangeTransactionInitializerMutation.isSuccess) { + // log.info("initilization was a success, checking for status"); + // await transactionsStatusMutation.mutateAsync( + // orangeTransactionInitializerMutation.data.order_id, + // ); + // log.info( + // "result of transactions", + // JSON.stringify(transactionsStatusMutation.data, null, 2), + // ); + // } // console.log("Response transaction", response); break; @@ -84,6 +91,7 @@ const PaymentAmountInputScreen: PaymentStackScreenComponentProps<"paymentAmountI paymentType, navigation, transactionsStatusMutation, + handlePaymentUsingBrowser, ]); return ( -- libgit2 0.27.1