#diavo-elements
1 messages · Page 1 of 1 (latest)
@reef rain that's not something we support today, those are HTML inputs you'd build as part of your overall form, we only have Elements for the card inputs themselves
So i cant add additionnal existing Stripe element in my stripe form ?
Because when a customer pay on my app atm, in dashboard he doesnt have billing adress or adress
His name is determined from his credit card name
do you use Elements or Checkout, or something else?
so you use Checkout
then yes you can't really customise what it asks for, it's a hosted page. We ask for the cardholder name, as you've seen. You can use https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-billing_address_collection to tell us to collect the full billing address if you'd like that!
so i just have to add this on my stripe.checkout.sessions.create ?
wait a minute, i didnt pay anything to use checkout, am i doing something wrong ?
yep it's parameter to that function
not sure what that means. There's no cost to using Checkout beyond normal processing fees as far as I know.
ok thanks, shouldn't i use customer create then setup intent then subscription.create to get data that i want for the customer? https://stripe.com/docs/api/customers/create?lang=node
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
hmm
I mean, you can, but that's an entirely different integration and much more work than using Checkout so I don't see why you'd do it.
if you just specifically want the Customer object cus_xxx to have specific fields like name and address set there are ways to do it. Like you could ask for it upfront before going to Checkout, create a Customer object(https://stripe.com/docs/api/customers/create?lang=node yes) and then use that Customer object in the CheckoutSession. https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
or you could copy the fields from the billing_details of the PaymentMethod across to the Customer object by writing some custom code as part of handling the checkout.session.completed webhook event, as another example.
so i guess there is no way to put a checkbox with GTC popup that needs to be read before clicking pay ?
no, there's not; you can add a link to your policies(https://stripe.com/docs/payments/checkout/customization#policies) but not a a checkbox
ok thanks mate, so i create ````form action"/create-customer" method="POST"``` to create a customer ?
to get his customerid with adress, name on /create-checkout session
hmm, maybe? you're skipping some steps there so I don't really know what you mean
- User click on a item to buy (15 dollars sub per month). 2. He get a form when enter his name, adress, phone number(if possible), card then he click pay and its done
This is what i want to achieve
const { sessionId } = req.query;
const session = await stripe.checkout.sessions.retrieve(sessionId);
res.send(session);
});
app.post("/create-checkout-session", async (req, res) => {
const domainURL = process.env.DOMAIN;
const { priceId } = req.body;
// Create new Checkout Session for the order
// Other optional params include:
// [billing_address_collection] - to display billing address details on the page
// [customer] - if you have an existing Stripe Customer ID
// [customer_email] - lets you prefill the email input in the form
// [automatic_tax] - to automatically calculate sales tax, VAT and GST in the checkout page
// For full details see https://stripe.com/docs/api/checkout/sessions/create
try {
const session = await stripe.checkout.sessions.create({
billing_address_collection: 'required',
mode: "subscription",
payment_method_types: ["card"],
line_items: [
{
price: priceId,
quantity: 1,
},
],
// ?session_id={CHECKOUT_SESSION_ID} means the redirect will have the session ID set as a query param
success_url: `${domainURL}/success.html?session_id={CHECKOUT_SESSION_ID}`,
cancel_url: `${domainURL}/canceled.html`,
// automatic_tax: { enabled: true }
});
return res.redirect(303, session.url);
} catch (e) {
res.status(400);
return res.send({
error: {
message: e.message,
}
});
}
});
app.get("/config", (req, res) => {
res.send({
publishableKey: process.env.STRIPE_PUBLISHABLE_KEY,
basicPrice: process.env.BASIC_PRICE_ID,
proPrice: process.env.PRO_PRICE_ID,
});
});```` i have this code from stripe github
then you can use Checkout for that form, sure.
https://stripe.com/docs/payments/checkout/phone-numbers is how you collect a number.
https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-billing_address_collection is how you collect the address.
cool, that looks like a working simple enough integration of Checkout. You can start experimenting with these extra parameters I've been linking you to so you can test out/see how things work and look.
ok thanks mate
Ok, where do i put my const customer = await stripe.customers.create({ description: 'My First Test Customer (created for API docs)', }); to make it work ? Because i cant see here why it would work if i put it like that on my server.js file, sorry againb for dumb question
you don't have to create a customer separately , but you can as an option. I'd try using the parameters to Checkout mentioned above first and see if it works for your use case before going down that path
Yyeah i can get the adress but number form doesnt show up with the snippet on doc
you're using phone_number_collection[enabled]:true and it doesn't result in the Checkout page asking for one?
well i'm using "phone_number_collection: {
enabled: true,
}," and it doesnt show up
can you link me to your exact Checkout page, the checkout.stripe.com link of the page?
hey there, sorry just picking this up -- i've tested this feature so let me see what's going on here
ahh, we've got a bug @reef rain -- actively working on resolving it, should be working again shortly!
ok thanks mate