#LMF-custom-quotes

1 messages ยท Page 1 of 1 (latest)

severe plinth
lofty wigeon
#
// 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.

severe plinth
#

Can you clarify what you mean by a "dynamic/varying" price?

lofty wigeon
#

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?

severe plinth
#

Thanks for clarifying! Instead of passing inprice you'd want to pass in amount and currency

lofty wigeon
#

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?

severe plinth
#

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?

lofty wigeon
#

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

severe plinth
#

For amount: 100.69 , what is your desired behavior? Do you want to be charging them $100.69?

lofty wigeon
#

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?

severe plinth
#

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.

lofty wigeon
#

no way

severe plinth
#

Yes, the amount field is expecting the value to be in cents (and in other currencies whatever is the smallest unit).

lofty wigeon
#

Wow

#

Do you not get millions of complaints about it?

#

That's really insane imo

severe plinth
#

We get some confusion occasionally, but personally I haven't heard any complaints.

lofty wigeon
#

Ty for your time

severe plinth
#

happy to help!

lofty wigeon
#

Oh

#

Success or redirect URL on the invoice?

severe plinth
#

Ah! Totally missed that question - there isn't a concept of a success/failure redirect URL for the Hosted Invoice page.

lofty wigeon
#

That's a real shame, would have been a great way to intercept.

#

I'll figure rest out. ๐Ÿค” ty ty ty

severe plinth
#

Yeah, sorry about that!

lofty wigeon
#

@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.

severe plinth
#

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

lofty wigeon
#
- 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?

honest jasper
#

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.

lofty wigeon
lofty wigeon
honest jasper
#

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.

lofty wigeon
#

Fair enough, manual would be more reassuring but that's a nice feature.

#

The invoice items need creating before the invoice.

#

Interesting.

honest jasper
#

Yep, that's correct.

lofty wigeon
#

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

honest jasper
#

Happy we could help!

lofty wigeon
#

@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'

honest jasper
lofty wigeon
#

i set it to auto advance and called the finalize

#

I did see some mention of

#

pay || send

honest jasper
#

What's the Invoice ID?

lofty wigeon
#

in_1JXtfGGi6NmsijZi1wOLqAoY

#

It says OPEN now

#

But no email

#

"Will be charged in 1 hour

"

#

So it wasn't advanced?

honest jasper
#

It will auto advance in one hour. If you don't want to wait call the pay API I linked to above.

lofty wigeon
#

I called finalize

honest jasper
#

Finalize is not pay.

lofty wigeon
#

Do I have to call finalize and pay?

#

Or just pay?

honest jasper
#

Those are two different calls.

lofty wigeon
#

I only called finalize in order to send the email

honest jasper
#

Generally you would finalize and then pay if you wanted to do both.

lofty wigeon
#

Okay ty!

honest jasper
#

Finalize will cause the email to be sent in about an hour.

lofty wigeon
#

That's slow, will pay send instantly?

honest jasper
#

Yes.

lofty wigeon
#

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?

honest jasper
#

Possibly? I don't think I have enough context to answer with certainty. Did you try it and something unexpected happened?

lofty wigeon
#

Yes, I got that error I sent to you.

#

The customer doesn't have a card

honest jasper
#

That was when you used pay, right? What happened when you tried send?

lofty wigeon
#

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.

honest jasper
#

Let's back up a bit. What are you trying to do exactly? I feel like you may be on the wrong path?

lofty wigeon
#

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

honest jasper
lofty wigeon
lofty wigeon
#

Looks like I'll have to redo it, was a nice excuse to practise invoices though. I bet it's very similar.

honest jasper
#

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.

lofty wigeon
#

@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

honest jasper
#

Right, but Quotes turn into Invoices and then the Invoice gets paid.

lofty wigeon
lofty wigeon
honest jasper
#

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.

lofty wigeon
#

This is great.

honest jasper
#

โ€‹โ€‹After the customer agrees to your quote, you can mark it as accepted. Accepted quotes generate an invoice, subscription, or subscription schedule โ€‹โ€‹automatically

lofty wigeon
#

I think that would really improve the business, thank you so much.

honest jasper
#

You can probably have them up and running pretty quickly in order to test them out.

lofty wigeon
#

Yeah it's just changing the business model

#

But I like it

#

ty

lofty wigeon
#

@honest jasper product id is required?

honest jasper
#

Yes.

lofty wigeon
#

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.

honest jasper
#

You shouldn't be creating Invoice Items at all if you're using Quotes.

lofty wigeon
#

I know

#

But I need a product_id...

#

Due to required.

honest jasper
#

Right... you're quoting some kind of product or service, right?

lofty wigeon
#

This is my current code.

#

Quoting for a custom priced service/event I suppose.

honest jasper
#

You can create a single Product that has multiple/custom Prices under it.

lofty wigeon
#

That's so lame

honest jasper
#

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.

lofty wigeon
#

@honest jasper I need to set a custom price... these are all hardcoded

mental magnet
#

๐Ÿ‘‹ 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

lofty wigeon
#

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.

mental magnet
#

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

lofty wigeon
#

But these products are never going to be cleaned up and exist for no reason

#

A product for every customer... that's just stupid

mental magnet
#

Well they exist for a reason: you sell them

#

I mean you call it stupid, it's not

lofty wigeon
#

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.

mental magnet
#

but overall, whatever you are selling can't be unique for every customer, it also doesn't really make sense in a normal business

lofty wigeon
#

It is unique for every customer.

#

Call it a holiday.

mental magnet
#

you don't sell a mop to Customer A and abook to Custom B and a Cookie to Customer C

lofty wigeon
#

Every holiday has a different price.

mental magnet
#

What is your tool selling?

#

Well but it's still a holiday package then right?

lofty wigeon
#

Sure

mental magnet
#

So you must have different types of holiday packages, and you'd do products for those and then you'd have custom pricing

lofty wigeon
mental magnet
#

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

lofty wigeon
#

These don't cut it.

#

No...

#

They're all existing products/trips/priced per night.

mental magnet
#

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

lofty wigeon
#

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.

mental magnet
#

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?

lofty wigeon
#

It doesn't work, unless the following is true:

#

I create ONE product... called "Holiday Package"

mental magnet
#

we absolutely support this today already

#

no one forces you to create ONE PRODUCT

lofty wigeon
#

I WANT TO.

mental magnet
#

lol

#

I thought you said the opposite earlier

lofty wigeon
#

I don't want a different product for each customer.

#

Here, let me know if this is possible:

mental magnet
#

then use the one product, what's blocking you? I think that's what I am missing

lofty wigeon
#
  1. I create ONE product... called "Holiday Package" (PRODUCT_X)

  2. I decide that I want to charge customer Y $200,000 for PRODUCT_X ($300,000 if it's you).

  3. I dynamically create this price on the PRODUCT_X for a quote

  4. Customer Z I decide I want to charge $10,000

  5. I dynamically create this price on the PRODUCT_X for a quote

mental magnet
#

This is 100% supported, that's exactly what the code you had above does

lofty wigeon
#

I still don't understand why the product is even necessary.

mental magnet
#

Sure, but that's a separate discussion

lofty wigeon
#

What is not possible today already is doing the simple version of what I needed.

mental magnet
#

Like what you want is exactly what we do

lofty wigeon
#

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:

mental magnet
#

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"

lofty wigeon
#

No product required.

mental magnet
#

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

lofty wigeon
#

All I need is a quote_ref and an invoice_ref

#

I don't care what Stripe thinks about products.

mental magnet
#

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

lofty wigeon
#

Yes. It doesn't do what I want but you helped me find a workaround.

#

Thank you.

mental magnet
#

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

lofty wigeon
#

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.

mental magnet
#

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

lofty wigeon
#

Yes. That would be great.

mental magnet
#

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

lofty wigeon
#

I imagine 90% of businesses need it, but this one doesn't.

mental magnet
#

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

lofty wigeon
#

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

mental magnet
#

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

lofty wigeon
#

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.

mental magnet
#

What does security have to do with any of this?

lofty wigeon
#

Cleaner data is better security.

#

When you load a product from stripe

#

Does it automatically include the pricing information?

mental magnet
#

who loads what in that sentence?

lofty wigeon
#

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

mental magnet
#

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

lofty wigeon
#

Well isn't that dandy. I'm sure I'll need that in 3 decades.

mental magnet
#

I'm just answering your questions here, you definitely don't have to use it

lofty wigeon
mental magnet
#

What's your question that goes with that screenshot?

#

are you asking what to pass in line_items?

lofty wigeon
#

No sir, I'm not that intelligent.

#

This is the first time I've used Stripe.

lofty wigeon
#

I'm aiming for bare minimum (I don't use code I don't understand).

mental magnet
#

oh sorry so you are not the developer implementing this yourself?

lofty wigeon
lofty wigeon
#

I've just never used Stripe before.

#

Also, the Node.js example is missing from quotes.

mental magnet
#

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?

lofty wigeon
#

Yes.

#

I only use code that I understand I meant.

#

Can't take risks with client work.

mental magnet
#

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)

lofty wigeon
#

Hang on...

#

Btw Python is also missing

#

Also Go

#

Also .NET

lofty wigeon
mental magnet
#

no just that it's a picture

#

so I can't copy paste it and help edit

lofty wigeon
#

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

mental magnet
#

so what is createPrice in your code? Did you write your own method for this?

lofty wigeon
#

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.

mental magnet
#

cool so the code you have, does it not work/error? You tweaked the hash now which should be correct

lofty wigeon
#

I'll try it now

#

I haven't ran it yet, I could tell it wasn't worth running before ๐Ÿ˜„

mental magnet
#

that's how I would do it. You can also ignore the createPrice and pass price_data instead to create the Price inline

lofty wigeon
mental magnet
#

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);

lofty wigeon
#

@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)

mental magnet
#

yep, you can pass product_data too I think instead of product

lofty wigeon
#

I want to clear test data and get rid of invoices and customers but not products and

mental magnet
#

but that creates one product per price/quote which you didn't want

lofty wigeon
#

Ah.

#

Ah...

#

But it will create a new product every time.

mental magnet
#

but that's meh :p

lofty wigeon
#

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

lofty wigeon
#

In like 2 days

#

This would have taken me 6 months in Paypal

mental magnet
lofty wigeon
#

I will boost this server when this client pays me as a way to pay back

mental magnet
#

but thanks for sharing,I remember reading this weeks ago and then forgot, will try to use it more

lofty wigeon
mental magnet
lofty wigeon
#

Was actually a really nice invention

#

But then Discord ruined the permissions

mental magnet
#

ah that's nice. Yeah I remove embeds for others too

#

which I also find calming ๐Ÿ˜น

lofty wigeon
#

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.

mental magnet
#

You too!

lofty wigeon
#

@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

mental magnet
#

we have a hosted page for quotes where they can accept yes

#

and we don't send emails in Test mode

lofty wigeon
#

And they can't be previewed in test mode either

mental magnet
#

yeah I don't know how to preview the email for quote or if there's one, let me look

#

yep okay there is an email but I don't see a way to "preview the email"

#

something we should add support for in the future! I'll make a not eof it

lofty wigeon
#

freemium