From 13631595a75be25c57a1d9c4149e631f0981f4ea Mon Sep 17 00:00:00 2001 From: Graham McIntire Date: Fri, 6 Mar 2026 11:02:48 -0600 Subject: [PATCH] fix: handle spaces in JSON when extracting Stripe IDs - Update grep patterns to match JSON with spaces after colons - Fixes false 'Error creating meter' message when meter created successfully - Applies to meter ID and price ID extraction --- setup_stripe_production.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/setup_stripe_production.sh b/setup_stripe_production.sh index 87048902..e0a86211 100755 --- a/setup_stripe_production.sh +++ b/setup_stripe_production.sh @@ -51,7 +51,7 @@ EXISTING_METERS=$(curl -s https://api.stripe.com/v1/billing/meters \ -u "${STRIPE_KEY}:" \ -H "Stripe-Version: 2024-11-20.acacia") -METER_ID=$(echo "$EXISTING_METERS" | grep -o '"event_name":"devices_monitored"' -B 20 | grep -o '"id":"mtr_[^"]*"' | head -1 | cut -d'"' -f4) +METER_ID=$(echo "$EXISTING_METERS" | grep -o '"event_name": "devices_monitored"' -B 20 | grep -o '"id": "mtr_[^"]*"' | head -1 | cut -d'"' -f4) if [[ -n "$METER_ID" ]]; then echo "✓ Found existing billing meter!" @@ -69,7 +69,7 @@ else -d "default_aggregation[formula]=sum" \ -d "value_settings[event_payload_key]=value") - METER_ID=$(echo "$METER_RESPONSE" | grep -o '"id":"mtr_[^"]*"' | head -1 | cut -d'"' -f4) + METER_ID=$(echo "$METER_RESPONSE" | grep -o '"id": "mtr_[^"]*"' | head -1 | cut -d'"' -f4) if [[ -z "$METER_ID" ]]; then echo "Error creating meter:" @@ -101,7 +101,7 @@ PRICE_RESPONSE=$(curl -s https://api.stripe.com/v1/prices \ -d "unit_amount=100" \ -d "nickname=Per Device Monthly") -PRICE_ID=$(echo "$PRICE_RESPONSE" | grep -o '"id":"price_[^"]*"' | head -1 | cut -d'"' -f4) +PRICE_ID=$(echo "$PRICE_RESPONSE" | grep -o '"id": "price_[^"]*"' | head -1 | cut -d'"' -f4) if [[ -z "$PRICE_ID" ]]; then echo "Error creating price:"