2016-11-27 2 views
0

Моя цель - назначить сумму плана, на который клиент подписал переменную $plan_amount. Я могу получить идентификатор клиента, делая $customer_id = $customer->id;Поиск значения суммы плана полосы от print_r

Я попытался

$plan_amount = $customer->plan->amount; 

, но это не сработало

Когда я var_export($customer); это данные, которые я получаю:

Stripe\Customer::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('id' => 'cus_9da91rn7gLhC2d', 'object' => 'customer', 'account_balance' => 0, 'created' => 1480215961, 'currency' => 'usd', 'default_source' => 'card_19KIzJI8DcpffB1bbUG87DhV', 'delinquent' => false, 'description' => NULL, 'discount' => NULL, 'email' => '[email protected]', 'livemode' => false, 'metadata' => Stripe\AttachedObject::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('user_id' => '129',), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)), 'shipping' => NULL, 'sources' => Stripe\Collection::__set_state(array('_requestParams' => array (), '_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('object' => 'list', 'data' => array (0 => Stripe\Card::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('id' => 'card_19KIzJI8DcpffB1bbUG87DhV', 'object' => 'card', 'address_city' => NULL, 'address_country' => NULL, 'address_line1' => NULL, 'address_line1_check' => NULL, 'address_line2' => NULL, 'address_state' => NULL, 'address_zip' => NULL, 'address_zip_check' => NULL, 'brand' => 'Visa', 'country' => 'US', 'customer' => 'cus_9da91rn7gLhC2d', 'cvc_check' => 'pass', 'dynamic_last4' => NULL, 'exp_month' => 1, 'exp_year' => 2019, 'fingerprint' => '7cCImrkBsKyb8S1A', 'funding' => 'credit', 'last4' => '4242', 'metadata' => Stripe\AttachedObject::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array (), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)), 'name' => '[email protected]', 'tokenization_method' => NULL,), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)),), 'has_more' => false, 'total_count' => 1, 'url' => '/v1/customers/cus_9da91rn7gLhC2d/sources',), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)), 'subscriptions' => Stripe\Collection::__set_state(array('_requestParams' => array (), '_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('object' => 'list', 'data' => array (0 => Stripe\Subscription::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('id' => 'sub_9da9u1VWytIjNq', 'object' => 'subscription', 'application_fee_percent' => NULL, 'cancel_at_period_end' => false, 'canceled_at' => NULL, 'created' => 1480215961, 'current_period_end' => 1482807961, 'current_period_start' => 1480215961, 'customer' => 'cus_9da91rn7gLhC2d', 'discount' => NULL, 'ended_at' => NULL, 'livemode' => false, 'metadata' => Stripe\AttachedObject::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array (), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)), 'plan' => Stripe\Plan::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array ('id' => 'Unlimited', 'object' => 'plan', 'amount' => 1000, 'created' => 1474078670, 'currency' => 'usd', 'interval' => 'month', 'interval_count' => 1, 'livemode' => false, 'metadata' => Stripe\AttachedObject::__set_state(array('_opts' => Stripe\Util\RequestOptions::__set_state(array('headers' => array (), 'apiKey' => 'sk_test_M34wpZquafPJwZBmRjw6nGlf',)), '_values' => array (), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)), 'name' => 'Unlimited', 'statement_descriptor' => 'BEATCART.FM', 'trial_period_days' => NULL,), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)), 'quantity' => 1, 'start' => 1480215961, 'status' => 'active', 'tax_percent' => NULL, 'trial_end' => NULL, 'trial_start' => NULL,), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)),), 'has_more' => false, 'total_count' => 1, 'url' => '/v1/customers/cus_9da91rn7gLhC2d/subscriptions',), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => NULL,)),), '_unsavedValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_transientValues' => Stripe\Util\Set::__set_state(array('_elts' => array (),)), '_retrieveOptions' => array (), '_lastResponse' => Stripe\ApiResponse::__set_state(array('headers' => array ('Server' => 'nginx', 'Date' => 'Sun, 27 Nov 2016 03:06:01 GMT', 'Content-Type' => 'application/json', 'Content-Length' => '2495', 'Connection' => 'keep-alive', 'Access-Control-Allow-Credentials' => 'true', 'Access-Control-Allow-Methods' => 'GET, POST, HEAD, OPTIONS, DELETE', 'Access-Control-Allow-Origin' => '*', 'Access-Control-Max-Age' => '300', 'Cache-Control' => 'no-cache, no-store', 'Request-Id' => 'req_9da94vcYeXgz5w', 'Stripe-Version' => '2016-07-06', 'Strict-Transport-Security' => 'max-age=31556926; includeSubDomains',), 'body' => '{ "id": "cus_9da91rn7gLhC2d", "object": "customer", "account_balance": 0, "created": 1480215961, "currency": "usd", "default_source": "card_19KIzJI8DcpffB1bbUG87DhV", "delinquent": false, "description": null, "discount": null, "email": "[email protected]", "livemode": false, "metadata": { "user_id": "129" }, "shipping": null, "sources": { "object": "list", "data": [ { "id": "card_19KIzJI8DcpffB1bbUG87DhV", "object": "card", "address_city": null, "address_country": null, "address_line1": null, "address_line1_check": null, "address_line2": null, "address_state": null, "address_zip": null, "address_zip_check": null, "brand": "Visa", "country": "US", "customer": "cus_9da91rn7gLhC2d", "cvc_check": "pass", "dynamic_last4": null, "exp_month": 1, "exp_year": 2019, "fingerprint": "7cCImrkBsKyb8S1A", "funding": "credit", "last4": "4242", "metadata": {}, "name": "[email protected]", "tokenization_method": null } ], "has_more": false, "total_count": 1, "url": "/v1/customers/cus_9da91rn7gLhC2d/sources" }, "subscriptions": { "object": "list", "data": [ { "id": "sub_9da9u1VWytIjNq", "object": "subscription", "application_fee_percent": null, "cancel_at_period_end": false, "canceled_at": null, "created": 1480215961, "current_period_end": 1482807961, "current_period_start": 1480215961, "customer": "cus_9da91rn7gLhC2d", "discount": null, "ended_at": null, "livemode": false, "metadata": {}, "plan": { "id": "Unlimited", "object": "plan", "amount": 1000, "created": 1474078670, "currency": "usd", "interval": "month", "interval_count": 1, "livemode": false, "metadata": {}, "name": "Unlimited", "statement_descriptor": "BEATCART.FM", "trial_period_days": null }, "quantity": 1, "start": 1480215961, "status": "active", "tax_percent": null, "trial_end": null, "trial_start": null } ], "has_more": false, "total_count": 1, "url": "/v1/customers/cus_9da91rn7gLhC2d/subscriptions" } } ', 'json' => array ('id' => 'cus_9da91rn7gLhC2d', 'object' => 'customer', 'account_balance' => 0, 'created' => 1480215961, 'currency' => 'usd', 'default_source' => 'card_19KIzJI8DcpffB1bbUG87DhV', 'delinquent' => false, 'description' => NULL, 'discount' => NULL, 'email' => '[email protected]', 'livemode' => false, 'metadata' => array ('user_id' => '129',), 'shipping' => NULL, 'sources' => array ('object' => 'list', 'data' => array (0 => array ('id' => 'card_19KIzJI8DcpffB1bbUG87DhV', 'object' => 'card', 'address_city' => NULL, 'address_country' => NULL, 'address_line1' => NULL, 'address_line1_check' => NULL, 'address_line2' => NULL, 'address_state' => NULL, 'address_zip' => NULL, 'address_zip_check' => NULL, 'brand' => 'Visa', 'country' => 'US', 'customer' => 'cus_9da91rn7gLhC2d', 'cvc_check' => 'pass', 'dynamic_last4' => NULL, 'exp_month' => 1, 'exp_year' => 2019, 'fingerprint' => '7cCImrkBsKyb8S1A', 'funding' => 'credit', 'last4' => '4242', 'metadata' => array (), 'name' => '[email protected]', 'tokenization_method' => NULL,),), 'has_more' => false, 'total_count' => 1, 'url' => '/v1/customers/cus_9da91rn7gLhC2d/sources',), 'subscriptions' => array ('object' => 'list', 'data' => array (0 => array ('id' => 'sub_9da9u1VWytIjNq', 'object' => 'subscription', 'application_fee_percent' => NULL, 'cancel_at_period_end' => false, 'canceled_at' => NULL, 'created' => 1480215961, 'current_period_end' => 1482807961, 'current_period_start' => 1480215961, 'customer' => 'cus_9da91rn7gLhC2d', 'discount' => NULL, 'ended_at' => NULL, 'livemode' => false, 'metadata' => array (), 'plan' => array ('id' => 'Unlimited', 'object' => 'plan', 'amount' => 1000, 'created' => 1474078670, 'currency' => 'usd', 'interval' => 'month', 'interval_count' => 1, 'livemode' => false, 'metadata' => array (), 'name' => 'Unlimited', 'statement_descriptor' => 'BEATCART.FM', 'trial_period_days' => NULL,), 'quantity' => 1, 'start' => 1480215961, 'status' => 'active', 'tax_percent' => NULL, 'trial_end' => NULL, 'trial_start' => NULL,),), 'has_more' => false, 'total_count' => 1, 'url' => '/v1/customers/cus_9da91rn7gLhC2d/subscriptions',),), 'code' => 200,)),)) 
+0

** 1) ** Вы используете 'stripe' помимо стандартного' php'? ** 2) ** Не используйте копию и вставляйте гигантский массив, который находится рядом с бесполезным в этой форме. ** 3) ** Является ли клиент 'id' где-то в классе' variable'' $ customer'? – Nytrix

+0

Эй, Нитрикс, да, я полагал, что кто-то, кто знал больше о рассечении данных, может знать, как получить доступ к сумме плана, посмотрев на массив print_r. – Jeff

+0

Можете ли вы показать 'var_export ($ customer)' вместо 'print_r' –

ответ

0

Я нашел более простое решение моей исходной проблемы, хотя оно прямо не отвечает на этот вопрос.

Поскольку данные были размещены я могу хранить сумму плана в скрытом ввода и извлечения его из почтовых данных

Внутри Форма первой страницы:

<input type="hidden" value="999" name="planamount"> 

Внутри страницы действия :

$amount = $_POST['planamount']; 
Смежные вопросы