#riptired
1 messages · Page 1 of 1 (latest)
Hi there, so you want to retrieve the chekcout session's line_items (https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-line_items) programmatically?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Hey Jack
So I am using stripe elements
I need my checkout to be 2 staged (stage 1 is get shipping address from the customer, and then stage 2 is show sales tax + shipping + product price and display the element that collects payment info)
When they finally complete checkout on the second stage, I would like the breakdown of sales tax, product price, shipping, etc to be available in the sales receipt so that I can sync it to quick books
Are you using PaymentIntents API or Invoicing APIs?
Payment Intents API
The customer is paying immediately on the checkout page so I don't need to send them an invoice (think like ecommerce buying a t-shirt)
The PaymentIntent doesn't carry information about tax, price or shipping.
So in order to have this work do I need to switch to the invoicing api?
and does the invoicing api work for my use case?
Yes you can use Invoicing API, but the easier way is just to use Checkout Session.
Is checkout session different from Stripe Checkout?
Stripe Checkout = Checkout Sessionl
so I can't host checkout on my domain and have line items?
You can host Checkout in your domain https://stripe.com/docs/payments/checkout/custom-domains
Okay great
Additionally, would this work with a 3rd party sales tax api?
And in stripe checkout is it fine if sales tax and shipping costs are unavailable until shipping address is provided
@azure venture
Not directly, You need to create the tax_rate based on the info from your 3rd-party tax API, and pass in when creating a checkout session. https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-tax_rates
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Personally I'd recommend you using Stripe Tax https://stripe.com/docs/tax
So I would need to collect shipping address and tax info prior to initiating the checkout session
how does stripe tax interface with stripe checkout?
Stripe Tax will automatically calculate the tax based on customer's address and various data (https://stripe.com/docs/tax/supported-use-cases)
If I want to stick with a third party api for sales tax integration but still have line items on my sales receipt I would be able to do that with stripe checkout correct?
and I would need to collect shipping address and tax info from the 3rd party api before initiating a stripe checkout session correct?
Yes you can do that as well.
Yes to both?
Yes to both
Okay, and then for shipping basically I would need to use my own elements for that since checkout is different from using payment intents?
You can use Checkout Session to collect it as well.
Checkout Session is the page view that you see in the docs right?
I don't see a shipping field available there
You can enable shipping address collection through this param https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-shipping_address_collection
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
okay so a checkout session would still enable me to collect shipping address, wait for sales tax to be calculated and then proceed with completing the checkout?
If you want to calculate tax based on the address that your customer enters during checkout, you need to use Stripe Tax. https://stripe.com/docs/tax/checkout
Okay so if I want to use a 3rd party API to get sales tax I have to collect shipping address before the checkout session?
and if I want to collect shipping address within the checkout session I need to use Stripe Tax
is that correct?
You are right. It's just that without Stripe Tax, you need to create the tax rate by yourself.
yeah I have an API that calculates the tax price
Okay so in sum: if I am using a 3rd party sales tax, I need to get shipping before the session but I can pass these line items in and they will be shown on the sales receipt
Regarding line items though, can I set any number of line items for the sales receipt?
If you are calculating the tax rate by yourself, address is not mandatory.
i.e. if I have a transaction fee I can show that as a line item as well?
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items you can add up to 100 line items in payment mode
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
and finally can metadata be passed through to a checkout session?
so that when a checkout session is completed that I can pass some data with that success event to a webhook
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata yes you can attach a metadata to a checkout session, and you can listen to checkout.session.completed webhook to get the metadata from the checkout session object.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
One more question @azure venture
If I need to dynamically fetch shipping price based on the shipping address provided in stripe checkout is that possible?
or does stripe checkout need to be initialized with the shipping price
(assuming I use stripe tax)
@azure venture
You mean retrieve the shipping address (https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-shipping_details-address) from a completed checkout session?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
No
so if I use stripe checkout (with stripe tax) I can have a user give us their shipping address inside the checkout session right
but I need to calculate shipping price based on the shipping address
via an API
is that possible?
or in order to do this I would need to do what we discussed before and host the shipping address fields outside of the checkout session, get the shipping cost and then initialize stripe checkout
You mean an API to get the shipping address that the user is entering to a checkout session? No I'm afraid there's no such API available.
No
Let me give you an example
User A lands on a product page for "Nike pegasus 32" and wants to buy the item. User A clicks buy now which starts a stripe checkout session
you mentioned earlier that I can ask User A for their shipping address within the stripe checkout session
if I need to query an external non stripe API to get the shipping cost based on the address, can I do that from the stripe checkout session?
that way User A can start the checkout session, enter their shipping address, see the sales tax based on shipping address and shipping cost based on address, and then provide their payment information and complete the checkout
No, you can't query an ongoing checkout session.
I don't need to query the session
I need to make a request to my own api to get a shipping quote for the ongoing checkout session
Would it be possible to pipe in a shipping price in an ongoing checkout session
Nope.
Is it possible with an "embedded" stripe checkout to expose the shipping address entered by the user in the stripe checkout page to an API
No, there's no such API or option
No I understand there is not an API
but if I have an API can I access that API from the embedded checkout
No, there's no way to tell a Checkout page to call an external API during a checkout flow.
Can I pull the shipping address out of the checkout page by something like document.getElementById and then pipe in a shipping price?
No.
Is it possible for you to give me access to stripe embedded checkout?
see image above for reference
What do you mean by access to stripe embedded checkout ?
There is a beta feature called stripe embedded checkout
I would like access to it
🤲
There's a contact us link in the page, you can click on that to request for beta access.
Okay thanks
Okay sure
But my concern is that this seems like a very common flow
shipping costs are not always flat across all addresses
so it seems absurd that I have to do this all externally / there is no way to access a shipping cost calculator
@halcyon ledge thoughts?
You are right, that's the limitation of checkout session at this moment. I'd pass along your feedback to the checkout team.
However I can use stripe.checkout.session object from the API independently of actually using the product Stripe Checkout right?
so that would enable me to add line items to a checkout object but still use stripe elements?
You still need a paymentIntent secret to render stripe elements, and Stripe checkout session only generate a paymentIntent after it's completed.
okay so there is no way for me to use the stripe checkout session object with stripe elements
Taking over here, and yep that's correct
Okay thanks
I want to follow up on this
I need to retrieve the shipping information from Stripe Checkout to dynamically calculate shipping and tax. How can I do this
Is there any way to do this with stripe checkout?
You mean retrieving after the Checkout has been paid?
No
I mean that after a user gives me their shipping address in a checkout session, that I can calculate shipping cost and present it to them
That means you would need to catch the information after the Session is already presented to the customer. That's not possible unfortunately
You can predefine some shipping options btw https://stripe.com/docs/payments/checkout/shipping
Okay so I have to calculate shipping before entering a stripe checkout session
Additionally if I wanted to use a tax calculator other than stripe tax, I would also need to calculate that beforehand
Finally, last questions: for Stripe customers that need a line item break down in quickbooks of their sales receipts, is stripe checkout the most common solution? And is there a built in way for me to post these sales receipts from stripe to QBO or do I have to use some kind of 3rd party connector
@thorny junco
appreciate your help here
Hmm I don't have that much context of your usecase, but generally yes Checkout has line items break down other than a pure PaymentIntent approach like Elements
By other than a pure approach what do you mean by that
We are currently using payment intent but were told that line items are not available for that
Yep, the exactly same thing. Checkout Session gives you the line_items array
Sorry
To be clear line items are NOT available for a payment intent / elements approach correct?
Yep
Okay appreciate it
thanks
For the line items in the stripe checkout session, are any of the fields optional?
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items here you will see price or price_data is required, and quantity is conditionally required
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
others are optional
Regarding line items in stripe checkout, if I add my own sales tax and my own shipping cost, where will they show up?
will they show up here in the highlighted section as my own line items?
That highlight is only for when you use the shipping options as above Doc. If you include yourself it will show above as a normal item
okay so there is no way for me to provide my own shipping cost as a line item in the total?
and not split out as a "product"
no way to provide your own shipping cost as a separated/highlight item yes. But you can name it properly and attract the customer attention
So it would have to show up in the product section
i.e. the section with the images shown above
Yep
ok thanks
so to be absolutely sure -- I cannot add shipping under or above tax in this session?
@thorny junco
Yes. It would line up with the "product 1" there
Okay so this cannot be done?
where shipping is under subtotal?
Additionally can I initialize a stripe checkout session with a shipping cost and a shipping address so that when the user lands on the stripe checkout session the page looks like this?
Yep
Okay so this is possible
Where shipping and tax show up underneath sub total, and then shipping address is filled out if the session is initialized with these values
@thorny junco
Sorry don't really follow if that's a question
Okay so this is the question
Can I initialize a stripe checkout session with a shipping address, sales tax, and shipping cost?
like shown in the photo above (i.e. I start a stripe checkout session and the user sees this session with their own shipping address pre populated)
Yes, *if you follow *the guide in this Doc: https://stripe.com/docs/payments/checkout/shipping
Yes I understand that you can add shipping
what I asked is if you can INITIALIZE a checkout session with a shipping address
so that the shipping address is prefilled in the checkout session
I just tried, and yes it's possible if you create a Customer beforehand, prefill their shipping address information, then supply the Customer Id into Checkout Session