Closed php4fan closed 1 month ago
I also tried changing the webhook-handling code to this:
$input = $request->getContent(); /// this is php://input
$event = \Stripe\Webhook::constructEvent(
$input,
$_SERVER['HTTP_STRIPE_SIGNATURE'],
'__WH_SECRET__'
);
$data = $event->data->toArray();
$stripe = new StripeClient($this->getPaymentToken());
$session = $stripe->checkout->sessions->retrieve($data['object']['id']);
$items = $session->line_items;
$this->getLogger()->debug("Line items: " . $items->toJSON());
and I get the same error.
@php4fan The line_items
property is what we call includable which means it's not return by default in the API and isn't part of the Event payload. You have to call the Retrieve PaymentLink API and use our Expand feature (docs, video) and explicitly ask for the line_items
property to be returned.
This is more an integration support question so I'd recommend reaching out to our support team via https://support.stripe.com/contact or talking to developers on our Discord server if you have follow up questions.
Describe the bug
I'm not sure whether this is a bug in the
stripe-php
library or in the actual API.To Reproduce
I create a payment link like this:
Then I have a webook for the event
checkout.session.complete
. When I receive such webhook I handle it like this:Expected behavior
This should log the
line_items
in the payment link object, which should correspond to the ones that were set when I created the payment link.NOTE: this bug template has an "expected behavior" section but lacks a "observed behavior" section.
OBSERVED BEHAVIOR
I get the error:
which means the
line_items
property of the payment link is null.Code snippets
No response
OS
all
PHP version
7.4
Library version
latest
API version
2024-04-10
Additional context
No response