# Repository guide

This is a PHP 8.2+ / Laravel 12 application for ShopAds. Browser routes are in
`routes/web.php`; upstream API integration is in `app/Services/MyadsApiClient.php`.
Blade templates are in `resources/views`; frontend assets use Vite.

## Read only what the task needs

- Start with `git status --short` and a targeted `rg` search for the route, method,
  or UI text. Preserve unrelated user changes.
- For API gateway controller work, read `app/Http/Controllers/APIGW/AGENTS.md`
  first. It maps features to small implementation files and relevant tests.
- For campaign menu pages and WABA templates, read
  `app/Http/Controllers/CampaignMenu/AGENTS.md` before the matching concern.
- For upstream API calls, read `app/Services/MyadsApi/AGENTS.md` before the
  matching endpoint or transport concern. `MyadsApiClient.php` holds composition
  and constructor configuration only.
- Read the matching method and its called helpers instead of dumping entire
  controllers, services, view directories, or test suites.
- Keep changes scoped to the requested feature. Put new gateway behavior in the
  appropriate concern; keep the route entry point small. Update the feature map
  when moving methods or adding files.

## Behavior and verification

- Preserve route names, public action signatures, validation, response shapes,
  session keys, and upstream payload field names during structural refactors.
  Some upstream field spellings (for example `recepientTotal`) are intentional.
- The API pays for campaigns: membership quota when the merchant's active
  membership covers the recipients, else main balance (Saldo Utama). Keep API
  balance rejection handling, scheduling checks, consent, and duplicate-send
  protection intact. Forms still put `useBonusBalance: 0` in the payload, but the
  API ignores it: the `/add` routes the portal calls send `"1"` to DigitalCore
  (`/add_main` would send `"0"`). MMS/RCS must not select package payment.
  Campaign QRIS routes and payment polling have been removed; merchants join a
  membership offer from the dashboard (`/dashboard/membership/join`, paid from
  Saldo Utama). The only QRIS is the paket order on the dashboard's Paket Iklan cards
  (`/paket/{package}/buy`, `/paket/orders/{order}`), a DUMMY for now whose
  Complete/Cancelled buttons stand in for the payment provider; it renders only
  when the merchant has a paket offer or a pending order.
- A failed campaign submission must not be resubmitted automatically. The API
  resends campaigns DigitalCore never received (status `NOT_SENT`) and refunds
  rejected ones; timeouts stay `UNKNOWN` until an admin checks DigitalCore.
  Use mocked HTTP in tests, not live campaign submissions.
- Run relevant tests with `php artisan test --filter=TestClassName`; use
  `php artisan test --compact` for changes spanning multiple features.
- Format changed PHP files only: `php vendor/bin/pint path/to/changed/file.php`.
- For frontend changes, run `npm run build` as appropriate. PHP-only extraction
  does not require rebuilding frontend assets.
- Do not print or commit `.env` values, credentials, or session tokens.
