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
- Load bootstrap and read raw input once.
- Verify provider signature and timestamp first.
- Resolve invoice, transaction ID, amount, fee and currency.
- Call
Gateway::processVerifiedPayment($invoiceId,$txnId,$amount,$fee,'acmepay',$currency). - Return the provider-required status without exposing internal errors.
The current release also requires adding gateway metadata to Gateway::getGatewayRegistry().