# কুঞ্জবন — Phase 4 Payment + Automation

## Included
1. Payment lifecycle:
   - unpaid
   - submitted
   - verified
   - rejected
   - refunded
2. Admin payment verification.
3. Verified digital payment automatically moves `pending/payment_review` order to `confirmed`.
4. Payment screenshot remains accessible from order details.
5. Automation log table.
6. WhatsApp customer notification:
   - Order received
   - Confirmed
   - Shipped
   - Delivered
   - Cancelled
7. Safe click-to-WhatsApp fallback.
8. Optional generic WhatsApp provider endpoint in config.php.
9. Public `api/payment-info.php` for bKash/Nagad/bank display.
10. Admin Automation Logs screen.

## Install
1. Use the Phase 3 package as the base.
2. Import `database/kunjobon_phase4.sql` AFTER Phase 2 + Phase 3 migrations.
3. Put real MySQL credentials in `config/config.php`.
4. Put real payment account information in `config/config.php` or `shop_settings`.
5. Make sure PHP cURL is enabled if using an external WhatsApp provider.
6. Include `assets/js/phase4-payment-automation.js` after your checkout scripts if you want the payment account placeholders populated by API.
7. Test with COD first, then a bKash/Nagad/Bank test order.
8. In Admin > Orders, open the order, verify payment, then use WhatsApp Customer.

## Important: WhatsApp
The package does NOT pretend to have sent a WhatsApp message when no WhatsApp Business/API provider is configured. In that case it creates a click-to-WhatsApp link and logs it as a queued fallback.

For true automatic server-side WhatsApp delivery, connect a WhatsApp Business Cloud API or another approved provider by setting:
- `automation.whatsapp.enabled = true`
- `automation.whatsapp.endpoint`
- `automation.whatsapp.token`

The generic provider expects a JSON body:
`{"to":"8801XXXXXXXXX","message":"..."}`

Adapt the endpoint payload/authentication to the actual provider you choose.

## Payment gateway note
This phase provides manual bKash/Nagad/Bank payment verification and COD. It does not claim to be an official bKash/Nagad API gateway. For automated gateway payment verification, the merchant account/API credentials and provider-specific integration must be configured separately.
