【发布时间】:2020-08-02 17:08:13
【问题描述】:
我正在开发一个 django 书店网站,但条带集成似乎存在错误。我有一个要求支付信息的订单页面(我现在正在使用测试 API)。我收到同样的错误“您没有设置有效的可发布密钥。使用您的可发布密钥调用 Stripe.setPublishableKey()。”
orders/views.py
from django.conf import settings
from django.views.generic.base import TemplateView
class OrdersPageView(TemplateView):
template_name = 'orders/purchase.html'
def get_context_data(self, **kwargs):
##Stripe.setPublishableKey('PUBLISHABLE_KEY')
context = super().get_context_data(**kwargs)
context['stripe_key'] = settings.STRIPE_TEST_PUBLISHABLE_KEY
return context
模板/订单/purchase.html
{% extends '_base.html' %}
{% block title %}Orders{% endblock title %}
{% block content %}
<h1>Orders page</h1>
<p>Buy for $39.00</p>
<script src="https://checkout.stripe.com/checkout.js" class="stripe-button"
data-key="{{ stripe_key }}"
data-description="All Books"
data-amount="3900"
data-locale="auto">
</script>
{% endblock content %}
【问题讨论】:
标签: python django stripe-payments