#one_checkout-shipping

1 messages ยท Page 1 of 1 (latest)

manic prismBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1216887609599590402

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

wintry houndBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

digital ember
coral ore
#

I don't believe the request makes it to Stripe. I have the code in a try catch statement, and catch triggers. That is why I thought it was syntax

digital ember
#

Right of the bat, it looks like you are not providing an array properly. Shouldn't this be

$checkout_session = \Stripe\Checkout\Session::create([
    'shipping_address_collection' => [
        [
            'allowed_countries' => ['us', 'ca'],
        ],
    ],
]);

?

#

I'm not a PHP expert but I think that's how you pass arrays

coral ore
#

Your attempt looks better than mine. I'll give it a try.

#

While I'm checking. Are those the correct parameters I'm asking for and array names?

digital ember
#

This line specifically seems to be what you are doing:

  'shipping_address_collection' => ['allowed_countries' => ['US']],

and that's pretty much your syntax. You might want to use caps for your country codes but otherwise it's the same

coral ore
#

Still failing in the catch. This is my code. It worked before I added the shipping request. Something is wrong with this code snippet.

#

Trying the capitals now

digital ember
#

What is the complete contests of the Exception?

#

$e

coral ore
#

one sec. getting it.

#

req_PaQVno0vNsf2Mk

#

unknown parameter: shipping_address_collection[0]

digital ember
#

Yeah because it's wrapped in too many []

#
'shipping_address_collection' => [
                
                    'allowed_countries' => ['us', 'ca'],
                
            ],
#

You've got an extra set in there

#

the shipping_address_collection is a hash type or associative array in PHP. You passed it as an array

wintry houndBOT
hollow magnet
#

one_checkout-shipping

coral ore
#

Seems to be working. Thank you for your help. Much appreciated. Have a great day.

#

Can I ask you a Webhook question. Just a question. Mine is working

hollow magnet
#

yep feel free to ask anything!

coral ore
#

Thanks. Webhook is able to send the return Event to my endpoint page, webhook.php. The sample assigns the Event object to a variable such as $paymentIntent. To retrieve the customer's info what is the syntax. Example $paymentIntent->customer_name or $paymentIntent.customer_name.

#

I see the instruction in the docs, but the docs are terrible sometimes - by not showing examples with exact syntax.

#

I'll send you the example code. One sec.

hollow magnet
#

okay so what's the problem exactly?

coral ore
#

Did you read my question above.

#

And look at the code sample.

hollow magnet
#

I did but you didn't really say much, just "docs are bad" and "need help"

#

like what exactly is the provlem?

coral ore
#

how do I extract the info from the payment intent?

hollow magnet
#

what have you tried?

coral ore
#

That's not all I said.

#

Stripe is great

hollow magnet
#

Sure but you haven't really said your exact question about this problem

coral ore
#

no syntax examples.

#

I;m not complaining.

hollow magnet
#

right now what you have is correct, so what exactly have you tried that isn't working?

coral ore
#

Can you stop

#

It's a simple question.

#

I've spent days trying to find syntax examples.

#

It's one line of code.

#

$paymentIntent boject

#

Look at the code please.

hollow magnet
#

I'm helping you. The code you shared works. I'm asking what the real problem is. I assume you tried something and that thing errored or didn't work.

coral ore
#

Please read. I'll ask again. case 'payment_intent.succeeded':
$paymentIntent = $event->data->object;

#

How would I get the customers name.

#

That's the only example I need.

#

One line of code, and I'll understand

#

case 'payment_intent.succeeded':
$paymentIntent = $event->data->object;

#

this is what Webhooks sends back.

#

I want to put the info in my database.

#

How do I get the customers name?

hollow magnet
#

I'm sorry I understand you want me to just give it to you but that's not how I help here. So I'm asking what you tried. A PaymentIntent has no customer name for example, that doesn't exist.

coral ore
#

Oh my goodeness. Other techs here don't have a problem.

#

Do you not know how to do it?

#

$paymentIntent->customer_id

#

Am I close.

#

$paymentIntent.customer_id

#

Any closer.

#

I just want to start putting this in my database. I finally got this working, which took me 4 days. And you won't tell me how to extract it.

hollow magnet
#

$paymentIntent->customer_id will be the customer id cus_123 which is not what you asked. I'm sorry you're clearly frustrated but I am trying to help you undersand your own question and how to self-serve

coral ore
#

Is there documentation that shows the exact syntax

#

Actually I'm not frustrated

#

Actually you seem to be frustrated.

#

I'm just asking a simple question.

#

Are you saying this is the correct syntax? $paymentIntent->customer_id

hollow magnet
#

Not really because that wasn't really your question again, you asked about the Customer name which does not exist on PaymentIntent.

The code $paymentIntent = $event->data->object; extracts the PaymentIntent information from the Event and puts it in the $paymentIntent variable. At that point, it's an instant of the PaymentIntent class from the stripe-php SDK and it has all the properties you see on our API Reference at https://docs.stripe.com/api/payment_intents

So if you write $paymentIntent->id you get pi_12345 if you write $paymentIntent->latest_charge you will get ch_1234 which is the Charge id, etc.

coral ore
#

Thank you.

hollow magnet
#

Try it though, I think you will have more questions but I can't really help until I see an exact line of code you tried and potentially the error

coral ore
#

Received unknown event type checkout.session.completed. There was no payment_intent.succeeded event.

#

Why was there no payment intent event

hollow magnet
#

There can be tons of reasons, such as a mode: 'setup' Checkout Session, one with a 100% off coupon, one for a Subscription with a trial and many more

coral ore
#

I didnt change anything. The only thing changed was the shipping address fields we addes.

#

added

hollow magnet
#

I'm sorry but I am not seeing what you are seeing unfortunately. I can only tell you some of what I think could cause this

coral ore
#

Do I extract information the same way as the payment intent. $checkoutSession = $event->data->object;
$id = $checkoutSession->id;

hollow magnet
coral ore
#

Thank you.