#mindfulrecruitai
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.
- adomarc-django-checkout, 59 minutes ago, 32 messages
Do you have any error on console? Or you can try to put some debug log in first to see where did it run through
Yes I do have console messages but I don't know if they are related.
Request to access cookie or storage on “https://js.stripe.com/v3/” was blocked because it came from a tracker and content blocking is enabled.
You may test your Stripe.js integration over HTTP. However, live Stripe.js integrations must use HTTPS. v3:1:432439
Loading failed for the <script> with source “http://127.0.0.1:8000/subscribe/dashboard.js”. basic:340:221
Request to access cookie or storage on “<URL>” was blocked because it came from a tracker and content blocking is enabled. 2
Partitioned cookie or storage access was provided to “https://m.stripe.network/inner.html#url=http%3A%2F%2F127.0.0.1%3A8000%2Fsubscribe%2Fbasic&title=Mindful Recruit&referrer=http%3A%2F%2F127.0.0.1%3A8000%2Fsubscribe%2F&muid=695b6c10-6f66-4015-96e2-a6ed91133cf81eebef&sid=d678d9d7-2951-4125-a39c-3c2431cdd02d67318b&version=6&preview=false” because it is loaded in the third-party context and dynamic state partitioning is enabled.
A resource is blocked by OpaqueResponseBlocking, please check browser console for details. 2 csp-report
Request to access cookie or storage on “<URL>” was blocked because it came from a tracker and content blocking is enabled. 3
A resource is blocked by OpaqueResponseBlocking, please check browser console for details. csp-report
A resource is blocked by OpaqueResponseBlocking, please check browser console for details. 2 csp-report
I have logger.debug statements as you can see in the code I attached. I get the printout "Retrieved tier: basic" so I'm at least getting that far
Sorry that seem unrelated. You would want to debug on your Django code a litte bit, break it down steps by steps
Did it return your client a client_secret?
yes. I see it in the terminal printout.
{'sessionId': 'cs_test_a11zjJVZtOGcHz6FdctCgyWYxyXzTPuG0KlrhVGUcaJbQClbHjOXF2ajPD', 'clientSecret': 'cs_test_a11zjJVZtOGcHz6FdctCgyWYxyXzTPuG0KlrhVGUcaJbQClbHjOXF2ajPD_secret_fid2cGd2ZndsdXFsamtQa2x0cGBrYHZ2QGtkZ2lgYSc%2FcXdwYCkncGxIamFgJz8nYGhnYGFhYGEnKSdpZHxqcHFRfHVgJz8ndmxrYmlgWmxxYGgnKSd3YGFsd2BmcUprRmpodWlgcWxqayc%2FJ2RpcmR8dicpJ2dkZm5id2pwa2FGamlqdyc%2FJyZjY2NjY2MneCUl', 'STRIPE_PUBLIC_KEY': 'pk_test_51OcD0zHih0ZoNuRgAMsyrXZvdarUgjgDX06UBk45LqnDr6Lqi7v4VCYah7kx6BkZes0DduyKS7bOWUjzM3VepywQ00imLXIqIW ', 'tier_name': 'basic'}
Alright, how the frontend intialized it?
There's some javascript in the html. Let me see if I can attach it. I think there may be an issue in the fetch url.
<!-- payments/templates/create_subscription.html -->
{% extends "appbase.html" %}
{% block content %}
<h2>Subscribe to {{ tier.name }}</h2>
<head>
<script src="https://js.stripe.com/v3/"></script>
</head>
<body>
<div id="checkout">
<!-- Checkout will insert the payment form here -->
</div>
</body>
<script>
// Get CSRF token from cookies
function getCookie(name) {
let cookieValue = null;
if (document.cookie && document.cookie !== '') {
const cookies = document.cookie.split(';');
for (let i = 0; i < cookies.length; i++) {
const cookie = cookies[i].trim();
if (cookie.substring(0, name.length + 1) === (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
const csrftoken = getCookie('csrftoken');
</script>
<script>
// This is your test publishable API key.
const stripe = Stripe('{{ STRIPE_PUBLIC_KEY }}');
initialize();
// Create a Checkout Session as soon as the page loads
async function initialize() {
const response = await fetch("/subscribe/", {
method: "POST",
headers: {
"X-CSRFToken": csrftoken,
"Content-Type": "application/json",
},
});
const { clientSecret } = await response.json();
const checkout = await stripe.initEmbeddedCheckout({
clientSecret,
});
// Mount Checkout
checkout.mount('#checkout');
}
</script>
{% endblock %}
payments/urls.py
from django.urls import path
from . import views
urlpatterns = [
path('subscribe/', views.list_tiers, name='list_tiers'),
path('subscribe/slug:tier_name', views.create_subscription, name='create_subscription'),
path('update_subscription/', views.update_subscription, name='update_subscription'),
path('cancel_subscription/', views.cancel_subscription, name='cancel_subscription'),
path('webhooks/stripe/', views.stripe_webhook, name='stripe_webhook'),
path('session_status/', views.session_status, name='session_status'),
]
sounds good
Did you have the checkout object after
const checkout = await stripe.initEmbeddedCheckout({
clientSecret,
});
if you console.log(checkout) here does it show you an object
I placed console.log(checkout) right after that line and I don't see it printed out in the console
I suspect this is the problematic part of the code
const response = await fetch("/subscribe/", {
method: "POST",
headers: {
"X-CSRFToken": csrftoken,
"Content-Type": "application/json",
},
});
If you console.log(response) do you see anything
no
I did console.log("initialize started") after the async function initialize() { line of code and I see that echoed back in the console
I tried console.log(clientSecret) but I do not see anything in the console
Alright, open the chrome console network tab and see the request to your backend
you can also check your django app log to see if any request coming in
Okay I'm using Mozilla. I'm on the network tab. I see NS_ERROR_FAILURE
method POST
domain q.stripe.com
file csp-report
Is there something I can provide back that will help with the debugging?
I see GET
http://127.0.0.1:8000/subscribe/basic
Is that what you are referring to?
sorry I'm not super knowledgeable on this
In my urls.py file my path is set up to include the tier name in the url:
path('subscribe/<slug:tier_name>', views.create_subscription, name='create_subscription'),
but javascript has:
const response = await fetch("/subscribe/", {
not sure if this is the problem
when I try const response = await fetch("/subscribe/"+tier_name, {
I get a traceback error:
ValueError: The view app.utility._wrapped_view didn't return an HttpResponse object. It returned None instead.
Alright that's where you django hasn't working to response to any request
you want to figure that out first, it's a server-client issue, before reaching the place of Stripe APIs
I would suggest debug until you got one simple POST request working, ie POST http://127.0.0.1:8000/helloworld
all my other urls seem to work okay
console.log('{{tier_name}}')
const response = await fetch("/subscribe/"+'{{tier_name}}', {
method: "POST",
headers: {
"X-CSRFToken": csrftoken,
"Content-Type": "application/json",
},
});
console.log("after fetch")
I see console respond with the correct tier_name and "after fetch" message
yes but the request is important. It need to get back to you the proper response
Is there any additional debugging I can do?
I see this in terminal too
[05/Feb/2024 21:33:19] "POST /subscribe/regular HTTP/1.1" 500 67625
ValueError: The view app.utility._wrapped_view didn't return an HttpResponse object. It returned None instead.
That's 500 error from your server
You want to debug why a POST to /subscribe/regular returns 500, by adding some log on your Django app
You want to add some log to your Django app, or researching around the error you got there
The view app.utility._wrapped_view didn't return an HttpResponse object. It returned None instead
any plans to add a django example to this page? that would really spare a huge headache.
https://stripe.com/docs/checkout/embedded/quickstart?lang=python
I hear you, will forward your feedback
return render(request, 'create_subscription.html', context)
I think around this part, you would want to not return a template, but return a json instead
Something like this https://stackoverflow.com/a/2428119/3631795