PAYBYTE COFFEE MUG SECURE CHECKOUT DEMO
=======================================

Purpose
-------
This is a small real PBE-PAY checkout example designed so browser JavaScript is
not authoritative for merchant payment details.

The merchant server chooses the receiving address, price, confirmation policy
and unique payment reference from server-side configuration. PHP creates the
PBE-PAY request and later checks the exact server-owned tuple against the PBE
node. The browser only renders the result and opens the returned wallet link.

Default demo values
-------------------
Product: Paybyte Coffee Mug
Price: 50.00 PBE
Confirmations: 12

Configuration
-------------
Edit demo-config.php on the server.

Required values:
- recipient: your pbe1... mainnet receiving address
- amountPbe: merchant-controlled product price
- confirmations: required canonical confirmation depth
- nodeUrl: compatible PBE web node used by the PHP merchant backend
- walletUrl: compatible PBE web wallet used for customer handoff

No database password, manageToken or signingSecret is used by this example.
Those Commerce webhook credentials are only required by webhook-based merchant
flows such as the Golden Sword example.

Security model
--------------
The browser never sends recipient, amount or reference to the PBE node.

1. Browser POSTs an empty create-order request to api.php with a CSRF token.
2. PHP reads recipient/amount/confirmations from demo-config.php.
3. PHP generates the random order reference.
4. PHP calls POST /rpc/commerce/payment-request itself.
5. PHP verifies the node returned the same recipient + amount + reference.
6. PHP stores the authoritative tuple in the server session.
7. Browser receives only the already-created payment URI/wallet link.
8. Browser polling calls this demo's api.php, not the PBE status API directly.
9. PHP checks GET /rpc/commerce/payment/{reference} using the session tuple.
10. The browser only displays the server-verified state.

A user can always edit their own DOM/JavaScript and make their own screen say
anything. That does not change the server session, the payment tuple queried by
PHP, or the state returned by the merchant endpoint.

Database
--------
No merchant database tables are required for this checkout example.
database.sql is intentionally a no-op.

A PHP session is enough to demonstrate server-authoritative checkout validation.
For a real store, persist orders in your merchant database rather than relying
on session lifetime, and use signed Commerce webhooks for automatic fulfilment.

Install
-------
Place the complete folder under your PBE /web directory, for example:

D:\xampp\htdocs\paybyte.org\web\Paybyte-Coffee-Mug-Checkout-Test\

Edit demo-config.php, then open:
https://your-domain.example/web/Paybyte-Coffee-Mug-Checkout-Test/

Expected flow
-------------
1. PHP creates a unique merchant order and PBE-PAY request.
2. Pay by Paybyte opens the configured wallet using the server-created URI.
3. Customer signs locally and broadcasts.
4. Browser asks api.php for current order state.
5. PHP checks the exact recipient + amount + reference against the PBE node.
6. UI moves unpaid -> pending -> confirming -> confirmed.

Important
---------
This is a REAL mainnet payment demo. Confirming the wallet transaction moves
real PBE to the configured receiving address plus the normal network fee.
Verify demo-config.php carefully before testing.

This example demonstrates secure server-authoritative checkout polling. It does
not demonstrate persistent order storage or automatic fulfilment. For that,
use the Golden Sword signed webhook example.

Documentation
-------------
Current Paybyte developer documentation and refreshed example downloads live at:
https://paybyte.org/web/developers/
