Skip to main content
added additional information
Source Link
jsherk
  • 6.5k
  • 9
  • 62
  • 90

I could not get ['expand' => ['line_items']] to work, but I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItems call in PHP (other languages use listLineItems or list_line_items calls).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items

EDIT: I have resolved the issue with 'expand line items'...

All the Stripe docs now refer to the newer interface method, but the old interface method is still available. However when using the old interface method, there were some quirks in how certain requests are made. Below is the correct way, in PHP, to make these calls using the old interface method.

// Setup for old interface method. \Stripe\Stripe::setApiKey('stripe_api_secret_key'); // Expand line_items with retrieve checkout_session object. Note the poistion of square brackets and inclusion of 'id' to make this call work. $get_line_items = \Stripe\Checkout\Session::retrieve(['id'=>'cs_test_123','expand'=>['line_items'], ]); // Retrieve all line_items object. Note: check that your stripe-sdk-php version is new enough to support the allLineItems call. $get_line_items = \Stripe\Checkout\Session::allLineItems('cs_test_123'); 

I could not get ['expand' => ['line_items']] to work, but I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItems call in PHP (other languages use listLineItems or list_line_items calls).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items

I could not get ['expand' => ['line_items']] to work, but I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItems call in PHP (other languages use listLineItems or list_line_items calls).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items

EDIT: I have resolved the issue with 'expand line items'...

All the Stripe docs now refer to the newer interface method, but the old interface method is still available. However when using the old interface method, there were some quirks in how certain requests are made. Below is the correct way, in PHP, to make these calls using the old interface method.

// Setup for old interface method. \Stripe\Stripe::setApiKey('stripe_api_secret_key'); // Expand line_items with retrieve checkout_session object. Note the poistion of square brackets and inclusion of 'id' to make this call work. $get_line_items = \Stripe\Checkout\Session::retrieve(['id'=>'cs_test_123','expand'=>['line_items'], ]); // Retrieve all line_items object. Note: check that your stripe-sdk-php version is new enough to support the allLineItems call. $get_line_items = \Stripe\Checkout\Session::allLineItems('cs_test_123'); 
added 12 characters in body
Source Link
jsherk
  • 6.5k
  • 9
  • 62
  • 90

I could not get ['expand' => ['line_items']] to work, but I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItemsallLineItems call in PHP (other languages use listLineItemslistLineItems or list_line_itemslist_line_items calls).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items

I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItems call in PHP (other languages use listLineItems or list_line_items).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items

I could not get ['expand' => ['line_items']] to work, but I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItems call in PHP (other languages use listLineItems or list_line_items calls).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items

Source Link
jsherk
  • 6.5k
  • 9
  • 62
  • 90

I was able to retrieve the products that a customer purchased in a checkout_session using the allLineItems call in PHP (other languages use listLineItems or list_line_items).

The Stripe API docs are here for Retrieve a Checkout Session's line items:

https://stripe.com/docs/api/checkout/sessions/line_items