#allen-checkout-shipping

1 messages · Page 1 of 1 (latest)

mellow islandBOT
earnest niche
#

👋 @gilded holly let's talk here

gilded holly
#

hello

#

I'm creating a Session with PHP StripeClient() and trying to add shipping rates but have not found the documentation showing how to do so. Anyone have a link?

#

??

gilded holly
#

so can I pass the shipping rate id instead of all of those parameters?

#

it should not be so difficult for users to find this information in the documentation

earnest niche
#

I googled "Checkout shipping rate stripe" and it was the first result though

#

But yes you can pass the id right there.

gilded holly
#

I googled "add shipping rate to stripe checkout session and this didn't come up

earnest niche
#

it's the first result for that search for me too, but maybe google knows I search for Stripe a lot

gilded holly
#

I see it as a snippet, but I ignore snippets because Google usually sucks at showing anything useful

#

more than half the time, the snippets section is completely irrelevant

#

I have not been able to get the suggestion from that page to work

#

$session = $stripe->checkout->sessions->create([
'payment_method_types' => ['card'],
'line_items' => $lineItems,
'mode' => 'payment',
'success_url' => 'https://www.merakimade.co/payment_success.php?session_id={CHECKOUT_SESSION_ID}',
'cancel_url' => 'https://www.merakimade.co/payment_cancel.php',
'shipping_address_collection' => array(
'allowed_countries' => ['US'],
),
'shipping_options' => [
[
'shipping_rate_data' => [$_POST['ship_rate'],],
],
],
// 'shipping_rate_data' => [$_POST['ship_rate']],
'customer_creation' => 'always',
'billing_address_collection' => 'required',
'automatic_tax' => ['enabled' => true,],
'metadata' => [
'order_number' => $OrderNumber,
'order_status' => 'placed',
],
]);

#

$_POST['ship_rate'] contains the shipping_rate->id

earnest niche
#

it's either shipping_rate: 'shr_123' or it's shipping_rate_data: [... all the info ...]

gilded holly
#

that doesn't show examples

#

I think this did it

    'shipping_options' => [
        [
        'shipping_rate' => $_POST['ship_rate'],
    ],
],
earnest niche
#

yep that works

gilded holly
#

I think I might be starting to understand the way the documentation is written and what it means but it's been quite a learning curve

earnest niche
#

glad to hear you're making progress

gilded holly
#

thanks. Have a great day