haybtech / drupal-commerce
HayBTech Payment Gateway for Drupal Commerce
Package info
github.com/HayBTech/haybtech_commerce_plugin
Type:drupal-module
pkg:composer/haybtech/drupal-commerce
v1.0.0
2026-05-22 20:40 UTC
Requires
- drupal/commerce: ^2.0
- haybtech/php-sdk: ^1.0
README
Official Drupal Commerce payment gateway module for HayBTech -- accept mobile money payments on your Drupal Commerce store.
Features
- Native Drupal Commerce 2.x offsite payment gateway
- Admin configuration form with test/live key management
- Automatic webhook (IPN) verification with HMAC-SHA256 signatures
- Full support for Test and Live modes
- Zero external Composer dependencies (embedded SDK)
- Handles
onReturn,onCancel, andonNotifylifecycle events
Requirements
| Requirement | Version |
|---|---|
| Drupal | 9.x or 10.x |
| Commerce | 2.x |
| Commerce Payment | 2.x |
| Commerce Order | 2.x |
| PHP | 8.1+ |
Installation
Via Composer
composer require haybtech/commerce drush en haybtech_commerce -y drush cr
Manual
- Copy the
haybtech_commercedirectory to<drupal-root>/modules/custom/. - Enable via admin: Extend > HayBTech Commerce > Install.
- Or via Drush:
drush en haybtech_commerce -y drush cr
Configuration
- Go to Commerce > Configuration > Payment gateways.
- Click Add payment gateway.
- Select **HayBTech ** as the plugin.
- Configure:
| Field | Description |
|---|---|
| Display name | Name shown to customers at checkout |
| Mode | Test or Live |
| Test Secret Key | Your sk_test_... key |
| Live Secret Key | Your sk_live_... key |
| Webhook Secret | Your whsec_... signing secret |
- Click Save.
Webhook Setup
- In your HayBTech Dashboard, go to Settings > Webhooks.
- Add a new endpoint:
https://your-site.com/payment/notify/haybtech_offsite
- Copy the webhook secret into the gateway configuration.
How It Works
- Customer selects HayBTech at checkout.
- Drupal Commerce redirects to the HayBTech hosted payment page.
- Customer pays via mobile money.
- HayBTech sends a signed IPN (webhook) to your
onNotifyendpoint. - The module verifies the HMAC-SHA256 signature, creates a Commerce Payment entity, and marks the order as completed.
- Customer is redirected back via the
onReturnhandler.
Module Structure
haybtech_commerce/
haybtech_commerce.info.yml # Module metadata and dependencies
src/
Plugin/Commerce/PaymentGateway/
HayBTech.php # Offsite gateway (config, onReturn, onNotify)
lib/
sdk/ # Embedded HayBTech PHP SDK
HayBTech.php, HayBTechClient.php, HayBTechResponse.php,
Webhook.php
Resources/
Payments.php, Webhooks.php
Exceptions/
ApiException.php, HayBTechException.php, SignatureException.php
Security
- HMAC-SHA256 Webhook Verification with constant-time comparison
- Zero External Dependencies -- embedded SDK, no supply chain risk
- Secret Masking in logs and debug output
- 1 MB Payload Limit to prevent DoS
- CRLF Guard against HTTP header injection
- Drupal Logging -- errors are logged via
\Drupal::logger('haybtech')
Troubleshooting
| Issue | Solution |
|---|---|
| Module not appearing | Run drush cr to clear caches |
| Gateway not in list | Verify commerce_payment and commerce_order are enabled |
| Webhooks returning 403 | Check webhook secret matches the HayBTech dashboard |
| Orders not completing | Check Drupal logs at Reports > Recent log messages |
MIT License