#fobor10362-checkout-email

1 messages · Page 1 of 1 (latest)

smoky ridge
#

Yo! Can you share the Checkout ID?

plucky barn
#

hold on

#

oh nevermind i see you disabled it so users cannot change their emails!

smoky ridge
#

Yeah that was a recent change if you pass customer I believe

plucky barn
#

excellent that changes everything

#

is there a way to pass in more fields like phone number using checkout?

smoky ridge
plucky barn
#

and can you make it optional instead of required or can you force it to be required?

smoky ridge
#

It's always required. Can't be optional if you pass that parameter

plucky barn
#

ah what a shame you cannot customize it 😦

#

is there a specific format for the phone number?

#

like an international format?

#

parenthesis, spaces, dashes?

clear matrix
#

Hi! I'm taking over ynnoj

#

The advantage of using Stripe Checkout is that it automatically handles data validation for you. So you will see an error message on the page if the phone is not being recognized by Stripe.

plucky barn
#

ok but what format is it in? Stripe will detect fake numbers?

#

+12345678909, (123) 456 78909, 123-456-78909 ?

clear matrix
#

I'm not sure on the exact format, and it might depend on the country. So I would recommend to test that directly yourself in test mode.

plucky barn
#

ok

#

I have a donations checkout page but it creates a new price id every time. Is there a way to prevent that?

clear matrix
#

Can you share a Checkout Session ID (cs_xxx) you created?

clear matrix
#

Thanks! Give me a few minutes to look into this.

plucky barn
#

stripe_donation_product_id = settings.STRIPE_DONATION_PRODUCT_ID
price = stripe.Price.create(
product=stripe_donation_product_id,
unit_amount=converted_amount,
currency='usd',
recurring={'interval': interval,},)
checkout_session = stripe.checkout.Session.create(
success_url=request.build_absolute_uri(reverse('donate:success')) + '?session_id={CHECKOUT_SESSION_ID}',
cancel_url=request.build_absolute_uri(reverse('donate:cancelled')),
payment_method_types=['card'],
customer=customer_id,
mode="subscription",
line_items=[{
'price': price,
'quantity':1,
}]
)

#

that is my code. I am forcefully creating the price id each time. Is there another way?

clear matrix
#

I see that your "donations" products has over 100 prices. You should create a price just once, and then reuse the price price ID when creating a Checkout Session.

plucky barn
#

hmm but a user could enter tons of custom values?

#

i guess i would have to lookup if the price id exists already?

clear matrix
#

hmm but a user could enter tons of custom values?
What do you mean by this? You should create a few Prices in advance, and then pick the correct price ID when creating the Checkout Session.

plucky barn
#

so i could have this for example:

#

$8 one time donation, $8 daily donation, $8 weekly donation, $8 monthly donation, $8 yearly donation

#

customers could enter any value or amount and choose any interval they want

#

there could be tons of results over time

clear matrix
plucky barn
#

hmmm

#

you mean the unit amount? Can you provide an example? Because that link you gave seems similar to what I have already with creating a price id. I would have to look it up then to see if it exists

clear matrix
#

IT's similar to what you are doing, but without creating any price.
It would look something like this (in nodejs):

stripe.checkout.sessions.create({
  payment_method_types: ["card"],
  mode: "payment",
  success_url: "http://.../success",
  cancel_url: "http://.../cancel",
  line_items: [
    {
      price_data: {
        currency: "eur",
        unit_amount: 250,
        product_data: {
          name: "name of the product",
        },
      },
      quantity: 1,
    },
  ],
});
plucky barn
#

ok makes sense thanks. so this would prevent any price ids from being created at all for the donation? for the product data, how would i pass in the product id? It has to be the name of the product?

clear matrix
#

this would prevent any price ids from being created at all for the donation?
Yes

how would i pass in the product id?
My example above is using no Product IDs. If you have one then you can do so like this:

line_items: [
    {
      price_data: {
        currency: "eur",
        unit_amount: 250,
        product: "prod_xxx",
      },
      quantity: 1,
    },
  ],
plucky barn
#

ah perfect

#

very interesting stuff! I will have to do a few tests.

#

Going back to the phone number, that data is captured in the charges object?

clear matrix
plucky barn
#

oh ok nice. So the customer can have multiple phone numbers though right if they pay multiple times and enter a new one?

#

or is it 1 field that gets updated with new data??

clear matrix
#

It's explained on the page I just linked:

Passing in an existing Customer with a populated phone property to the Checkout Session results in the phone number field being pre-filled.
If the customer updates their phone number, this updated value persists on the phone property on the Customer object , overwriting any previously saved phone number.

plucky barn
#

oh sorry i did not see it!

#

I am getting an error from your code: name 'price_data' is not defined

#

line_items=[{
price_data: {
currency: "usd",
unit_amount: 250,
product: "prod_HuhjcdKhnVmN8A",
},
'quantity':1,
}],

#

node js uses : not equals like in python?

#

oh maybe i need to do this 'price_data'

#

Request req_kkY3c7zcklSB7q: You must provide at least one recurring price in subscription mode when using prices.

#

guess we can't do it that way and we absolutely need a price id

smoky ridge
#

To be clear, using price_data will create an ad-hoc Price object for every Session

plucky barn
#

oh ok

#

so it really doesn't matter either way a price id will be created using your method or mine?

smoky ridge
#

Exactly, yes

#

Just using price_data means they're created ad-hoc

clear matrix
#

Sorry for the confusion, I didn't know that.

plucky barn
#

i see. no worries soma

#

ok thank you i have a lot to think about

smoky ridge
#

Kind of buried in the docs ☝️

#

By default, prices created with price_data are effectively archived (for example, they’re marked as active=false) so that they you can’t reuse them for other customers or subscriptions. You can’t update or reuse ad hoc prices after you create them.

plucky barn
#

so there will always be hundreds of $8 monthly price ids if customers love donating that amount all the time?

smoky ridge
#

Yes exactly

#

There's work underway to better facilitate this use case, but nothing to share yet

plucky barn
#

that is good to know. any ideas what it entails?

#

or what method you will use instead?

smoky ridge
#

Can't share anything right now

plucky barn
#

😦 any expected release date?

smoky ridge
#

Can't share anything right now

plucky barn
#

😢

#

ok guess i will just have to wait then

smoky ridge
#

There's nothing inherently bad about the multitude of Price objects

plucky barn
#

ok that's good

#

is there a webhook for when a customer pays an amount based on a certain product id?

smoky ridge
#

There's not, no

plucky barn
#

but there is when a customer pays something though?

#

i have a memberships product that is currently on stripe.js and am thinking of moving it to checkout

#

but it does a bunch of crazy things though and am wondering if i should switch to checkout as long as I can do everything the same in checkout

smoky ridge
#

Yep, you'll get a checkout.session.completed event

plucky barn
#

hmm i neeed a way to tie it to a certain product id though since i have a donations product id and memberships product id

smoky ridge
#

Yeah you can do that, but you'll need to make an additional API request to extend the line_items field on the Checkout Session

plucky barn
#

Can you show me an example?

smoky ridge
#

What language are you using in your webhook?

plucky barn
#

python

smoky ridge
#

Something like:

stripe.checout.Session.retrieve(
  'cs_xxx',
  expand=['line_items']
)