#giuliano-invoice-subscription
1 messages ยท Page 1 of 1 (latest)
Hello
Yeah that's correct
So you would need to loop over the items in the array to grab each value
I'm testing with $plan = $event->data->object->lines->data->plan; and it doesn't work, but when I leave it until $plan = $event->data->object->lines->data; it works
$billing = $event->data->object->billing_reason;
if (strval($billing) === 'subscription_create'){
$id_sub = $event->data->object->subscription;
$customer = $event->data->object->customer;
$plan = $event->data->object->lines->data->plan;
file_put_contents('stripe_webhook.txt', $plan, FILE_APPEND);
$amount = $event->data->object->amount;
/*$insertsub = $iN->iN_InsertNewSubscriber($id_sub, $amount);*/
}```
my code
Yes becuase data is an array as you already stated
So you need to write more code to loop over the different objects in the array
๐
@royal flame also the Plan API was deprecated in 2018. You really should use the Price API instead
giuliano-invoice-subscription
Price API ?
ok, thanks
I'm having difficulty accessing the array in PHP, I'm trying data[1] and it doesn't work either
All good. Step 1: debug ๐
Add clear logs to your code to log each part of the object to understand what's missing!
@royal flame did you make progress?
yeah
I just created a variable and then used simple json
$object = $event->data->object;
$plan = $object['lines']['data'][0]['price'];
I copied from here
@torn umbra
a question,
when a subscription is created it shows sub_, cus_ and plan_
Every time this subscription is renewed, will it have the same value in sub_ cus_ and plan_?
The Event you are parsing here is not a Subscription Event right? It's an Invoice Event, it describes an Invoice object https://stripe.com/docs/api/invoices/object