Получение элемента subscription_id из файла JSON

теперь у меня есть функция, и я хотел бы вычесть subscription_id из кода JSON, который он передает на сайт Chargify, но я не уверен, как это сделать.

Это основная функция

public function reactivateSubscription2()
{
$chargify = new \Crucial\Service\Chargify([
'hostname'   =>  //,
'api_key'    =>  //,
'shared_key' =>  //
]);

$subscription = $chargify->subscription()->reactivate(1234); // 1234 is the ID number

return redirect()->action('WebhookController@postChargify')->with('account', [ [ 'msg' => 'Thank you for your activation, please refresh this page after 30 seconds, thank you.', 'type' => 'success', 'icon' => 'fa-check']]);

когда у нас есть

->reactivate(1234); // 1234 is the ID number

Я просто хочу получить идентификатор подписки для пользователя, когда пользователь вошел в систему и выполнить команду. Вот код JSON.

{"subscription"=>
{"id"=>17674824,
"state"=>"canceled",
"trial_started_at"=>Tue, 09 May 2017 15:01:50 EDT -04:00,
"trial_ended_at"=>Thu, 08 Jun 2017 15:01:50 EDT -04:00,
"activated_at"=>Thu, 04 May 2017 15:09:04 EDT -04:00,
"created_at"=>Wed, 03 May 2017 14:18:19 EDT -04:00,
"updated_at"=>Thu, 11 May 2017 16:08:57 EDT -04:00,
"expires_at"=>nil,
"balance_in_cents"=>0,
"current_period_ends_at"=>Sun, 11 Jun 2017 16:08:32 EDT -04:00,
"next_assessment_at"=>Sun, 11 Jun 2017 16:08:32 EDT -04:00,
"canceled_at"=>Thu, 11 May 2017 16:08:53 EDT -04:00,
"cancellation_message"=>nil,
"next_product_id"=>nil,
"cancel_at_end_of_period"=>false,
"payment_collection_method"=>"automatic",
"snap_day"=>nil,
"cancellation_method"=>"merchant_ui",
"current_period_started_at"=>Thu, 11 May 2017 16:08:32 EDT -04:00,
"previous_state"=>"active",
"signup_payment_id"=>184515899,
"signup_revenue"=>"0.00",
"delayed_cancel_at"=>nil,
"coupon_code"=>nil,
"total_revenue_in_cents"=>95990,
"product_price_in_cents"=>999,
"product_version_number"=>1,
"payment_type"=>"credit_card",
"referral_code"=>"8gx4bk",
"coupon_use_count"=>nil,
"coupon_uses_allowed"=>nil,
"reason_code"=>"CH:Unknown",
"automatically_resume_at"=>nil,
"customer"=>
{"id"=>17209166,
"first_name"=>"Zhiyu",
"last_name"=>"Pu",
"organization"=>nil,
"email"=>"georgepuww45@gmail.com",
"created_at"=>Wed, 03 May 2017 14:18:19 EDT -04:00,
"updated_at"=>Thu, 04 May 2017 15:26:07 EDT -04:00,
"reference"=>"georgepuww45@gmail.com",
"address"=>nil,
"address_2"=>nil,
"city"=>nil,
"state"=>nil,
"zip"=>nil,
"country"=>"CA",
"phone"=>nil,
"portal_invite_last_sent_at"=>nil,
"portal_invite_last_accepted_at"=>nil,
"verified"=>false,
"portal_customer_created_at"=>nil,
"cc_emails"=>nil,
"tax_exempt"=>false},
"product"=>
{"id"=>3889616,
"name"=>"Xert Premium Monthly",
"handle"=>"prm-mth",
"description"=>"",
"accounting_code"=>"",
"request_credit_card"=>true,
"expiration_interval"=>nil,
"expiration_interval_unit"=>"never",
"created_at"=>Wed, 10 Aug 2016 00:29:41 EDT -04:00,
"updated_at"=>Wed, 10 Aug 2016 00:29:41 EDT -04:00,
"price_in_cents"=>999,
"interval"=>1,
"interval_unit"=>"month",
"initial_charge_in_cents"=>nil,
"trial_price_in_cents"=>nil,
"trial_interval"=>nil,
"trial_interval_unit"=>"day",
"archived_at"=>nil,
"require_credit_card"=>true,
"return_params"=>"",
"taxable"=>true,
"update_return_url"=>"",
"initial_charge_after_trial"=>true,
"version_number"=>1,
"update_return_params"=>"",
"product_family"=>
{"id"=>588123,
"name"=>"Billing Plans",
"description"=>nil,
"handle"=>"baron-biosystems-billing-plans",
"accounting_code"=>nil},
"public_signup_pages"=>[]},
"credit_card"=>
{"id"=>11910433,
"first_name"=>"George",
"last_name"=>"Pu",
"masked_card_number"=>"XXXX-XXXX-XXXX-1111",
"card_type"=>"visa",
"expiration_month"=>11,
"expiration_year"=>2020,
"customer_id"=>17209166,
"current_vault"=>"bogus",
"vault_token"=>"1",
"billing_address"=>"",
"billing_city"=>"",
"billing_state"=>"",
"billing_zip"=>"",
"billing_country"=>"CA",
"customer_vault_token"=>nil,
"billing_address_2"=>nil,
"payment_type"=>"credit_card"}},
"site"=>{"id"=>, "subdomain"=>""},
"event_id"=>}

0

Решение

Задача ещё не решена.

Другие решения

Других решений пока нет …