Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

101
Views
Firestore Cloud Function devuelve indefinido al cliente cuando realizo la operación de publicación de axios

Buen día, estoy tratando de procesar el pago usando Firestore Cloud Function y una pasarela de pago llamada Yoco. Mi código de pago funciona y devuelve un objeto de falla o éxito. Cuando hago logger.log, puedo ver el objeto, pero el problema es cuando intento devolver el resultado al Cliente. Me sigo sin definir. Mis métodos son asíncronos.

 CLIENT SIDE I want to response from server and update my UI const handlePay = () => { if (amount > 100) { yoco.showPopup({ amountInCents: amount, // 2 decimal places begining from left currency: "ZAR", name: "Student Angel", description: "Helping students deal with student debt", callback: function (result) { // This function returns a token that your server can use to capture a payment if (result.error) { const errorMessage = result.error.message; alert("error occured: " + errorMessage); } else { paymentMethod({ token: result.id, amount: amount }); } // In a real integration - you would now pass this chargeToken back to your // server along with the order/basket that the customer has purchased. }, }); } else { toast.error( "Due to high transaction charges, We can only process R100 and above. Thank you" ); } }; const paymentMethod = ({ token, amount }) => { const handlePayments = httpsCallable(functions, "handlePayments"); handlePayments({ token, amount }) .then((result) => { console.log(result); }) .catch((result) => { console.log(result); }); };
 THIS IS CLOUD FUNCTION exports.handlePayments = functions.https.onCall(async (data, context) => { // Using a testing key Not Production Key const SECRET_KEY = "sk_test_5ca384cdyerp8kY188a435e95fbe"; // check auth state if (!context.auth) { throw new functions.https.HttpsError( "unauthenticated", "You are not authenticated" ); } const token = data.token; const amount = data.amount; await axios // I have tried this return await axios.post but nothing .post( "https://online.yoco.com/v1/charges/", { token: token, amountInCents: amount, currency: "ZAR", }, { headers: { "X-Auth-Secret-Key": SECRET_KEY, }, } ) .then((res) => { // res.status will contain the HTTP status code // res.data will contain the response body functions.logger.log(res); return res; }) .catch((error) => { return error; }); });
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Eliminé la espera en mi llamada axios y la reemplacé con return. en mis devoluciones de llamada .then y catch en lugar de regresar

 return res

o

 return error

Accedo a la propiedad de datos de esta manera

 return res.data

También eliminó el error que estaba recibiendo en mis registros de funciones en la nube Se excedió el tamaño máximo de la pila de llamadas

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!