#vell2x
1 messages ยท Page 1 of 1 (latest)
Hi there ๐ can you tell me more about how you're trying to interact with our API? How are you trying to make the request to create a Checkout Session?
the flow is App(C#) -> Server(node js) -> Stripe
I am using the pre-checkout implementation. So there is a page with a buy button that contains the JS script. When you select buy it sends a post and redirect the user to the pre-checkout page where the actual payment happens
Alright, so are you trying to create the Checkout Sessions from the server side code?
Or were you referring to app-side Javascript for that?
Yes I want the server to handle the payment to ensure it is PCI compliant.
Can you tell me how your server is currently trying to create those Checkout Sessions, or am I wrong in assuming you're trying to leverage Checkout Sessions for your integration?
You mentioned you're trying to do this from your Node server, are you using our Node library to help simplify that process?
I am using your implementation so I may have some of the low level details wrong but from my understanding. I send the user to the precheckout webpage that has all of the css and js. From there you click but which sends a post request to '/create-checkout-session'
// Create new Checkout Session for the order
// Other optional params include:
// For full details see https://stripe.com/docs/api/checkout/sessions/create
const session = await stripe.checkout.sessions.create({
mode: 'payment',
line_items: [{
price: priceid,
quantity: 1,
}],
//?session_id={CHECKOUT_SESSION_ID} means the redirect will have the session ID set as a query param
success_url: ${domainURL}/success.html?session_id={CHECKOUT_SESSION_ID},
cancel_url: ${domainURL}/canceled.html,
automatic_tax: { enabled: true }
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thats what is inside the function
Gotcha, so I think you're following our guide, where /create-checkout-session is an endpoint on your server, that executes the server-side portion of the process which in this case is creating a Checkout Session. Does that sound right?
If so, is the request to create the Checkout Session completing successfully, or are you seeing an error?
If it is completing successfully, where are you seeing HTML being returned? Is that from our API, or is that the response your server is sending to your app?
Yes. I don't see any errors but since I cant consume HTML in the app(being sent as a response). I need a way to send the data then get it afterwards I guess
Sorry, I still don't understand where the HTML is coming from, so I don't know what to suggest changing. Our API responds with JSON data, so I would be surprised if it is providing you with an HTML response instead.
Is the HTML what is being returned to your application from your server? If so, what is your endpoint currently returning from its function?
When you create a Checkout Session via our API, the resulting Checkout Session object should have a url value that contains the URL of the session. Is that what you're returning to your app?
https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-url
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Are you following that guide exactly? It has the server respond with a redirect taking the browser directly to the URL rather than responding with the URL as data.
res.redirect(303, session.url);
My issue is before checkout is triggered. there is a '/' endpoint where the css and JS is housed. I am trying to send price_id to that page so when the post form is sent price_id will be included as the price to be paid.
When I post there I recieve HTML code and not a link I can use on the app end
What is that endpoint, and what is it trying to do?
Quick side question. When I create a checkout session does it expire after a few minutes or days?
that end point is the 'checkout.html' that was in the pre-checkout link I sent
By default they expire after 24 hours, but that is controlled via the expires_at parameter and can be set from 30 minutes to 24 hours:
https://stripe.com/docs/api/checkout/sessions/create?lang=curl#create_checkout_session-expires_at
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Sorry, made that a reply to the wrong message.
Can you elaborate on this? If you're making a request to an HTML resource, I believe it is expected for it to respond by providing its HTML content.
Maybe I am approaching it the wrong way
Taking a step back, I think the approach I would recommend trying is:
- Have your app make a request to an endpoint on your server
- Have that server endpoint create a Checkout Session
- Have your server respond to the request from your app with the URL as the payload
- Redirect your customer to the provided URL
I'm not too familiar with this type of approach on Android, so I'm not certain how smoothly it will go but think it is a good starting point.
Would that payload be able to store my price id?
You would design the structure of the endpoint on your server, so you can control what details your server accepts in the payloads for that endpoint.
Ok. Thank you I will try that