#one_checkout-shipping
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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.
- one-love_checkout-address-collection, 13 minutes ago, 5 messages
- one-love_webhooks, 14 hours ago, 60 messages
- one-love_code, 3 days ago, 22 messages
- one-love_best-practices, 5 days ago, 5 messages
- one-love_unexpected, 5 days ago, 24 messages
- one-love_api, 6 days ago, 16 messages
Hi ๐
Can you share an API request ID for this error? It will start with req_
Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
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
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
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?
I think so but take a look at the code snippet here: https://docs.stripe.com/payments/checkout/customization?lang=php#customize-text-policies. It's got more parameters than you are trying to use but should offer a good example of the syntax required
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
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
one sec. getting it.
req_PaQVno0vNsf2Mk
unknown parameter: shipping_address_collection[0]
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
one_checkout-shipping
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
yep feel free to ask anything!
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.
okay so what's the problem exactly?
I did but you didn't really say much, just "docs are bad" and "need help"
like what exactly is the provlem?
how do I extract the info from the payment intent?
what have you tried?
Sure but you haven't really said your exact question about this problem
right now what you have is correct, so what exactly have you tried that isn't working?
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.
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.
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?
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.
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.
$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
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
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.
Thank you.
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
Received unknown event type checkout.session.completed. There was no payment_intent.succeeded event.
Why was there no payment intent event
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
I didnt change anything. The only thing changed was the shipping address fields we addes.
added
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
Do I extract information the same way as the payment intent. $checkoutSession = $event->data->object;
$id = $checkoutSession->id;
that will print the Checkout Session id cs_test_123yes. And that object has all its properties in the API Reference: https://docs.stripe.com/api/checkout/sessions/object
Thank you.