alpha_full/admin/extensions/profils/testProfils.php
2026-04-06 22:58:51 +02:00

49 lines
10 KiB
PHP
Executable File

<?php
$nomFicAppelant = basename(__FILE__);
// -----------------------------------------------------
// HTML
// -----------------------------------------------------
echo '<!DOCTYPE html>';
echo '<html>';
echo '<head>';
echo '</head>';
// -----------------------------------------------------
// Body
// -----------------------------------------------------
echo '<body >';
$json='
{ "object": "list", "data": [ {"id": "sub_1K25OjGPrFXOX5m02mMI2u9a", "object": "subscription", "application_fee_percent": null, "automatic_tax": {"enabled": false }, "billing_cycle_anchor": 1638413509, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1638413509, "current_period_end": 1641091909, "current_period_start": 1638413509, "customer": "cus_KhUNyRfZ44VgZh", "days_until_due": null, "default_payment_method": "pm_1K25OiGPrFXOX5m0PqqRMf7a", "default_source": null, "default_tax_rates": [], "discount": null, "ended_at": null, "items": {"object": "list", "data": [ {"id": "si_KhUNZBlZi4cyJM", "object": "subscription_item", "billing_thresholds": null, "created": 1638413509, "metadata": [], "plan": {"id": "price_1K1vRDGPrFXOX5m02nxEv7rY", "object": "plan", "active": true, "aggregate_usage": null, "amount": 500, "amount_decimal": "500", "billing_scheme": "per_unit", "created": 1638375223, "currency": "eur", "interval": "month", "interval_count": 1, "livemode": false, "metadata": [], "nickname": "Abonnement mensuel profil interm\u00e9diaire", "product": "prod_KhK5nv9BFyDOsi", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "price": {"id": "price_1K1vRDGPrFXOX5m02nxEv7rY", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1638375223, "currency": "eur", "livemode": false, "lookup_key": null, "metadata": [], "nickname": "Abonnement mensuel profil interm\u00e9diaire", "product": "prod_KhK5nv9BFyDOsi", "recurring": {"aggregate_usage": null, "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 500, "unit_amount_decimal": "500" }, "quantity": 1, "subscription": "sub_1K25OjGPrFXOX5m02mMI2u9a", "tax_rates": [] } ], "has_more": false, "total_count": 1, "url": "\/v1\/subscription_items?subscription=sub_1K25OjGPrFXOX5m02mMI2u9a" }, "latest_invoice": "in_1K25OjGPrFXOX5m0OqUcX4v6", "livemode": false, "metadata": [], "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": {"payment_method_options": null, "payment_method_types": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "plan": {"id": "price_1K1vRDGPrFXOX5m02nxEv7rY", "object": "plan", "active": true, "aggregate_usage": null, "amount": 500, "amount_decimal": "500", "billing_scheme": "per_unit", "created": 1638375223, "currency": "eur", "interval": "month", "interval_count": 1, "livemode": false, "metadata": [], "nickname": "Abonnement mensuel profil interm\u00e9diaire", "product": "prod_KhK5nv9BFyDOsi", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "quantity": 1, "schedule": null, "start_date": 1638413509, "status": "active", "transfer_data": null, "trial_end": null, "trial_start": null }, {"id": "sub_1K25NoGPrFXOX5m0B55Nx6Ql", "object": "subscription", "application_fee_percent": null, "automatic_tax": {"enabled": false }, "billing_cycle_anchor": 1638413452, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1638413452, "current_period_end": 1641091852, "current_period_start": 1638413452, "customer": "cus_KhUMbHjCSpRb3E", "days_until_due": null, "default_payment_method": "pm_1K25NoGPrFXOX5m0a9bc8H5o", "default_source": null, "default_tax_rates": [], "discount": null, "ended_at": null, "items": {"object": "list", "data": [ {"id": "si_KhUMombCcUP8Ow", "object": "subscription_item", "billing_thresholds": null, "created": 1638413453, "metadata": [], "plan": {"id": "price_1K1vRDGPrFXOX5m02nxEv7rY", "object": "plan", "active": true, "aggregate_usage": null, "amount": 500, "amount_decimal": "500", "billing_scheme": "per_unit", "created": 1638375223, "currency": "eur", "interval": "month", "interval_count": 1, "livemode": false, "metadata": [], "nickname": "Abonnement mensuel profil interm\u00e9diaire", "product": "prod_KhK5nv9BFyDOsi", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "price": {"id": "price_1K1vRDGPrFXOX5m02nxEv7rY", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1638375223, "currency": "eur", "livemode": false, "lookup_key": null, "metadata": [], "nickname": "Abonnement mensuel profil interm\u00e9diaire", "product": "prod_KhK5nv9BFyDOsi", "recurring": {"aggregate_usage": null, "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 500, "unit_amount_decimal": "500" }, "quantity": 1, "subscription": "sub_1K25NoGPrFXOX5m0B55Nx6Ql", "tax_rates": [] } ], "has_more": false, "total_count": 1, "url": "\/v1\/subscription_items?subscription=sub_1K25NoGPrFXOX5m0B55Nx6Ql" }, "latest_invoice": "in_1K25NpGPrFXOX5m06uScAGAd", "livemode": false, "metadata": [], "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": {"payment_method_options": null, "payment_method_types": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "plan": {"id": "price_1K1vRDGPrFXOX5m02nxEv7rY", "object": "plan", "active": true, "aggregate_usage": null, "amount": 500, "amount_decimal": "500", "billing_scheme": "per_unit", "created": 1638375223, "currency": "eur", "interval": "month", "interval_count": 1, "livemode": false, "metadata": [], "nickname": "Abonnement mensuel profil interm\u00e9diaire", "product": "prod_KhK5nv9BFyDOsi", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "quantity": 1, "schedule": null, "start_date": 1638413452, "status": "active", "transfer_data": null, "trial_end": null, "trial_start": null }, {"id": "sub_1JzT2XGPrFXOX5m0K0qIHtel", "object": "subscription", "application_fee_percent": null, "automatic_tax": {"enabled": false }, "billing_cycle_anchor": 1637789405, "billing_thresholds": null, "cancel_at": null, "cancel_at_period_end": false, "canceled_at": null, "collection_method": "charge_automatically", "created": 1637789405, "current_period_end": 1640381405, "current_period_start": 1637789405, "customer": "cus_KembIVjArF5Po1", "days_until_due": null, "default_payment_method": "pm_1JzT2WGPrFXOX5m0iEo29KqV", "default_source": null, "default_tax_rates": [], "discount": null, "ended_at": null, "items": {"object": "list", "data": [ {"id": "si_Kemb7MGiWI31ik", "object": "subscription_item", "billing_thresholds": null, "created": 1637789406, "metadata": [], "plan": {"id": "price_1JyZ1YGPrFXOX5m0WAFgkVOs", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1990, "amount_decimal": "1990", "billing_scheme": "per_unit", "created": 1637574080, "currency": "eur", "interval": "month", "interval_count": 1, "livemode": false, "metadata": [], "nickname": null, "product": "prod_Kdqi8JaOGdSsjr", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "price": {"id": "price_1JyZ1YGPrFXOX5m0WAFgkVOs", "object": "price", "active": true, "billing_scheme": "per_unit", "created": 1637574080, "currency": "eur", "livemode": false, "lookup_key": null, "metadata": [], "nickname": null, "product": "prod_Kdqi8JaOGdSsjr", "recurring": {"aggregate_usage": null, "interval": "month", "interval_count": 1, "trial_period_days": null, "usage_type": "licensed" }, "tax_behavior": "unspecified", "tiers_mode": null, "transform_quantity": null, "type": "recurring", "unit_amount": 1990, "unit_amount_decimal": "1990" }, "quantity": 1, "subscription": "sub_1JzT2XGPrFXOX5m0K0qIHtel", "tax_rates": [] } ], "has_more": false, "total_count": 1, "url": "\/v1\/subscription_items?subscription=sub_1JzT2XGPrFXOX5m0K0qIHtel" }, "latest_invoice": "in_1JzT2XGPrFXOX5m0KM1Bpw68", "livemode": false, "metadata": [], "next_pending_invoice_item_invoice": null, "pause_collection": null, "payment_settings": {"payment_method_options": null, "payment_method_types": null }, "pending_invoice_item_interval": null, "pending_setup_intent": null, "pending_update": null, "plan": {"id": "price_1JyZ1YGPrFXOX5m0WAFgkVOs", "object": "plan", "active": true, "aggregate_usage": null, "amount": 1990, "amount_decimal": "1990", "billing_scheme": "per_unit", "created": 1637574080, "currency": "eur", "interval": "month", "interval_count": 1, "livemode": false, "metadata": [], "nickname": null, "product": "prod_Kdqi8JaOGdSsjr", "tiers_mode": null, "transform_usage": null, "trial_period_days": null, "usage_type": "licensed" }, "quantity": 1, "schedule": null, "start_date": 1637789405, "status": "active", "transfer_data": null, "trial_end": null, "trial_start": null } ], "has_more": true, "url": "\/v1\/subscriptions" }
';
$json=str_replace ( 'Stripe\Customer JSON:','', $json);
// echo $json;
$tabResp=json_decode($json,true);
// echo ' <br>tableau => <div><br><pre>'.print_r($tabResp). '<pre></div>';
$stripeObj=$tabResp['object'];
// echo '<br> stripeObj = '.($stripeObj). '<br>';
$stripeData=$tabResp['data'];
// echo '<br> stripeData = <pre>'.print_r($stripeData). '</pre><br>';
for($c=0;$c<count($stripeData);$c++) {
// if (isset($debug[1]) && $debug[1] == '1' ) $debugMsg .='$c=' .$c;
$stripeInfos=$stripeData[$c];
echo '<br> stripeInfos = <pre>'.print_r($stripeInfos). '</pre><br>';
$items=$stripeInfos['items'];
// echo '<br> items = <pre>'.print_r($items). '</pre><br>';
$price=$items['data'][0]['plan']['id'];
echo '<br> price = <pre>'.($price). '</pre><br>';
$nickname=$items['data'][0]['plan']['nickname'];
echo '<br> nickname = <pre>'.($nickname). '</pre><br>';
}
echo '</body >';
echo '</html>';
?>