# Manual M-Pesa URL Registration Guide

## URLs to Register

**Validation URL:**
```
https://branchbusinessadvance.co.ke/payments/callback/validation/
```

**Confirmation URL:**
```
https://branchbusinessadvance.co.ke/payments/callback/confirmation/
```

## Step-by-Step Instructions

### For Main Branch (Shortcode: 4086675)

1. **Login to Safaricom M-Pesa Portal**
   - URL: https://org.ke.m-pesa.com/
   - Use your organization credentials

2. **Navigate to C2B Settings**
   - Click on "API Management" or "Manage APIs"
   - Select "C2B" (Customer to Business)
   - Click "Register URLs" or "Configure URLs"

3. **Select Shortcode**
   - Choose shortcode: **4086675**

4. **Enter URLs**
   - Validation URL: `https://branchbusinessadvance.co.ke/payments/callback/validation/`
   - Confirmation URL: `https://branchbusinessadvance.co.ke/payments/callback/confirmation/`
   - Response Type: **Completed**

5. **Save Configuration**

### For Juja Branch (Shortcode: 4159523)

**Repeat the same steps above but select shortcode: 4159523**

Important: Use the **SAME URLs** for both shortcodes!

## Verification

After registering:

1. **Test Main Branch**
   - Make payment to paybill: 4086675
   - Amount: KES 10
   - Account: Any registered borrower ID

2. **Check Admin Panel**
   - Go to: Payments → M-Pesa Callbacks
   - Look for new entries with BusinessShortCode = 4086675

3. **Test Juja Branch**
   - Make payment to paybill: 4159523
   - Verify callbacks appear

## Common Issues

### URLs Not Accepted
- Ensure domain has valid SSL certificate
- URLs must start with `https://`
- No trailing parameters allowed
- Must be accessible from internet

### Callbacks Not Received
- Check server firewall settings
- Verify SSL certificate is valid
- Test URLs manually:
  ```bash
  curl https://branchbusinessadvance.co.ke/payments/callback/validation/
  ```
- Contact Safaricom support if needed

## Alternative: Programmatic Registration

If you prefer to register via API:

```bash
# Default (uses branchbusinessadvance.co.ke and production)
python register_mpesa_urls.py

# Specify domain
python register_mpesa_urls.py yourdomain.com

# Specify domain and environment
python register_mpesa_urls.py yourdomain.com sandbox
```

## Contact Safaricom Support

If you encounter issues:
- Phone: 0711 066 000
- Email: m-pesabusiness@safaricom.co.ke
- Mention shortcodes: 4086675 and 4159523
