From 160e6da3f66691580752c65063e93c038b7a5547 Mon Sep 17 00:00:00 2001 From: ppanel-web Date: Fri, 6 Feb 2026 07:06:16 +0000 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20fix(payment):=20use=20native=20W?= =?UTF-8?q?eChat=20Pay=20QR=20data?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../user/src/sections/user/payment/stripe.tsx | 50 +++++++++++++------ 1 file changed, 34 insertions(+), 16 deletions(-) diff --git a/apps/user/src/sections/user/payment/stripe.tsx b/apps/user/src/sections/user/payment/stripe.tsx index 90a2d58..248b632 100644 --- a/apps/user/src/sections/user/payment/stripe.tsx +++ b/apps/user/src/sections/user/payment/stripe.tsx @@ -276,6 +276,7 @@ const CheckoutForm: React.FC> = ({ const stripe = useStripe(); const [errorMessage, setErrorMessage] = useState(null); const [qrCodeUrl, setQrCodeUrl] = useState(null); + const [qrCodeImageDataUrl, setQrCodeImageDataUrl] = useState(null); const [isSubmitted, setIsSubmitted] = useState(false); const { t } = useTranslation("payment"); const qrCodeMap: Record = { @@ -328,12 +329,21 @@ const CheckoutForm: React.FC> = ({ if (paymentIntent?.status === "requires_action") { const nextAction = paymentIntent.next_action as any; - const qrUrl = - method === "alipay" - ? nextAction?.alipay_handle_redirect?.url - : nextAction?.wechat_pay_display_qr_code?.image_url_svg; + // Stripe returns multiple WeChat QR-related fields. + // For native WeChat pay experience we should prefer the protocol data (weixin://...). + // Fallback to the provided base64 image if present. + if (method === "alipay") { + const qrUrl = nextAction?.alipay_handle_redirect?.url; + setQrCodeUrl(qrUrl || null); + setQrCodeImageDataUrl(null); + } else { + const wechat = nextAction?.wechat_pay_display_qr_code; + const data = wechat?.data; // e.g. weixin://wxpay/bizpayurl?pr=... + const imageDataUrl = wechat?.image_data_url; // data:image/png;base64,... - setQrCodeUrl(qrUrl || null); + setQrCodeUrl(data || null); + setQrCodeImageDataUrl(!data ? imageDataUrl || null : null); + } } } catch (_error) { handleError(t("stripe.error", "An error occurred")); @@ -348,18 +358,26 @@ const CheckoutForm: React.FC> = ({
- ) : qrCodeUrl ? ( + ) : qrCodeUrl || qrCodeImageDataUrl ? ( <> - + {qrCodeImageDataUrl ? ( + {qrCodeMap[method] + ) : ( + + )}

{qrCodeMap[method] || t(`qrcode.${method}`, `Scan with ${method}`)}