#fobor10362-checkout-email
1 messages · Page 1 of 1 (latest)
Yeah that was a recent change if you pass customer I believe
excellent that changes everything
is there a way to pass in more fields like phone number using checkout?
You can collect phone numbers, yep: https://stripe.com/docs/payments/checkout/phone-numbers
and can you make it optional instead of required or can you force it to be required?
It's always required. Can't be optional if you pass that parameter
ah what a shame you cannot customize it 😦
is there a specific format for the phone number?
like an international format?
parenthesis, spaces, dashes?
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.
ok but what format is it in? Stripe will detect fake numbers?
+12345678909, (123) 456 78909, 123-456-78909 ?
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.
ok
I have a donations checkout page but it creates a new price id every time. Is there a way to prevent that?
Can you share a Checkout Session ID (cs_xxx) you created?
I did not pay yet either. I allow customers to enter a custom value they want to donate then they can go to the checkout page to pay
Thanks! Give me a few minutes to look into this.
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?
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.
hmm but a user could enter tons of custom values?
i guess i would have to lookup if the price id exists already?
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.
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
If the price is completely flexible, then instead of using price IDs you could directly pass the amount when creating the checkout session using line_items.price_data https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data
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
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,
},
],
});
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?
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,
},
],
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?
The phone can be retrieved on the Customer object or Checkout Session object, as explained here: https://stripe.com/docs/payments/checkout/phone-numbers#after-session
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??
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.
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
Hmm, you'd passing the recurring hash: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-line_items-price_data-recurring
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
To be clear, using price_data will create an ad-hoc Price object for every Session
oh ok
so it really doesn't matter either way a price id will be created using your method or mine?
Sorry for the confusion, I didn't know that.
Learn how to manage products and prices.
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.
so there will always be hundreds of $8 monthly price ids if customers love donating that amount all the time?
Yes exactly
There's work underway to better facilitate this use case, but nothing to share yet
that is good to know. any ideas what it entails?
or what method you will use instead?
Can't share anything right now
😦 any expected release date?
Can't share anything right now
There's nothing inherently bad about the multitude of Price objects
ok that's good
is there a webhook for when a customer pays an amount based on a certain product id?
There's not, no
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
Yep, you'll get a checkout.session.completed event
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
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
Can you show me an example?
What language are you using in your webhook?
python
Something like:
stripe.checout.Session.retrieve(
'cs_xxx',
expand=['line_items']
)
That will return the same Checkout Object, but with the line_items field: https://stripe.com/docs/api/checkout/sessions/object?lang=python#checkout_session_object-line_items
That contains data pertaining to Prices & Products
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.