Skip to content

Knowledgebase & Docs

Search guides, configuration tutorials, API references, and troubleshooting solutions.

Creating a payment gateway

Category: KBilling — Modules 2 Views 0 Helpful Votes

Implement configuration, checkout, callbacks and refunds safely.

Structure and class

modules/gateways/acmepay/acmepay.php    // class AcmepayGateway
modules/gateways/acmepay/callback.php
<?php
class AcmepayGateway {
 public function meta(): array { return ['DisplayName'=>'Acme Pay','SupportsRefunds'=>true]; }
 public function getConfigFields(): array { return [
  'name'=>['FriendlyName'=>'Display Name','Type'=>'text','Default'=>'Acme Pay'],
  'api_key'=>['FriendlyName'=>'API Key','Type'=>'password']
 ]; }
 public function testConnection(array $config): array { return ['success'=>true,'message'=>'Connected']; }
 public function renderPaymentButton(array $invoice,array $config): string { /* hosted checkout */ return ''; }
 public function refundTransaction(array $params,array $config): array { return ['success'=>false,'message'=>'Not implemented']; }
}

Callback checklist

  1. Load bootstrap and read raw input once.
  2. Verify provider signature and timestamp first.
  3. Resolve invoice, transaction ID, amount, fee and currency.
  4. Call Gateway::processVerifiedPayment($invoiceId,$txnId,$amount,$fee,'acmepay',$currency).
  5. Return the provider-required status without exposing internal errors.
Payment boundaryNever directly mark an invoice paid, trust browser amounts, store raw callbacks, PAN or CVV.

The current release also requires adding gateway metadata to Gateway::getGatewayRegistry().