#theofficeismypersonality
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- jacb-products-markinactive, 14 hours ago, 7 messages
hello! I assume you're using Checkout Sessions and want to redirect the customer to the Stripe hosted Checkout page?
i don't think that's related, but you can try out whatever you think is the solution first
You have two options to redirect to a Checkout Session URL:
- Return the Checkout Session's url from your backend, and then on the frontend update the window.location
- Or do a <form action="xxx" method="POST"> on the frontend and the backend can do a redirect directly
through flask when I load request.json it says 415 Unsupported Media Type: Did not attempt to load JSON data because the request Content-Type was not 'application/json'.
@app.route('/create-checkout-session', methods=['POST'])
def create_checkout_session():
try:
print(request.json)
print(request.json)
product = request.get_json(force=True)['product']
quantity = request.get_json(force=True)['quantity']
price = 'price_1OimLhKonneQF4Y3489xrTck'
# create checkout session object
client_session = stripe.checkout.Session.create(
ui_mode = 'embedded',
line_items=[
{
'price': price,
'quantity': 1
},
],```
oh, you're using embedded Checkout Session
so it has nothing to do with the redirect right?
in line items I tried to pass in the product variable but it doesn't work
however when I pass it in explicitly it does
Since you mentioned when I load request.json it says 415 Unsupported Media Type: Did not attempt to load JSON data because the request Content-Type was not 'application/json'. , you'll want to resolve that first. I'm guessing that because of this issue, if you try to print product, you likely won't get any usable value
We dont think thats no longer the problem, when I run checkout.html independently it works because all the request values are null, and when I run it through something else it doesn't
yes we think it doesn't anymore
Hey! Taking over for my colleague.
May I inivte you to download first this quickstart with Python and Stripe Checkout:
https://stripe.com/docs/checkout/quickstart?client=html&lang=python