// One-off script: register Stripe Tax for all US states + DC.
// Run with: STRIPE_SECRET_KEY=sk_... node scripts/register-us-states-tax.js
//
// WARNING: only register in states where you have an actual tax obligation/nexus.
// In live mode, several states charge real registration fees (see
// https://docs.stripe.com/tax/use-stripe-to-register#pricing-and-state-fees).
// Run against a test-mode key first to verify.

const Stripe = require('stripe');
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY);

const US_STATES = [
  'AL', 'AK', 'AZ', 'AR', 'CA', 'CO', 'CT', 'DE', 'DC', 'FL', 'GA',
  'HI', 'ID', 'IL', 'IN', 'IA', 'KS', 'KY', 'LA', 'ME', 'MD', 'MA',
  'MI', 'MN', 'MS', 'MO', 'MT', 'NE', 'NV', 'NH', 'NJ', 'NM', 'NY',
  'NC', 'ND', 'OH', 'OK', 'OR', 'PA', 'RI', 'SC', 'SD', 'TN', 'TX',
  'UT', 'VT', 'VA', 'WA', 'WV', 'WI', 'WY',
];

async function main() {
  for (const state of US_STATES) {
    try {
      const registration = await stripe.tax.registrations.create({
        country: 'US',
        country_options: {
          us: {
            type: 'state_sales_tax',
            state,
          },
        },
        active_from: 'now',
      });
      console.log(`OK   ${state} -> ${registration.id}`);
    } catch (err) {
      console.error(`FAIL ${state} -> ${err.message}`);
    }
  }
}

main();
