For Developers

Developer Guide

A practical technical summary. Full deep reference is in the root DEVELOPER.md file in the repository.

Architecture layers

  • Core — plugin bootstrap and hook registration (Core/Plugin.php)
  • Gateways — WooCommerce adapters extending WC_Payment_Gateway
  • Services — external API calls and payment verification logic
  • Controllers — callback and AJAX request handling
  • Blocks — block checkout support classes and JS registration

Adding a new gateway

  1. Create a new service class under app/Services/ to handle external API communication.
  2. Create a gateway class under app/Gateways/ extending WC_Payment_Gateway.
  3. Register the gateway in GatewayManager::register().
  4. Add the callback hook in Core/Plugin.php.
  5. Add the callback handler in Controllers/CallbackController.php.
  6. Add a block support class and JS file if block checkout is needed.

Security checklist

  • Sanitize all $_GET and $_POST values before use
  • Verify nonces for all admin AJAX actions
  • Never trust redirect success status without independent API verification
  • Store all credentials in WooCommerce settings only — never hardcode
  • Log errors through WooCommerce logger, not error_log()

Key file locations

bpgw/
├── app/
│   ├── Core/Plugin.php           # Bootstrap & hooks
│   ├── Gateways/
│   │   ├── BkashGateway.php
│   │   ├── SSLCommerzGateway.php
│   │   └── Blocks/               # Block support classes
│   ├── Services/
│   │   ├── BkashService.php
│   │   └── SSLCommerzService.php
│   └── Controllers/
│       └── CallbackController.php
└── assets/js/
    ├── bkash-block.js
    └── sslcommerz-block.js