我一直在使用https://stripe.com/docs/payments/checkout/migrating-prices#server-side-code-for-inline-items和https://stripe.com/docs/payments/checkout/accept -a-payment以及其他指南/SO 帖子作為指南。payments.html 頁面中的結(jié)帳按鈕不起作用;頁面上沒有任何反應。在 Flask 的 /payment 函數(shù)中,我已經(jīng)能夠打印出 session/session.id 了。我試過將會話和 session.id 傳遞給 payments.html 頁面,但都沒有用。payments.html 上的 {{price}} 工作正常。為了使結(jié)帳頁面正常工作,我在這里忽略/弄亂了什么?基礎(chǔ).html<!DOCTYPE html><html> <head> <title>Stripe Checkout</title> <link rel="stylesheet" href="{{ url_for('static', filename='main.css') }}"> <link rel="stylesheet" href="{{ url_for('static', filename='bootstrap.min.css') }}"> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <meta name="mobile-web-app-capable" content="yes"> <meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=no"> </head> <body> <div class="container"> {% block content %} {% endblock %} </div> {% block scripts %} {% endblock %} </body></html>付款.html{% extends "base.html" %}{% block content %} <div> <h1>Cost</h1> <h2>Pay ${{price}}</h2> <button type="button" class="btn btn-primary" id="checkout">Pay with Card</button> <button type="button" class="btn btn-primary" id="back">Back</button> </div> <div id="status"> <br> <div class="alert alert-primary" id="alert" role="alert"></div> </div>{% endblock %}{% block scripts %} <script src="https://js.stripe.com/v3"></script> <script> var stripe = Stripe('pk_test_...'); var checkoutButton = document.querySelector('#checkout'); checkoutButton.addEventListener('click', function () { stripe.redirectToCheckout({ sessionId: {{sessionID}} }); }); </script>{% endblock %}
Flask Stripe Checkout 動態(tài)價格 SessionID 錯誤
臨摹微笑
2023-01-06 16:18:11