# Ads Billing Service

> Microservice for advertising payment processing, credit management, and invoicing.

## Overview

Ads Billing Service manages all financial aspects of the advertising system:

- **Prepaid/Postpaid** - Supports both payment models
- **Credit Lines** - Automatic credit limit allocation
- **Threshold Billing** - Auto-charge at spending thresholds
- **Invoice Generation** - Automatic VAT invoice generation

## Requirements

| Requirement | Version |
|-------------|---------|
| .NET SDK | 10.0.101+ |
| Docker | 24.0+ |
| PostgreSQL | 15+ |

## Quick Start

```bash
cd services/ads-billing-service-net
docker-compose up -d
```

## Project Structure

```
ads-billing-service-net/
├── src/
│   ├── AdsBillingService.API/
│   │   └── Controllers/
│   │       ├── BillingAccountsController.cs
│   │       ├── CreditLinesController.cs
│   │       └── InvoicesController.cs
│   │
│   ├── AdsBillingService.Domain/
│   │   └── AggregatesModel/
│   │       ├── BillingAccountAggregate/
│   │       ├── CreditLineAggregate/
│   │       ├── InvoiceAggregate/
│   │       └── ChargeAggregate/
│   │
│   └── AdsBillingService.Infrastructure/
│
└── AdsBillingService.slnx
```

## API Endpoints

### Billing Accounts

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-billing/accounts/{advertiserId}` | Account info |
| `POST` | `/api/v1/ads-billing/accounts/{id}/add-funds` | Add funds |
| `GET` | `/api/v1/ads-billing/accounts/{id}/balance` | Current balance |

### Credit Lines

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-billing/credit-lines/{advertiserId}` | Credit limit |
| `POST` | `/api/v1/ads-billing/credit-lines/request` | Request increase |

### Invoices

| Method | Endpoint | Description |
|--------|----------|-------------|
| `GET` | `/api/v1/ads-billing/invoices` | List invoices |
| `GET` | `/api/v1/ads-billing/invoices/{id}` | Invoice details |
| `GET` | `/api/v1/ads-billing/invoices/{id}/download` | Download PDF |

## Integration

| Service | Integration |
|---------|-------------|
| **Wallet Service** | Payment processing |
| **ads-serving-service** | Consume charges |
| **IAM Service** | Advertiser info |

## License

Proprietary - GoodGo Platform
