# M-Pesa URL Registration - Quick Start

## 🚀 Fastest Way to Register URLs

### Option 1: Django Command (Recommended)

```bash
# Navigate to your project directory
cd c:\Users\phing\Desktop\branch-system

# Run the registration command
python manage.py register_mpesa_urls --use-config --production
```

**That's it!** The command will:
- Load your credentials from the database
- Generate an access token
- Register the URLs
- Show you the result

---

### Option 2: Standalone Script

```bash
# 1. Edit the script first
notepad register_mpesa_urls_standalone.py

# 2. Update these values:
#    CONSUMER_KEY = "your_key"
#    CONSUMER_SECRET = "your_secret"
#    SHORT_CODE = "your_shortcode"

# 3. Run the script
python register_mpesa_urls_standalone.py
```

---

### Option 3: Postman (Manual)

#### Step 1: Get Access Token

```
GET https://api.safaricom.co.ke/oauth/v1/generate?grant_type=client_credentials

Headers:
  Authorization: Basic <base64(consumer_key:consumer_secret)>
  Content-Type: application/json
```

#### Step 2: Register URLs

```
POST https://api.safaricom.co.ke/mpesa/c2b/v2/registerurl

Headers:
  Authorization: Bearer <access_token_from_step_1>
  Content-Type: application/json

Body:
{
    "ShortCode": "YOUR_SHORTCODE",
    "ResponseType": "Completed",
    "ConfirmationURL": "https://branchbusinessadvance.co.ke/payments/callback/confirmation/",
    "ValidationURL": "https://branchbusinessadvance.co.ke/payments/callback/validation/"
}
```

---

## ✅ What You Need

From Safaricom's email, you need to register:

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

---

## 🎯 Expected Response

```json
{
    "OriginatorCoversationID": "29115-34620561-1",
    "ResponseCode": "0",
    "ResponseDescription": "Success"
}
```

If you see `ResponseCode: 0`, you're done! ✅

---

## 🧪 Test It

After registration:

1. Send 10 KES to your shortcode
2. Check: `https://branchbusinessadvance.co.ke/payments/transactions/`
3. Verify payment was processed

---

## ❓ Need Help?

See the full guide: `MPESA_URL_REGISTRATION_GUIDE.md`
