In cases where you need information from a linked object, you can retrieve the linked object in a new call using its ID. However, this approach requires two API requests to access just one value. If you need information from multiple linked objects, each would also require separate requests, which all adds to the latency and complexity of your application.
The API has an Expand feature that allows you to retrieve linked objects in a single call, effectively replacing the object ID with all its properties and values. For example, say you wanted to access details on a customer tied to a given Checkout Session. You would retrieve the Checkout Session and pass the customer property to the expand array, which tells Stripe to include the entire Customer object in the response:
I'm not sure I understand this. Below is a sample checkout session completed object Could someone
please tell me how I would go about constructing a curl request to get the product id for this object?
Checkout Session Completed
{
"id": "evt_1OMOv7JRE4EJdR2wHuSl3V50",
"object": "event",
"api_version": "2023-10-16",
"created": 1702360457,
"data": {
"object": {
"id": "cs_test_a1SGHM8PBa51O75YzSvnZFoiZF9LUqAkwQrYHk6I84FkxZO8K7K2N3mfEv",
"object": "checkout.session",
"after_expiration": null,
"allow_promotion_codes": false,
"amount_subtotal": 1500,
"amount_total": 1500,
"automatic_tax": {
"enabled": false,
"status": null
},
"billing_address_collection": "auto",
"cancel_url": "
https://stripe.com",
"client_reference_id": null,
"client_secret": null,
"consent": null,
"consent_collection": {
"payment_method_reuse_agreement": null,
"promotions": "none",
"terms_of_service": "none"
},
"created": 1702360332,
"currency": "usd",
"currency_conversion": null,
"custom_fields": [
],
"custom_text": {
"after_submit": null,
"shipping_address": null,
"submit": null,
"terms_of_service_acceptance": null
},
"customer": "cus_PAkPVMHG9JMQDo",
"customer_creation": "if_required",
"customer_details": {
"address": {
"city": null,
"country": "US",
"line1": null,
"line2": null,
"postal_code": "90210",
"state": null
},
"email": "
us...@email.com",
"name": "Ron Parker",
"phone": "+123 436-7890",
"tax_exempt": "none",
"tax_ids": [
]
},
"customer_email": null,
"expires_at": 1702446732,
"invoice": "in_1OMOv4JRE4EJdR2wNVuPKlZ9",
"invoice_creation": null,
"livemode": false,
"locale": "auto",
"metadata": {
},
"mode": "subscription",
"payment_intent": null,
"payment_link": "plink_1OMN1XJRE4EJdR2wFDgO2U1f",
"payment_method_collection": "always",
"payment_method_configuration_details": null,
"payment_method_options": null,
"payment_method_types": [
"card"
],
"payment_status": "paid",
"phone_number_collection": {
"enabled": true
},
"recovered_from": null,
"setup_intent": null,
"shipping_address_collection": null,
"shipping_cost": null,
"shipping_details": null,
"shipping_options": [
],
"status": "complete",
"submit_type": "auto",
"subscription": "sub_1OMOv4JRE4EJdR2wl7hoZVSg",
"success_url": "
https://stripe.com",
"total_details": {
"amount_discount": 0,
"amount_shipping": 0,
"amount_tax": 0
},
"ui_mode": "hosted",
"url": null
}
},
"livemode": false,
"pending_webhooks": 1,
"request": {
"id": null,
"idempotency_key": null
},
"type": "checkout.session.completed"
}
Much appreciated!