我一直在使用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 页面中的结帐按钮不起作用;页面上没有任何反应。在 Flask 的 /payment 函数中,我已经能够打印出 session/session.id 了。我试过将会话和 session.id 传递给 payments.html 页面,但都没有用。payments.html 上的 {{price}} 工作正常。为了使结帐页面正常工作,我在这里忽略/弄乱了什么?基础.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 %}
添加回答
举报
0/150
提交
取消