#fauve-prefill

1 messages · Page 1 of 1 (latest)

scarlet coral
#

hi there, can you share a link to the documentation for the Stripe form that you're referring to?

daring mauve
#

Yes. One minute.

daring mauve
#

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.

scarlet coral
daring mauve
#

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?

scarlet coral
#

yep, it's just a single name field. We don't offer separate fields for first name and last name

daring mauve
#

👍

light quarryBOT
#

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

daring mauve
#

@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

dim pulsar
#

This API will return the whole customer object, including the cusotmer ID.

daring mauve
#

I need to store this php page somewhere and call it from another page to get the json?

dim pulsar
#

$customer = $stripe->customers->create([....

daring mauve
#

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 ?

dim pulsar
#

You can create a $customer variable to store the customer object

daring mauve
#

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?

dim pulsar
#

OK, so you question is how to retrieve the customer object knowing its ID?

daring mauve
daring mauve
#

I just whant to retrieve at least the customer id, or someting alow me to get the customer object.

dim pulsar
#

Did you save the API result to a variable?

daring mauve
#

🌻 it’s for you @dim pulsar

dim pulsar
#

OK, so you have the customer variable that contains all the customer info including the ID

daring mauve
#

Yes, I have it now. The world is wonderfull.

dim pulsar
#

Don't mention it, happy to help

daring mauve
dim pulsar
#

Nope, this API doesn't accept product

daring mauve
#

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.

dim pulsar
daring mauve
#

Thank you.

#

Ow, ok, it’s near products.

daring mauve
#

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?

dim pulsar
#

The Checkout session won't pre-fill other data I'm afraid

daring mauve
#

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.

dim pulsar
#

You can listen to the checkout.session.completed webhook events to get notified when your customer has completed the checkout session.

daring mauve
#

Thank you a lot, it’s great to help me, you and alex-stripe 🙂

daring mauve
#

I can’t get an ID of the maded transaction ?

dim pulsar
#

what do you mean by maded transaction ?

daring mauve
#

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

dim pulsar
#

OK, so you are using PaymentLink, this is the no code solution for non-engineer to quickly get started with Stripe products

daring mauve
#

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?

dim pulsar
#

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.

daring mauve
#

With the cli ? ok.

#

@dim pulsar is this command correct ? : $ stripe listen --events=checkout.session.completed ?

floral silo
#

Hey, taking over here. Let me know if there's any follow-up Qs I can answer!

daring mauve
#

With pleasure 🙂

floral silo
#

Are you trying to forward test events with the CLI to a local webhook handler?

daring mauve
#

Yes, that’s what I try to do*

floral silo
daring mauve
#

For the moment I didl :
stripe listen --events=checkout.session.completed --forward-to https://<link to my webhook>

floral silo
#

Is it working as you need?

daring mauve
#

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.

floral silo
#

Have you triggered a checkout.session.completed event (either via the CLI or by completed a Payment Link transaction)?

daring mauve
#

I get it.

daring mauve
#

I did this in the cli:

#

^C$ stripe trigger checkout.session.completed

#

In the mail I get "11" 😹

floral silo
#

Yep, that will create test objects and fire the corresponding events?

daring mauve
#

Someting goes wrong.

daring mauve
#

So, now it reach my webhook. But my webhook didn’t receive nothing pertinent (json, ID…)

floral silo
#

Can you share your webhook code? Your handle mustn't be parsing the incoming event correctly

floral silo
#

You need to handle the JSON correctly:

$payload = @file_get_contents('php://input');
$event = \Stripe\Event::constructFrom(json_decode($payload, true));
daring mauve
#

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

floral silo
#

Well, that example actually uses the webhook signing secrets to verify the event was actually sent by us

#

Hence the constructEvent function

daring mauve
#

Then, the json is stored in $payload?

floral silo
#

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

daring mauve
#

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.

floral silo
#

Sure, that's a fair concern

daring mauve
#

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.

floral silo
#

Sure, np! Always here to answer any more Qs you have

daring mauve
#

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?

floral silo
#

Yep that will be the value filled by user in the Checkout page UI

daring mauve
#

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.

daring mauve
#

Here I am again 😹

#

So, I can get the id from the json below,

#

Theire is two other variables payment_intent and payment_link

#

So witchone is usefull to retrieve payment, please?

floral silo
daring mauve
#

Ow… sorry.

#

I become anoying, since I didn’t sleep from more over than 20h. Sorry :>

floral silo
#

Ouch, get some rest (or ☕ )!

daring mauve
#

Thank you, I finish it now. I can sleep now.

#

But you have a cool comunity, here.