YKK ORDERS API - CPANEL SETUP
=============================

We will first install the API separately. Do NOT change the YKK checkout yet.

STEP 1 - CREATE A SUBDOMAIN (recommended)
------------------------------------------
In cPanel open Domains / Subdomains and create:

orders.ykk-shopping.com

Point it to a separate folder, for example:
public_html/ykk-orders-api

If your cPanel creates the folder automatically, use that folder.

STEP 2 - ENABLE HTTPS
---------------------
Make sure the new subdomain has SSL/HTTPS. Use the hosting's SSL/Let's Encrypt option if necessary.
The final API should be accessed with:
https://orders.ykk-shopping.com/api/health

STEP 3 - UPLOAD THE API
-----------------------
Open File Manager and open the new API folder.
Upload the contents of the 'api' folder from this ZIP into:
public_html/ykk-orders-api/api/

You should have:
public_html/ykk-orders-api/api/index.php
public_html/ykk-orders-api/api/config.php
public_html/ykk-orders-api/api/.htaccess

STEP 4 - CREATE MYSQL DATABASE
------------------------------
Open cPanel > Database Wizard.
Create a new database, database user, and password.
Give the database user ALL PRIVILEGES for this new database.

Keep the exact database name, username and password.
Do not send those credentials to ChatGPT.

STEP 5 - CREATE THE TABLE
-------------------------
Open cPanel > phpMyAdmin.
Select the new YKK Orders database.
Open the SQL tab.
Copy all SQL from:
database/install.sql
Paste it and click Go/Run.

You should see a table named:
ykk_orders

STEP 6 - EDIT config.php
------------------------
In File Manager open:
api/config.php

Replace these values:

'db_name' => 'CHANGE_ME',
'db_user' => 'CHANGE_ME',
'db_pass' => 'CHANGE_ME',
'api_key' => 'CHANGE_ME_TO_A_LONG_RANDOM_SECRET',

Example only:
'db_name' => 'cpuser_ykkorders',
'db_user' => 'cpuser_ykkapi',
'db_pass' => 'YOUR_DATABASE_PASSWORD',
'api_key' => 'a-long-random-secret-you-create',

Do NOT use the example values above as real credentials.

STEP 7 - TEST HEALTH
--------------------
Open in your browser:
https://orders.ykk-shopping.com/api/health

You should get JSON similar to:
{"success":true,"service":"YKK Orders API","status":"online",...}

This health endpoint does not require the API key.

STEP 8 - TEST DATABASE/API
--------------------------
The protected orders endpoint requires the X-YKK-API-Key header. The standalone dashboard will be connected to this API in the next stage.

DO NOT CONNECT THE LIVE CHECKOUT YET.

If the health URL works, tell me:
"API health works"

Then we will test creating one sample order through the API. Only after that will we connect the desktop checkout and mobile WhatsApp checkout.

TROUBLESHOOTING
---------------
- 500 / Database connection failed: check DB name, user, password and privileges.
- 404: check that index.php is inside the /api/ folder and that the URL includes /api/health.
- SSL warning: enable HTTPS for the subdomain before testing.
- 403: check the hosting security rules and .htaccess.
