最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

next.js - Mercado Pago CheckoutPro, automatic redirection after PIX payment - Stack Overflow

programmeradmin3浏览0评论

I’m using Mercado Pago’s CheckoutPro in a Next.js application. Inside my app, I follow a structure similar to this one:

However, my user is not automatically redirected after making a payment with PIX. The redirection works normally for any other payment method because of the back_urls configuration when creating a payment preference:

back_urls: {
  success: `${req.headers.get("origin")}/?status=success`,
  failure: `${req.headers.get("origin")}/?status=failure`,
  pending: `${req.headers.get("origin")}/api/mercado-pago/pending`, // We created a route to handle pending payments
},

After reading more about it, I found out that PIX payments are asynchronous, so Mercado Pago cannot take action when the payment is made. I was instructed to listen to the Mercado Pago webhook to know when the payment is completed. However, I would like to automatically redirect the customer after the payment is done.

I’ve thought about techniques like polling or WebSockets, but I can't apply them since the user is on the Mercado Pago domain during the payment process. Has anyone faced something similar and knows how to handle it?

I tried implementing it using backURL, but it doesn’t trigger automatic redirection for PIX payments.

发布评论

评论列表(0)

  1. 暂无评论