#fauve-prefill
1 messages · Page 1 of 1 (latest)
hi there, can you share a link to the documentation for the Stripe form that you're referring to?
Yes. One minute.
It create a payment link with void fields in the form. I didn’t find in documentation how to prefiled the form with information I alredy grab about my customer.
And for user experience and comfort, I whant to avoid to force the user to fille twice his informations.
if you have those information already, you should create a Customer : https://stripe.com/docs/api/customers/create.
When you include the Customer id when creating a Checkout session, it will prefill certain fields based off certain criteria : https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
Ok, thank you, it’s nice @scarlet coral 🙂 It’s a quick and satisfying answear.
But, just a few little thing: theire is only onename field and no lastName-firstName couple. Theire is no way to get this behaviour?
yep, it's just a single name field. We don't offer separate fields for first name and last name
👍
This thread has been archived. If you need help with anything else please ask in #dev-help or contact Stripe Support: https://support.stripe.com/contact
Find help and support for Stripe. Our support center provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
@scarlet coral please, related to this archived tread #965824750763012096 message , how to get customer ID when I create it with \Stripe\StripeClient->customers->create ?
I can create it and see it in my dashboard, but how can I get the id after create the client?
$stripe = new \Stripe\StripeClient(
'topsecret'
);
$stripe->customers->create([
'description' => generateRandomId(),
'email' => "contact@taniere.info",
'phone' => "0033656562545",
'shipping' => [
'name' => "Jean Dupond",
'address' => [
'city' => "London",
'country' => "UK",
'line1' => "22b Baker Street",
'postal_code' => "12345",
]
]
]);
This is my code
This API will return the whole customer object, including the cusotmer ID.
I need to store this php page somewhere and call it from another page to get the json?
$customer = $stripe->customers->create([....
I can’t just stay in the same php page and get the json from $stripe variable to continue my process in the same file ?
You can create a $customer variable to store the customer object
Ok
So thank you.
Hmm… just a minute.
As I said, the customer is correctly created in my dashboard.
But I still don’t know how to get the customer object.
I see here how the response should look like, but how can I retrive it?
OK, so you question is how to retrieve the customer object knowing its ID?
When I wrote « I see here » I forget the past the link https://stripe.com/docs/api/customers/create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Not exactly… after the code I showed here #965824750763012096 message I didn’t get at all any customer object or customer id.
I just whant to retrieve at least the customer id, or someting alow me to get the customer object.
Did you save the API result to a variable?
Now yes 🙂
🌻 it’s for you @dim pulsar
OK, so you have the customer variable that contains all the customer info including the ID
Yes, I have it now. The world is wonderfull.
Don't mention it, happy to help
Please, in the session creation https://stripe.com/docs/api/checkout/sessions/create can I instead of price put a product ?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Nope, this API doesn't accept product
Ok.
So where can I create or modify price from dashboard?
It’s important to make it from the dashboard, so administrators can do it codeless.
https://dashboard.stripe.com/test/products you can create /modify the prices from this page
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
So, I launch a session https://stripe.com/docs/api/checkout/sessions/create with a customer id. It autodect his email and prefield it.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
But it doesn’t field his name, his address, un phone number.
I tried 'billing_address_collection' => 'required',
But it doesn’t fill it, it just add morover field.
Is it possible to pre-field other data than only email, please?
The Checkout session won't pre-fill other data I'm afraid
Ok ://
BTW, can I at least get back this data after the checkout session by listning to the API to store them in my DB ?
I’ll let Stripe perform the KYC, and then ask him back to give them to me.
Just to avoid asking the user 2 times the same questions.
You can listen to the checkout.session.completed webhook events to get notified when your customer has completed the checkout session.
Thank you a lot, it’s great to help me, you and alex-stripe 🙂
Pelase, in this page https://dashboard.stripe.com/test/payment-links/plink_******* for payment link edition, if I set a redirection page,
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I can’t get an ID of the maded transaction ?
what do you mean by maded transaction ?
So, the page below allow me to define a redirecition page for each payment.
When the payment is made, and the user is redirected to the specified page of my website, I want to know if the payment is succeded to advice the user, and send him an email.
I was expecting to get someting with GET or POST
OK, so you are using PaymentLink, this is the no code solution for non-engineer to quickly get started with Stripe products
Okay, so it haven’t this kind of feature.
THe PaymentLink solution’s features satisfy me. I just want in addition to this an ID or a json on post|get when redirecting. Is theire anothe kind of link?
The PaymentLink is powered by Checkout, so you can still register to the webhook events checkout.session.completed to get notified when your customer has completed the checkout session.
With the cli ? ok.
@dim pulsar is this command correct ? : $ stripe listen --events=checkout.session.completed ?
Hey, taking over here. Let me know if there's any follow-up Qs I can answer!
With pleasure 🙂
Are you trying to forward test events with the CLI to a local webhook handler?
Yes, that’s what I try to do*
You'll need to add the --forward-to flag to your command to: https://stripe.com/docs/cli/listen#listen-forward-to
For the moment I didl :
stripe listen --events=checkout.session.completed --forward-to https://<link to my webhook>
Is it working as you need?
I test it.
I put this in the webhook link, to see the behaviour:
$content=print_r($_GET) . print_r($_POST);
mail("mymail@example.com", "Payement stripe", $content);
And now, I’m waiting for the mail.
Have you triggered a checkout.session.completed event (either via the CLI or by completed a Payment Link transaction)?
I get it.
By the cli, I think it’s the answer?
I did this in the cli:
^C$ stripe trigger checkout.session.completed
In the mail I get "11" 😹
Yep, that will create test objects and fire the corresponding events?
Someting goes wrong.
I expect it fire the corresponding events. Then I’ll be able to continue my workflow.
So, now it reach my webhook. But my webhook didn’t receive nothing pertinent (json, ID…)
Can you share your webhook code? Your handle mustn't be parsing the incoming event correctly
Yes @floral silo he is here
You need to handle the JSON correctly:
$payload = @file_get_contents('php://input');
$event = \Stripe\Event::constructFrom(json_decode($payload, true));
Full example here: https://stripe.com/docs/webhooks/quickstart
I find this code a little bit hard to understand.
So finaly, in witch variable is the json stored?
It seems this instruction generate the json json_decode($payload, true)
son I can do $jsoncontent=json_decode($payload, true) ?
Well, that example actually uses the webhook signing secrets to verify the event was actually sent by us
Hence the constructEvent function
Then, the json is stored in $payload?
But if you don't intend to use that (I would recommend you do), then you should use what I shared above and you can use the $event variable
Okay 🙂
I avoid to use huge code when I consider my need to simple for it.
It’s hard to maintain also if I don’t understand half of his instructions.
Sure, that's a fair concern
Thank you @floral silo it work, I think I finish my workflow. Thanks to you all. 🙂
I think it could take more over time without you.
Sure, np! Always here to answer any more Qs you have
To be honest I tried Wire and Transak before. But now I’m sure I’ll use Stripe in future.
Just one last question.
I receveive the json data, but I’m not sure about the syntax to reach mail.
Just one second, i’ll past my output.
Stripe\Event JSON: {
"id": "******",
"object": "event",
"api_version": "2020-08-27",
"created": 1650357733,
"data": {
"object": {
"id": "*******",
"object": "checkout.session",
"after_expiration": null,
"allow_promotion_codes": false,
"amount_subtotal": 5000,
"amount_total": 5000,
"automatic_tax": {
"enabled": true,
"status": "complete"
},
"billing_address_collection": "auto",
"cancel_url": "https:\/\/stripe.com",
"client_reference_id": null,
"consent": null,
"consent_collection": null,
"currency": "eur",
"customer": null,
"customer_creation": "if_required",
"customer_details": {
"address": {
"city": "c",
"country": "MA",
"line1": "a",
"line2": null,
"postal_code": "b",
"state": null
},
"email": "a@b.com",
"name": "S H",
"phone": null,
So, if I want to reach the mail, is this the correct path: ["Stripe Event JSON"]["data"]["object"]["customer_details"]["email"] ?
What the \Eis set for?
Yep that will be the value filled by user in the Checkout page UI
Here Stripe\Event JSON:
Okay.
So, thanks 🙂
So… I didn’t get the mail with this code:
$payload = @file_get_contents('php://input');
$event = \Stripe\Event::constructFrom(json_decode($payload, true));
$To=$event["Stripe Event JSON"]["data"]["object"]["customer_details"]["email"];
I think someting is wrong in my path.
Ow no sorry…
I process the json as if it was a php objebct. My bad.
Here I am again 😹
So, I can get the id from the json below,
But this id dont seems usefull to retrieve a payment with https://stripe.com/docs/api/payment_methods/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Theire is two other variables payment_intent and payment_link
So witchone is usefull to retrieve payment, please?
Well that's the API to retrieve a Payment Method object (i.e. the credit card), not the payment itself
You want the payment_intent field, with this API: https://stripe.com/docs/api/payment_intents/retrieve
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ow… sorry.
I become anoying, since I didn’t sleep from more over than 20h. Sorry :>
Ouch, get some rest (or ☕ )!