#allen-checkout-shipping
1 messages · Page 1 of 1 (latest)
👋 @gilded holly let's talk here
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?
??
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
I googled "Checkout shipping rate stripe" and it was the first result though
But yes you can pass the id right there.
I googled "add shipping rate to stripe checkout session and this didn't come up
it's the first result for that search for me too, but maybe google knows I search for Stripe a lot
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
it's either shipping_rate: 'shr_123' or it's shipping_rate_data: [... all the info ...]
that doesn't show examples
I think this did it
'shipping_options' => [
[
'shipping_rate' => $_POST['ship_rate'],
],
],
yep that works
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
glad to hear you're making progress
thanks. Have a great day