#ruslan_checkout-urls
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1247574348559028324
๐ Have more to share? Add details, code, screenshots, videos, etc. below.
Hi there ๐ I'm not sure I understand the question. If you're using the {CHECKOUT_SESSION_ID} syntax, then we will replace that placeholder with the ID of the Checkout Session when your customer is directed to your success or return URL. You don't provide a value there, but rather you read the value we provide.
Yes, but now within test function it should work the same way. Unfortunately it doesn''t.
I mean it doesn't pull values from Stripe API to my project peace of code as it did when I ran main code
Main code - I mean code of my project where I really use API key and hit Stripe API
no test function code
I'm going to need more context about what you're seeing. Are you logging the query params you're receiving when your success or cancel URL is hit after completing the checkout flow?
allow me awhile please - I will print query params in code snippet
fjnvdkjfnvkru
ruslan_checkout-urls
let's say it a result of logging session id
point is that is not pulled to the placeholders
aka - CHECKOUT_SESSION_ID
Can you share an example Checkout Session id for me to look at?
fjnvdkjfnvkru
it is just for testing purposes within my test function
it is not even real id
as you can see it shorter and not descriptive
I need a real Checkout Session id. The cs_test_123
cs_test_a1LBolVglTJgnDkEujmpUT6p3a1ejJHccNYYeRJVh70Pe1O66HuKees2sw
okay so I confirmed that your code passed {CHECKOUT_SESSION_ID} properly. So what exactly is the issue? What do you see in the browser's URL bar after the redirect?
point is that every time I try to do the same inside my test function it shows mistake aka - URL is not valid
I don't know what those words mean unfortunately
What exact error do you get with what exact parameters and which exact request id req_12345 so I can help you
raise err
stripe._error.InvalidRequestError: Request req_SLW2Yv8SxsWna9: Not a valid URL
You can see error message
Look at the API Request though: https://dashboard.stripe.com/test/logs/req_SLW2Yv8SxsWna9 you can see immediately that your success_url is not a real URL
I turn back to my initial question - CHECKOUT_SESSION_ID - this one is not pulled inside code where I am trying to create Session object
yeah sorry this still doesn't make any sense to me, I don't know what you are asking.
This is a "placeholder". It's in your URL so that we (Stripe) can replace it with the real Checkout Session id when we redirect the customer.
I apologize but how can I put together this parts of logic
Allow me this
- Initially defined placeholders in create sessin method
- Create a real session inside my test function
on step 2 I need to pass real session id
which I subsequently pass to certain payment
payment_user = sample_payment(
borrowing=self.borrowing_1,
session_url=session.url,
session_id=session.id,
money_to_pay=self.borrowing_1.book.daily_fee
)
but prior to it I create a session itself
session = stripe.checkout.Session.create(
line_items=[
{
"price": price_data.id,
"quantity": 1,
}
],
mode="payment",
success_url=SUCCESS_URL + "?session_id={CHECKOUT_SESSION_ID}",
cancel_url=CANCEL_URL + "?session_id={CHECKOUT_SESSION_ID}"
)
so, where can I get a relevant session id
let's say so
my point is (and I want to clearly expound it to you) that on the step I am creating a real session, placeholder should be automatically replaced with real value
otherwise it won't work
you create a Checkout Session, you get a response from our API in the session variable. That is an entire Checkout Session resource, you can do session.id and see the Checkout Session id
It reminds me cyclic dependency - I can't create real session without success_url parameter which consist of checkout_session_id. But every time I try to create session itself with placeholders (there is no session_id yet because session is not yet created) it can't pull session_id because session is not created
paradox
yeah you seem to really misunderstand the whole thing
How can I put real id inside PLaceholder in case when I just have no one - session is not created
I do
It is a placeholder. You do nothing other than what you do already.
So, it is real trap
because app doesn't pull value to placeholder place
automatically
- Create a Checkout Session
- Go the the URL
- Click on the back arrow in the top left corner
- Notice the
cs_test_123is in the URL automatically which is exactly what you want
I don't undestad point
Please do step 1 and 2 and then share a screenshot of what you see
In this case you don't understand me - I have n access to browser - I run tests in terminal window
point 1
I can't even see URL bar
Okay step 1 you create a Checkout Session.
Then print session.url or look at the URL property. That's the URL that you would send your customer to in a browser. Can you please share that exact URL that you see in our API response?
Every time I try to create it complaint to URL parameter inside creation method
Request req_SLW2Yv8SxsWna9: Not a valid URL
Session couldn't be created
But I already explained this today before.
that is initial point of the whole discussion
You are not passing a valid URL. You never passed https:// in your URL you passed a fake/bad value
You are a developer. You are writing the code. You control exactly what to pass
https://dashboard.stripe.com/test/logs/req_SLW2Yv8SxsWna9 this was your request. You passed success_url: "/api/payments/payment_success/?session_id={CHECKOUT_SESSION_ID}"
You can see how this is not a valid URL right?
OK, in case of real workflow how is it works
we don't need to manually put value in placeholders, do we?
It is pulled automatically on this place
yes
so, in my case why not?
But please, you're still lost, so please try to do exactly what I said
@spiral tartan have you created that Checkout Session now?