Separate storefront and payment logic
A storefront displays products and collects a customer choice. A server endpoint validates the request and talks to a configured payment provider. A browser-side price or success message must never be trusted as proof of payment.
Read the existing integration first
includes/storefront-integration.php participates in saving storefront-enabled content. donation-api.php demonstrates server-side provider selection, currency checks and order creation in wh_shop_orders. Donation workflows have their own behavior; do not assume they are identical to every product checkout.
Use test environments
Keep provider secrets on the server and use the provider sandbox for development. Trace the order ID and server-confirmed state. Never log secret keys or real payment details, and verify site ownership when displaying private order information.
Syntax in practice
A focused learning example. Read the referenced source file for its full application context.
// Conceptual boundary: browser input is not a confirmed payment.
$currency = strtoupper($config['currency']);
if (!in_array($currency, ['USD', 'INR', 'EUR', 'GBP', 'AUD', 'CAD', 'SGD'], true)) {
throw new RuntimeException('Unsupported currency.');
}Try it yourself
Explain which values a server must verify before creating an order, without making a live payment.
Work on a development copy, then explain what changed and how you verified it.
Project file map
Find these paths in your local WebsHigher checkout. Source paths are references, not public downloads of application code.
includes/storefront-integration.phpdonation-api.php