Set Up Multi-Entity Operations (BR/US)
MIDDAG operates as two legal entities: MIDDAG BR (Brazil) and MIDDAG GLOBAL (US LLC). This recipe configures both entities, connects Stripe accounts and HubSpot instances per entity, sets up tax rules, and tests with an order routed to each entity.
Prerequisites
- WordPress admin access with MIDDAG Account plugin installed.
- Two Stripe accounts: one for MIDDAG BR (BRL), one for MIDDAG GLOBAL (USD).
- Two HubSpot portals (if using HubSpot integration): one for BR, one for GLOBAL.
- ISSNet digital certificate for NFSe issuance (BR entity only).
Steps
Part A: Configure entity settings
Step 1. Go to MIDDAG Account > Settings > Entities in the admin sidebar.
Step 2. You will see two entity cards: MIDDAG BR and MIDDAG GLOBAL. Click Edit on MIDDAG BR.
Step 3. Fill in the MIDDAG BR entity details:
- Legal name -- the registered company name in Brazil.
- Tax ID (CNPJ) -- the Brazilian company tax identifier.
- Address -- registered business address in Brasilia/DF.
- Currency -- BRL (Brazilian Real).
- Jurisdiction -- Brazil.
Step 4. Click Save. Then click Edit on MIDDAG GLOBAL.
Step 5. Fill in the MIDDAG GLOBAL entity details:
- Legal name -- the registered LLC name in the US.
- Tax ID (EIN) -- the US Employer Identification Number.
- Address -- registered business address in the US.
- Currency -- USD (US Dollar).
- Jurisdiction -- United States.
Step 6. Click Save.
Part B: Connect Stripe accounts
Step 7. Go to MIDDAG Account > Settings > Stripe.
Step 8. Under MIDDAG BR Stripe Account:
- Enter the API Secret Key for the BR Stripe account.
- Enter the Publishable Key for the BR Stripe account.
- Enter the Webhook Signing Secret for the BR account.
- The webhook endpoint is:
{your-site}/wp-json/middag-account/v1/webhooks/stripe/br
Step 9. Under MIDDAG GLOBAL Stripe Account:
- Enter the API Secret Key for the GLOBAL Stripe account.
- Enter the Publishable Key for the GLOBAL Stripe account.
- Enter the Webhook Signing Secret for the GLOBAL account.
- The webhook endpoint is:
{your-site}/wp-json/middag-account/v1/webhooks/stripe/llc
Step 10. Click Save. The system validates both key pairs by making a test API call.
Step 11. In each Stripe dashboard, configure the webhook endpoint to send these events: payment_intent.succeeded, payment_intent.payment_failed, invoice.created, invoice.paid, invoice.payment_failed, invoice.finalized, customer.subscription.updated, customer.subscription.deleted.
Part C: Connect HubSpot instances
Step 12. Go to MIDDAG Account > Settings > HubSpot.
Step 13. Under MIDDAG BR HubSpot Portal:
- Enter the Portal ID for the BR HubSpot instance.
- Enter the API Key or connect via OAuth.
- Configure the webhook secret for incoming quote and deal events.
Step 14. Under MIDDAG GLOBAL HubSpot Portal:
- Enter the Portal ID for the GLOBAL HubSpot instance.
- Enter the API Key or connect via OAuth.
- Configure the webhook secret.
Step 15. Click Save.
Part D: Configure tax rules per entity
Step 16. Go to MIDDAG Account > Settings > Tax.
Step 17. Under MIDDAG BR Tax Rules:
- Enable NFSe Issuance (toggle on).
- Enter the ISSNet Web Service URL for Brasilia/DF.
- Upload the Digital Certificate (A1 format,
.pfxfile) and enter the certificate password. - Set the Municipal Tax Code (CNAE) for the primary service activity.
- Set the ISS Rate (typically 2% to 5% depending on the municipality).
Step 18. Under MIDDAG GLOBAL Tax Rules:
- NFSe is not applicable -- leave NFSe Issuance disabled.
- Configure US tax settings if applicable (state sales tax, etc.) or mark as "No tax invoice required."
Step 19. Click Save.
Part E: Test with a BR order
Step 20. Create a test Organization with billing entity set to MIDDAG BR. See Onboard an Organization.
Step 21. Create a quote for this Organization with a BRL-priced product. See Issue a Quote.
Step 22. Accept the quote and complete payment using a test card (or Pix in sandbox mode).
Step 23. Verify:
- The payment was processed by the BR Stripe account (check in Stripe dashboard under the BR account).
- An invoice was synced from the BR Stripe account.
- An NFSe was issued via ISSNet (check MIDDAG Account > Tax Invoices).
- The entitlement was created and linked to the BR Organization.
Part F: Test with a GLOBAL order
Step 24. Create a second test Organization with billing entity set to MIDDAG GLOBAL.
Step 25. Create a quote for this Organization with a USD-priced product.
Step 26. Accept the quote and pay with a test card.
Step 27. Verify:
- The payment was processed by the GLOBAL Stripe account (check in Stripe dashboard under the GLOBAL account).
- An invoice was synced from the GLOBAL Stripe account.
- No NFSe was issued (GLOBAL transactions do not trigger NFSe).
- The entitlement was created and linked to the GLOBAL Organization.
Part G: Verify entity routing
Step 28. Go to MIDDAG Account > Invoices. The unified invoice list should show entries from both entities with a visual indicator:
- Invoices from MIDDAG BR show the BR entity label.
- Invoices from MIDDAG GLOBAL show the GLOBAL entity label.
Step 29. Verify the entity resolution chain works correctly. The system uses this priority:
- Organization's explicit
billing_entity(most reliable). - Tax ID type -- CNPJ routes to BR; EIN/VAT routes to GLOBAL.
- Product entity tag.
- Currency fallback -- BRL implies BR, USD implies GLOBAL.
- Admin manual override.
Step 30. Test an edge case: create an Organization without a billing entity set. Create a quote and observe which entity the system selects based on the resolution chain.
Expected result
- Both entities are configured with separate Stripe accounts, HubSpot portals, and tax rules.
- BR orders are processed through the BR Stripe account with NFSe issued via ISSNet.
- GLOBAL orders are processed through the GLOBAL Stripe account with no NFSe.
- The admin sees a unified view with entity indicators across invoices, quotes, and entitlements.
- Entity routing works correctly based on the Organization's billing entity setting.
Further reading
- Multi-Entity Operations -- how entity routing works in detail.
- Billing and Finance -- financial data flow across entities.
- Generate an Invoice -- invoice and NFSe generation per entity.