===================================================================================
   AUTOMATED PAYMENT GATEWAY - FULL COMMERCIAL DEPLOYMENT & API INTEGRATION GUIDE
===================================================================================

Thank you for choosing this Automated Multi-Gateway Payment System.
This release features a 1-Click Graphical Web Installer Wizard, so you can 
deploy and launch the entire payment gateway in under 2 minutes without 
touching any code or manually editing the .env file!

===================================================================================
 SECTION 1: 1-CLICK AUTOMATED WEB INSTALLATION (SUPER FAST)
===================================================================================

STEP 1: Upload & Extract Package
---------------------------------
1. Upload `Arora_Payment_Gateway_Release_v5.0.zip` to your web server root directory
   (e.g., `/www/wwwroot/yourdomain.com` in aaPanel, or `public_html` in cPanel).
2. Extract all files into the root folder.

STEP 2: Set Running Directory / Document Root to `/public`
---------------------------------------------------------
* IMPORTANT: Laravel requires the Web Document Root to point to the `/public` folder.
- In aaPanel: Website -> Site Settings -> Site Directory -> Running directory: `/public` -> Save.
- In cPanel: Domains -> Document Root: Set to `public_html/public`.
- In Nginx/VPS: Set `root /www/wwwroot/yourdomain.com/public;` in your Nginx config.

STEP 3: Set Storage Permissions
-------------------------------
Make sure the web server user (www or www-data) has write permissions:
In terminal / SSH:
    chmod -R 775 storage bootstrap/cache public/uploads
    chown -R www:www /www/wwwroot/yourdomain.com

STEP 4: Open Your Website in Browser (Automatic Web Installer)
--------------------------------------------------------------
1. Open your browser and visit your domain: `https://yourdomain.com/`
2. The **Graphical Web Installer Wizard** will automatically launch!
3. Follow the 3 easy on-screen steps:
   - Step 1: System & Permissions Check (Verifies PHP >= 8.2 and required extensions).
   - Step 2: Database Configuration (Enter DB Name, User, Password -> The installer
             automatically tests the connection, auto-updates the .env file, and
             initializes all database tables automatically).
   - Step 3: Admin & License Setup (Set your Admin Name, Email, Password, and enter
             your purchased License Key to activate the system).
4. Click "Complete Installation" -> Your site is instantly live!
5. Visiting `https://yourdomain.com/` will now directly open the Admin Login / Dashboard!

===================================================================================
 SECTION 2: BRANDING & SYSTEM CONFIGURATION
===================================================================================

Navigate to: Admin Panel -> "Brand & System Settings"

1. General Settings:
   - Customize Brand Name, Title, and Currency (BDT, USD, etc.).
2. Logo & Favicon:
   - Upload your custom website logo and browser favicon with instant live preview.
3. Themes & Accent Colors:
   - Switch between Dark and Light mode, choose primary theme accent color.
4. Mail / SMTP Notifications:
   - Enter your SMTP details (Gmail, Zoho, SendGrid, Amazon SES) to send automated
     HTML payment receipts to customers and alert emails to admin.
5. Telegram Notifications:
   - Enter Telegram Bot Token and Chat ID to receive instant alerts when payments succeed.
6. FAQ & SEO:
   - Add custom FAQs and Meta tags for Google search engine optimization.

===================================================================================
 SECTION 3: HOW TO CONFIGURE PAYMENT GATEWAYS
===================================================================================

Navigate to: Admin Panel -> "Gateways" -> "New Gateway"

1. Mobile Banking (bKash, Nagad, Rocket, Upay, Cellfin, Tap, Ok Wallet):
   - Click on the desired gateway template.
   - Enter your personal/agent account number.
   - (Optional) Upload your QR code image.
   - Set Minimum/Maximum transaction limits.
   - Click "Create".

2. Binance Crypto Gateway:
   - Select "Binance Personal".
   - Enter your Binance API Key, API Secret, and Binance Pay ID.
   - The gateway will automatically convert BDT to USDT and verify transfers in real-time.

3. Merchant APIs (bKash API, Nagad API, SSLCommerz, Stripe, PayPal):
   - Select the respective gateway template.
   - Input your Merchant credentials and toggle Sandbox mode if testing.

===================================================================================
 SECTION 4: API INTEGRATION TUTORIAL FOR DEVELOPERS & MERCHANTS
===================================================================================

How to connect this gateway with WooCommerce, WHMCS, Shopify, or Custom PHP/Node apps:

STEP 1: Generate an API Key
---------------------------
1. Go to Admin Panel -> "Api Keys" -> "New api key".
2. Set a name (e.g. "Main Website Store") and click Create.
3. Copy your Public Key / API Key.

STEP 2: Create a Payment Session (Endpoint)
-------------------------------------------
- Method  : POST
- URL     : `https://yourdomain.com/api/checkout-v2`
- Headers :
    Content-Type: application/json
    Accept: application/json
    RT-UDDOKTAPAY-API-KEY: <YOUR_API_KEY>

- Request Body (JSON):
{
    "full_name": "Customer Name",
    "email": "customer@example.com",
    "amount": "500",
    "metadata": {
        "order_id": "ORDER_10023"
    },
    "redirect_url": "https://yourwebsite.com/payment/success",
    "cancel_url": "https://yourwebsite.com/payment/cancel",
    "webhook_url": "https://yourwebsite.com/payment/webhook"
}

- Success Response (JSON):
{
    "status": true,
    "message": "Payment initiated successfully",
    "payment_url": "https://yourdomain.com/pay/PL_ABC123XYZ"
}

-> Action: Redirect the customer's browser to `payment_url`.

STEP 3: Verify Payment Status
-----------------------------
- Method  : POST
- URL     : `https://yourdomain.com/api/verify-payment`
- Headers :
    RT-UDDOKTAPAY-API-KEY: <YOUR_API_KEY>
- Request Body (JSON):
{
    "invoice_id": "PL_ABC123XYZ"
}

- Success Response (JSON):
{
    "status": "COMPLETED",
    "amount": "500.00",
    "trx_id": "9H71B20A1",
    "payment_method": "bkash",
    "date": "2026-08-27 02:00:00"
}

-----------------------------------------------------------------------------------
 COMPLETE PHP INTEGRATION SAMPLE CODE:
-----------------------------------------------------------------------------------

<?php
$apiKey = "YOUR_API_KEY_HERE";
$gatewayUrl = "https://yourdomain.com/api/checkout-v2";

$data = [
    "full_name"    => "Rahim Uddin",
    "email"        => "rahim@example.com",
    "amount"       => 500,
    "metadata"     => ["order_id" => "101"],
    "redirect_url" => "https://myshop.com/success.php",
    "cancel_url"   => "https://myshop.com/cancel.php",
    "webhook_url"  => "https://myshop.com/ipn.php"
];

$ch = curl_init($gatewayUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data));
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "RT-UDDOKTAPAY-API-KEY: " . $apiKey,
    "Content-Type: application/json",
    "Accept: application/json"
]);

$response = curl_exec($ch);
curl_close($ch);

$result = json_decode($response, true);
if (!empty($result['payment_url'])) {
    header("Location: " . $result['payment_url']);
    exit();
} else {
    echo "Payment Error: " . ($result['message'] ?? 'Unable to connect');
}
?>

===================================================================================
 SECTION 5: AUTOMATED CRON JOB (SCHEDULED TASKS)
===================================================================================

To enable automatic license check & SMS background processing, add this cron job:

* * * * * cd /www/wwwroot/yourdomain.com && php artisan schedule:run >> /dev/null 2>&1

===================================================================================
                       © 2026 All Rights Reserved.
===================================================================================
