PHP student here using json for the first time. Stripe is sending data using Json and I am trying to set specific objects to my PHP variables. For example, how would I set a variable to the "5000" given from "subscriptions" -> "amount" in this Json result:
object: "customer",
created: 1410050969,
id: cus_4jMblEOo2y84j6,
livemode: false,
description: "[email protected]",
email: "[email protected]",
delinquent: false,
metadata:
{}
subscriptions::
{
object: "list"
total_count: 1
has_more: false
url: "/v1/customers/cus_4jMblEOo2y84j6/subscriptions"
data:
[
{
id: sub_4jMbSoTXxUBHd0
plan:
{
interval: "year",
name: "Website Hosting",
created: 1409981699,
amount: 5000,
currency: "usd",
id: webhosting,
object: "plan",
livemode: false,
interval_count: 1,
trial_period_days: null,
metadata:
{},
statement_description: null
},
count:1
}
My best failed attempts:
$amount = customer->subscriptions->data->plan->amount;
$amount = $event_json->customer->subscriptions->data->plan->amount;
$amount = subscriptions->data->plan->amount;
$amount = $event_json->subscriptions->data->plan->amount;
Any ideas or general json/php references that would help in this case are greatly appreciated!