haybtech/drupal-commerce

HayBTech Payment Gateway for Drupal Commerce

Maintainers

Package info

github.com/HayBTech/haybtech_commerce_plugin

Type:drupal-module

pkg:composer/haybtech/drupal-commerce

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-05-22 20:40 UTC

This package is auto-updated.

Last update: 2026-05-22 20:40:26 UTC


README

Official Drupal Commerce payment gateway module for HayBTech -- accept mobile money payments on your Drupal Commerce store.

Drupal Commerce PHP License

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, and onNotify lifecycle 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

  1. Copy the haybtech_commerce directory to <drupal-root>/modules/custom/.
  2. Enable via admin: Extend > HayBTech Commerce > Install.
  3. Or via Drush:
drush en haybtech_commerce -y
drush cr

Configuration

  1. Go to Commerce > Configuration > Payment gateways.
  2. Click Add payment gateway.
  3. Select **HayBTech ** as the plugin.
  4. 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
  1. Click Save.

Webhook Setup

  1. In your HayBTech Dashboard, go to Settings > Webhooks.
  2. Add a new endpoint:
https://your-site.com/payment/notify/haybtech_offsite
  1. Copy the webhook secret into the gateway configuration.

How It Works

  1. Customer selects HayBTech at checkout.
  2. Drupal Commerce redirects to the HayBTech hosted payment page.
  3. Customer pays via mobile money.
  4. HayBTech sends a signed IPN (webhook) to your onNotify endpoint.
  5. The module verifies the HMAC-SHA256 signature, creates a Commerce Payment entity, and marks the order as completed.
  6. Customer is redirected back via the onReturn handler.

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

haybtech_commerce_plugin

haybtech_commerce_plugin