*English is not my mother language,so if my English is not correct,please ignore.
At Local, Stripe has worked well on Django. But after deploying Heroku, Stripe(subscription Service) doesn't work. When I click "Pay",everytime showed " Internet Error 500".I checked Heroku logs,but connect and service looks like okay.
I've tried deployed again and again, but everytime the results are same. Showing "Internet Error 500".
This is logs by Heroku logs --tail
2024-03-19T08:03:27.576123+00:00 heroku[router]: at=info method=POST path="/checkout/" host=nagoyameshi-marina-32890ff7fdd2.herokuapp.com request_id=40d9d9e5-8ebf-436f-9254-2e862dcada7e fwd="126.15.11.7" dyno=web.1 connect=2ms service=19ms status=500 bytes=459 protocol=https
2024-03-19T08:03:27.576163+00:00 app[web.1]: 10.1.20.255 - - [19/Mar/2024:17:03:27 +0900] "POST /checkout/ HTTP/1.1" 500 145 "https://nagoyameshi-marina-32890ff7fdd2.herokuapp.com/terms_of_service/" "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36"
These are my settings.py and CheckoutView from views.py I deployed on Heroku.
if "STRIPE_PUBLISHABLE_KEY" in os.environ and "STRIPE_API_KEY" in os.environ and "STRIPE_PRICE_ID" in os.environ:
STRIPE_PUBLISHABLE_KEY = os.environ["STRIPE_PUBLISHABLE_KEY"]
STRIPE_API_KEY = os.environ["STRIPE_API_KEY"]
STRIPE_PRICE_ID = os.environ["STRIPE_PRICE_ID"]
- CheckoutView
stripe.api_key = settings.STRIPE_API_KEY
class CheckoutView(LoginRequiredMixin,View):
def post(self, request, *args, **kwargs):
checkout_session =stripe.checkout.Session.create(
line_items=[
{
'price':settings.STRIPE_PRICE_ID,
'quantity':1,
},
],
payment_method_types=['card'],
mode='subscription',
success_url=request.build_absolute_uri(reverse_lazy("nagoyameshi:success")) + '?session_id={CHECKOUT_SESSION_ID}',
cancel_url=request.build_absolute_uri(reverse_lazy("nagoyameshi:index")),
)
print( checkout_session["id"] )
return redirect(checkout_session.url)
checkout = CheckoutView.as_view()
DB is " Heroku Postgres".