From 23a83c2b4d252cabf49a9d8ee6ced360fefcab24 Mon Sep 17 00:00:00 2001 From: G Date: Tue, 14 May 2024 16:47:03 +0000 Subject: [PATCH] now with real amount and paymentUrl --- src/screens/PaymentAmountInputScreen.tsx | 38 ++++++++++++++++++++++++++++++-------- 1 file changed, 30 insertions(+), 8 deletions(-) diff --git a/src/screens/PaymentAmountInputScreen.tsx b/src/screens/PaymentAmountInputScreen.tsx index e958509..e83d0a7 100644 --- a/src/screens/PaymentAmountInputScreen.tsx +++ b/src/screens/PaymentAmountInputScreen.tsx @@ -9,7 +9,8 @@ import BackgroundDefault from "@components/backgrounds/BackgroundDefault"; import Box from "@components/bases/Box"; import Text from "@components/bases/Text"; import { useMutation } from "@tanstack/react-query"; -import { useState } from "react"; +import * as WebBrowser from "expo-web-browser"; +import { useCallback, useState } from "react"; import { useSafeAreaInsets } from "react-native-safe-area-context"; const PaymentAmountInputScreen: PaymentStackScreenComponentProps<"paymentAmountInputScreen"> = ({ @@ -41,26 +42,47 @@ const PaymentAmountInputScreen: PaymentStackScreenComponentProps<"paymentAmountI }; const omPaymentMutation = useMutation({ - mutationFn: () => getTransactionsData(dummyObject), - onSuccess: (data) => { - console.log("om starter response", data); + mutationFn: (amount: number) => + getTransactionsData({ + // biome-ignore lint/style/useNamingConvention: + type_paiement: 1, + marchand: "1", + service: "1", + montant: amount, + numero: "0707070707", + commentaire: "Un commentaire", + }), + onSuccess: async (data) => { + const result = await WebBrowser.openBrowserAsync(data.payment_url); + // setResult(result); + console.log("result", result); }, onError: (err) => { console.log("om start error ", err); }, }); - const handlePaymentButton = () => { + const _handlePressButtonAsync = async () => { + console.log("openning browser ! "); + const result = await WebBrowser.openBrowserAsync( + "https://mpayment.orange-money.com/sx/mpayment/abstract/v13r49t9xznfvjxxngu31gz1ecpeenhpaethdyl4psuhzwlws64vvyixqywa8zcf", + ); + // setResult(result); + console.log("result", result); + }; + + const handlePaymentButton = useCallback(() => { switch (paymentType) { case "OM": - console.log("OM so we stays on screen"); - omPaymentMutation.mutate(); + console.log("OM so we stays on screen !!"); + console.log("Calling api with amount :: ", amountToPay); + omPaymentMutation.mutate(amountToPay); break; default: navigation.navigate("numberAndOtpForPaymentScreen"); break; } - }; + }, [amountToPay, omPaymentMutation, paymentType, navigation]); return ( -- libgit2 0.27.1