简体   繁体   English

谷歌支付选项没有出现

[英]Google pay option is not coming in stripe

backend后端

    @app.route('/create-payment-intent', methods=['POST'])
    def create_payment():
        try:
            data = json.loads(request.data)
            # Create a PaymentIntent with the order amount and currency
            intent = stripe.PaymentIntent.create(
                amount=calculate_order_amount(data['items']),
                currency='usd',
                automatic_payment_methods={
                    'enabled': True,
                },
            )
            return jsonify({
                'clientSecret': intent['client_secret']
            })
        except Exception as e:
            return jsonify(error=str(e)), 403

frontend前端

    export default function App() {
    const [clientSecret, setClientSecret] = useState("");

    useEffect(() => {
        // Create PaymentIntent as soon as the page loads
        fetch("/create-payment-intent", {
        method: "POST",
        headers: { "Content-Type": "application/json" },
        body: JSON.stringify({ items: [{ id: "xl-tshirt" }] }),
        })
        .then((res) => res.json())
        .then((data) => setClientSecret(data.clientSecret));
    }, []);

    const appearance = {
        theme: "stripe",
    };
    const options = {
        clientSecret,
        appearance,
    };

    return (
        <div className="App">
        {clientSecret && (
            <Elements options={options} stripe={stripePromise}>
            <CheckoutForm />
            </Elements>
        )}
        </div>
    );
    }

here is my stripe code where i am expecting google pay to come but it is not coming in my localhost.这是我的条码代码,我期待谷歌支付来但它不在我的本地主机上。 I am using live stripe acccount for testing.我正在使用实时条纹帐户进行测试。 Is google pay btn not coming because of localhost?谷歌支付 btn 不会因为本地主机而出现吗?

Please check the screenshot how it is coming.请检查截图它是怎么来的。 在此处输入图像描述

Not sure what this mean in there doc不确定这在文档中意味着什么在此处输入图像描述

Google Pay with Payment Element has the same prerequisites as Stripe's Payment Request Button integration.带有支付元素的 Google Pay 与 Stripe 的支付请求按钮集成具有相同的先决条件。 In their documentation they specify that your application has to be served over HTTPS, which your integration isn't currently doing.在他们的文档中,他们指定您的应用程序必须通过 HTTPS 提供服务,而您的集成目前并未这样做。 You can use something like ngrok to serve your application over HTTPS and verify that Google Pay shows up.您可以使用 ngrok 之类的东西通过 HTTPS 为您的应用程序提供服务,并验证 Google Pay 是否显示。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM