#LMF-custom-quotes
1 messages ยท Page 1 of 1 (latest)
// Set your secret key. Remember to switch to your live secret key in production.
// See your keys here: https://dashboard.stripe.com/apikeys
const stripe = require('stripe')('KEY');
stripe.invoiceItems.create({
price: 'price_CBb6IXqvTLXp3f',
customer: 'cus_4fdAW5ftNQow1a',
});
This creates a fixed price/associated with product or subscription quote.
I do not want this.
Can you clarify what you mean by a "dynamic/varying" price?
The price changes.
Every quote will be different, not associated to a product or subscription. Most of examples I have seen/used so far rely on a set product or a set subscription.
stripe.invoiceItems.create({ price: '100USD', customer: 'cus_4fdAW5ftNQow1a' });
Can I do something like this?
Thanks for clarifying! Instead of passing inprice you'd want to pass in amount and currency
The...
amount seems a bit problematic.
I want to do it based on a float... unit_amount seems to want cents instead of dollar float.
amount: 100
unit_amount: 100000
Is that the difference?
Do you have a specific reason for needing a float? In your above example with 100USD1 do you want to line item to be $1.00 or for some other amount?
I am accepting a float
amount: 100.69
This would be $100, right?
that unit_amount is a scary field... charging people 100x less or 100x more
For amount: 100.69 , what is your desired behavior? Do you want to be charging them $100.69?
Yes, I think that's what happens or should happen... but seeing that unit_amount field ๐ฎ
Thank you very much for the help.
Will this invoice once created instantly email the customer?
Can I set a success/redirect URL?
Gotcha, so if you want to be charging them $100.69 then the amount you pass in would be 10069 since amount would be in cents.
no way
In the amount field?
Yes, the amount field is expecting the value to be in cents (and in other currencies whatever is the smallest unit).
We get some confusion occasionally, but personally I haven't heard any complaints.
Ty for your time
happy to help!
Ah! Totally missed that question - there isn't a concept of a success/failure redirect URL for the Hosted Invoice page.
That's a real shame, would have been a great way to intercept.
I'll figure rest out. ๐ค ty ty ty
Yeah, sorry about that!
@severe plinth is there a specific field for making sure this emails customer instantly?
this is way more complicated than I expected.
I think I need to create an invoice but also create an invoice item for it.
So starting with your first question: There isn't a specific field - typically the flow would be that if you set auto_advance: true the invoice would automatically finalize after about an hour and then the invoice would be email to your customer. If you want to send the email immediately you can do so through a separate API call (https://stripe.com/docs/api/invoices/send)
And yes, when you create an invoice through the API you first need to create an invoice item for the customer, and then create the invoice
Have you read through our invoicing docs yet? They may help https://stripe.com/docs/invoicing/integration
Yeah, this is my first Stripe integration though - it's going really well.
Stripe's Discord support method is game changing.
- typically the flow would be that if you set auto_advance: true the invoice would automatically finalize after about an hour and then the invoice would be email to your customer
This is brilliant
This shows Stripe using fibers with Meteor, working very well so far.
You can see here how I am going to check if the invoice was ever paid and update our/client's records.
So last question I believe on making this "invoice item" (custom price)
@severe plinth how do I tie the invoice item to the right invoice?
Hello! @severe plinth had to step away, but I'm happy to help! Let me get caught up...
When you create Invoice Items on a Customer the next Invoice for that Customer will sweep up all pending Invoice Items automatically.
That seems more like a limitation than a feature, what if they want separate invoices for multiple things?
What makes them think they're allowed a break?
The system is designed this way so you can add Invoice Items to a Customer and then have the next Invoice generated by a Subscription sweep them up, so both the one-off items and the Subscription charges are all on one Invoice.
If you want to do separate Invoices you would create the Invoice Items for the first Invoice, create the Invoice, then do the same thing for the next Invoice.
Fair enough, manual would be more reassuring but that's a nice feature.
The invoice items need creating before the invoice.
Interesting.
Yep, that's correct.
Invoice item successfully created resp
Okay
There's a few weird bits but this is pretty nice.
I've got a full paywall and subscription and invoice system within a few hundred lines of code...
Thank you to you and the few others who helped me and cleared up Stripe API etc a bit more.
Way better than Paypal
Happy we could help!
@honest jasper for some reason I set auto_advance and I wasn't emailed straight away? (Still haven't received the email)
Invoice status = 'incomplete'
I need additional details to be sure, but I'm guessing you didn't call the pay API on the Invoice: https://stripe.com/docs/api/invoices/pay
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
i set it to auto advance and called the finalize
I did see some mention of
pay || send
What's the Invoice ID?
in_1JXtfGGi6NmsijZi1wOLqAoY
It says OPEN now
But no email
"Will be charged in 1 hour
"
So it wasn't advanced?
It will auto advance in one hour. If you don't want to wait call the pay API I linked to above.
I called finalize
Finalize is not pay.
Those are two different calls.
I only called finalize in order to send the email
Generally you would finalize and then pay if you wanted to do both.
Okay ty!
Finalize will cause the email to be sent in about an hour.
Yes.
This is it then, we'll see.
@honest jasper can I swap invoice.pay with invoice.send
And use it reliably for people with no payment method yet?
Possibly? I don't think I have enough context to answer with certainty. Did you try it and something unexpected happened?
That was when you used pay, right? What happened when you tried send?
I haven't tried it yet, I'll do that now.
This is a lot of steps for just a custom invoice/quote
Last step I believe.
Let's back up a bit. What are you trying to do exactly? I feel like you may be on the wrong path?
I want to invoice the customer a custom priced quote and have them pay it.
Feels like the wrong path to me too, I just assumed Stripe was long
Now, when you say "quote" do you literally mean a quote? As in: https://stripe.com/docs/quotes
Yes!!! ๐ ๐ ๐ ๐ ๐ ๐
Looks like I'll have to redo it, was a nice excuse to practise invoices though. I bet it's very similar.
They are fairly similar.
But yeah, sounds like Quotes are what you want/need. They turn into Invoices later on, but yeah, starting with Invoices doesn't sound like a good fit for your use case.
@honest jasper I may disagree slightly.
The reason I want invoice directly was so that I could check if it was paid.
Because it's tied to an internal quote called "request"
Shouldn't I have received an email for in_1JXuCQGi6NmsijZiSgazSl5U by now? It has been a while
Right, but Quotes turn into Invoices and then the Invoice gets paid.
When does the quote turn into an invoice?
Learn about the quotes workflow.
You're in test mode, and we don't usually send invoices in test mode. The exception is if you trigger them manually in the Dashboard and send them to your email address only.
Learn about the quotes workflow.
This is great.
โโAfter the customer agrees to your quote, you can mark it as accepted. Accepted quotes generate an invoice, subscription, or subscription schedule โโautomatically
I think that would really improve the business, thank you so much.
Quotes are pretty straightforward from a code perspective, I recommend giving it a try using this guide: https://stripe.com/docs/quotes/create?testing-method=with-code
You can probably have them up and running pretty quickly in order to test them out.
Yes.
But this is for a custom quote / estimate
That defeats the entire point
Can I pass the invoice item...?
But if I create an invoice item, it would get pulled into the next invoice...
So if they accept the quote and a new invoice item is created.. then it's a duplicate.
You shouldn't be creating Invoice Items at all if you're using Quotes.
Right... you're quoting some kind of product or service, right?
You can create a single Product that has multiple/custom Prices under it.
That's so lame
So if you have, say, a service where you fold tablecloths you can have a single Product called "Tablecloth Folding" and then have many Quotes/Prices that use that single Product.
๐ taking over for @honest jasper now. You can do whatever you want with the API really and create Prices on-demand with the right information (currency amount) as needed and use that
So I don't need to create a product pointlessly?
const price = await stripe.prices.create({
unit_amount: 5000,
currency: 'usd',
recurring: {interval: 'month'},
product: 'prod_KCJVHT787u6aQG',
});
This also requires a product
"REQUIRED UNLESS PRODUCT_DATA IS PROVIDED"
I don't want to create a new product
Every quote will be a different product/different service.
@mental magnet please show me the simplest way to do this without being tied to a product and preferably without creating new product entries... since they'd be impossible to delete then.
You can't have it all really
you do need real Products and Prices
Either you create them upfront and use those, or create them on demand
if the things you sell are completely separate from each other, then create a new Price and Product each time
If they all map to the same product, just with custom pricing, create one Product and then pass that id all the time on Price creation
But these products are never going to be cleaned up and exist for no reason
A product for every customer... that's just stupid
I can't map it to 1 product with custom pricing
The kinds of "custom pricing" that are provided don't give me what I need.
but overall, whatever you are selling can't be unique for every customer, it also doesn't really make sense in a normal business
you don't sell a mop to Customer A and abook to Custom B and a Cookie to Customer C
Every holiday has a different price.
Sure
So you must have different types of holiday packages, and you'd do products for those and then you'd have custom pricing
When you buy something on Expedia, they have hotels and number of nights, and plane tickets, each of those things have an obvious underlying Product
sure, so you do have a Product, "the hotel night at the marriot XXX"
and then you have a Price per night price_ABC like $200
and then you can charge someone for 7 nights so $1400 with the price_ABC
That does not fit the business
I need to be able to quote a different price every time and I don't want to create a product pointlessly.
It doesn't look like Stripe makes this possible (I have it working already)
Basically, you'll be forcing me to rewrite your quote functionality.
Because Stripe can't function without a quote being tied specifically to a product.
With the following limitations on "custom prices":
These aren't custom prices. These are pre-defined prices.
You keep putting that picture, I don't know what it supports/proves
I'm sorry, you do seem set that it can't work
if you don't care about the Price/Product catalog, why is it an issue to create one-off prices/products each time?
It doesn't work, unless the following is true:
I create ONE product... called "Holiday Package"
I WANT TO.
I don't want a different product for each customer.
Here, let me know if this is possible:
then use the one product, what's blocking you? I think that's what I am missing
-
I create ONE product... called "Holiday Package" (PRODUCT_X)
-
I decide that I want to charge customer Y $200,000 for PRODUCT_X ($300,000 if it's you).
-
I dynamically create this price on the PRODUCT_X for a quote
-
Customer Z I decide I want to charge $10,000
-
I dynamically create this price on the PRODUCT_X for a quote
This is 100% supported, that's exactly what the code you had above does
I still don't understand why the product is even necessary.
Sure, but that's a separate discussion
What is not possible today already is doing the simple version of what I needed.
Like what you want is exactly what we do
I want to do it without a product.
That isn't what you do.
It works on invoice but it doesn't work on quote.
This is how it is done on invoice:
The reason is: let;'s say tomorrow you also want to sell a "year-long stay" not holiday packages. Without the Product abstraction, you need to remember that thousands of prices are for holiday packages and new ones are for year long stays"
No product required.
with our approach: the prices for holidays are for a Product prod_A and the prices for year long stays are for a Product prod_B
That isn't true.
All I need is a quote_ref and an invoice_ref
I don't care what Stripe thinks about products.
hum
we're talking a bit past each other
You are correct, we absolutely could remove all of this from our API and it would work your way
it would prevent any kind of improvements, automatic reporting, upsells, and dozens of features we support that almost every business wants in the long run
But in your specific case it would seem easier at first yes
We used to do it this way years ago
We're also working on a new feature that does something similar
Almost every business sure. If it makes life easier for devs in general then your way makes sense.
It seems tightly coupled to someone though..
It really doesn't seem to fit quote whatsoever, quotes are super fluid.
basically you don't create a Price/Product pair. You pass price information like a "flattened line item" and your own "product reference" and we try to de-duplicate/organize for you behind the scenes. It's in beta though a lot of the feedback is that most people want the Product/Price layer after all
Yes. That would be great.
I've worked with many users on the Quote API, most people quote real products/prices they sell, even if it's pricing per customer
I imagine 90% of businesses need it, but this one doesn't.
getting that layer of "N prices go with Product A" unlocks so much reporting/upsell opportunities later
Well I would bet you might in 18 months
No sir.
At no point will I ever want 1 product for every customer.
Or even
1 price entry within a product for every customer
Let's say I have a "HOLIDAY_PACKAGE" and 10,000 people had been quoted for it
our position is that overall it doesn't change much since it's just code. If you do not ever need the product/price split, then it doesn't matter what you do, your code can just create products on demand, an you never look at it, and it doesn't really change anything code wise
And I had added 10,000 prices to it (unique for each)
What happens when I load the product? Do the prices come with it?
"an you never look at it"
That's really unwise.
It's a financial account, it needs to be as simple as possible and watched carefully. Basic security.
What does security have to do with any of this?
Cleaner data is better security.
When you load a product from stripe
Does it automatically include the pricing information?
who loads what in that sentence?
Doesn't look like it will load prices, at least that's not going to be a problem.
I have a feeling that:
const price = await stripe.prices.create({
unit_amount: 5000,
currency: 'usd',
product: 'prod_KCJVHT787u6aQG',
});
This is going to tell me
That the product can't have more than 1 price
of course it can have more than one price, that's the whole point
and no a Product doesn't have a list of Prices in it, since you could have millions of them. You use the List Prices API to find those, there's a product parameter to filter https://stripe.com/docs/api/prices/list
I'm just answering your questions here, you definitely don't have to use it
What's your question that goes with that screenshot?
are you asking what to pass in line_items?
Please, unless you see any other issues.
I'm aiming for bare minimum (I don't use code I don't understand).
oh sorry so you are not the developer implementing this yourself?
Yes, I am.
I've just never used Stripe before.
Also, the Node.js example is missing from quotes.
I'm sorry I'm lost, you said you're not intelligent, not really collaborative, then that you don't use code and don't understand but now say you're the on implementing this
Are you the developer yourself?
Yes.
I only use code that I understand I meant.
Can't take risks with client work.
ah gotcha. So what is your question? You send a screenshot of your code instead of real code (I'm getting the APIreference fixed, no idea how no one noticed this for months, sorry)
Are you trying to say my code isn't real? That's pretty cruel.
Oh yeah, sorry
const customPrice = createPrice({
unit_amount: 5000,
currency: 'usd',
product: 'prod_KCL0vgnyIntmas'
});
console.log(customPrice);
const quote = createQuote({
customer: requestUser.stripe_identifier,
line_items: [
{
}
]
});
console.log(quote);
-d "line_items[0][price]"=price_1JXuscGi6NmsijZiPEMXwUi0
-d "line_items[0][quantity]"=2
so what is createPrice in your code? Did you write your own method for this?
It's just a wrapper to make it fiber
Because Meteor is weirder than Stripe is.
const customPrice = createPrice({
unit_amount: 5000,
currency: 'usd',
product: 'prod_KCL0vgnyIntmas'
});
console.log(customPrice);
const quote = createQuote({
customer: requestUser.stripe_identifier,
line_items: [
{
price: customPrice.id,
quantity: 1
}
]
});
console.log(quote);
export const createPrice = Meteor.wrapAsync(stripe.prices.create, stripe.prices);
Just pretend it's
const customPrice = await stripe.prices.create({});
The async/method calls are all working fine.
cool so the code you have, does it not work/error? You tweaked the hash now which should be correct
I'll try it now
I haven't ran it yet, I could tell it wasn't worth running before ๐
that's how I would do it. You can also ignore the createPrice and pass price_data instead to create the Price inline
something like this const quote = createQuote({ customer: requestUser.stripe_identifier, line_items: [ { price_data: { unit_amount: 5000, currency: 'usd', product: 'prod_KCL0vgnyIntmas' } quantity: 1 } ] }); console.log(quote);
v
@mental magnet perfect, thank you very much.
It's not so bad making the product especially since it's an edge case... but I'd rather not have that step and to worry about another identifier (gets deleted when you clear test data)
yep, you can pass product_data too I think instead of product
I want to clear test data and get rid of invoices and customers but not products and
but that creates one product per price/quote which you didn't want
I guess you could keep track of whether a product exists already with https://stripe.com/docs/api/products/list and use it if there's one
but that's meh :p
I'll stick with this way, thank you.
Btw, maybe you already know this
but if you put a Discord link between <> it suppresses the embed
I may end up doing this but for now everything is working perfectly. I've made a full business model with subscriptions, paywall, quotes (due to your and support advice), invoices...
In like 2 days
This would have taken me 6 months in Paypal
ah yeah, but it removes the pleasure of undoing those embeds which I find calming :p
I will boost this server when this client pays me as a way to pay back
but thanks for sharing,I remember reading this weeks ago and then forgot, will try to use it more
In my server with a bot I made... I had the bot suppressing other people's links unless they toggled it
oh that's nice! We're a big company and all of it is paid by Stripe this server (I work for Stripe) though so keep your money ๐
ah that's nice. Yeah I remove embeds for others too
which I also find calming ๐น
I don't think a bot can anymore
I may try turning it back on see if it works again.
Thanks for all the help again, take care.
You too!
@mental magnet one last thing...
I thought it said customers could... "accept" a quote...
Is this an email that's sent automatically... or like invoice is it not sent to test environments?
Weird.
I thought "Quotes" included a functionality for the customer to accept a quote
we have a hosted page for quotes where they can accept yes
and we don't send emails in Test mode
And they can't be previewed in test mode either