---
name: automation-app-feature
description: Tanzania USSD automation app API — what was built and where
metadata:
  type: project
---

Implemented the Tanzania USSD Payment Automation backend API on branch `automation-app-apis`.

**New files:**
- `database/migrations/2026_06_16_000000_create_automation_devices_table.php`
- `database/migrations/2026_06_16_000100_add_ussd_config_to_merchant_accounts.php`
- `database/migrations/2026_06_16_000200_add_automation_fields_to_transactions.php`
- `app/Models/AutomationDevice.php`
- `app/Http/Middleware/EnsureAutomationDeviceAuthenticated.php` — alias: `automation.device`
- `app/Http/Controllers/AutomationApp/AutomationAppController.php`
- `resources/views/automation-devices/index.blade.php` — admin list with approve/revoke
- `resources/views/automation-devices/show.blade.php` — device detail + command panel

**Modified files:**
- `app/Models/MerchantAccount.php` — added USSD config fields to fillable/casts
- `app/Http/Controllers/AdminController.php` — added 7 automation device admin methods + `providersUpdateUssd()`
- `app/Http/Kernel.php` — registered `automation.device` middleware alias
- `routes/api.php` — added `POST /api/v1/automation-app/register` (public) + 3 authenticated endpoints
- `routes/admin.php` — added 7 automation device admin routes + `PUT providers/{uuid}/ussd`
- `resources/views/providers/index.blade.php` — added USSD config section to provider form
- `resources/views/parts/sidebar.blade.php` — added Automation Devices nav link

**Transaction matching logic:** Automation devices are matched to transactions via `network_operator` — the device's `network_operator` must match the `MerchantAccount.automation_operator` field. Transactions need `automation_status = 'pending'` and `receiver_description` matching the provider name.

**Why:** Run automated USSD payment sessions on dedicated SIM-farm phones for Tanzania mobile money operators (Vodacom, Tigo, Airtel, Halotel).
