Skip to main content

Architecture

File Structure

suma-test-woocommerce-gateway/
suma-test-woocommerce-gateway.php
includes/
class-wc-gateway-suma-test.php
README.md

Bootstrap File

suma-test-woocommerce-gateway.php is responsible for:

  • Defining plugin constants (STWG_PLUGIN_FILE, STWG_PLUGIN_DIR)
  • Loading text domain on plugins_loaded
  • Guarding initialization until WooCommerce and WC_Payment_Gateway exist
  • Requiring gateway class file
  • Registering gateway class via woocommerce_payment_gateways

Gateway Class

WC_Gateway_Suma_Test extends WC_Payment_Gateway and implements:

  • Gateway metadata (id, title, description, supports)
  • Admin fields and settings persistence
  • Checkout field rendering and validation
  • Payment processing (approve or decline branch)
  • Thank-you page output
  • Customer email instruction output
  • WC API callback endpoint

Payment Branches

Approve Branch

  • Generates fake transaction ID
  • Generates fake auth code
  • Persists order meta:
    • _stwg_auth_code
    • _stwg_avs = Y
    • _stwg_cvv = M
  • Adds approval order note
  • Calls payment_complete()
  • Empties cart
  • Returns success + redirect URL

Decline Branch

  • Generates fake transaction ID
  • Persists order meta:
    • _stwg_response_code = DECLINED_100
    • _stwg_response_text = Do not honor
  • Adds decline order note
  • Updates status to failed
  • Fires WooCommerce failure action
  • Adds checkout error notice
  • Returns failure

User-Facing Surfaces

  • Checkout payment fieldset
  • Thank-you section for orders paid with gateway
  • Customer email pre-table instruction message
  • WC API endpoint response (OK)