refactor(billing): clean architecture with payment gateway abstraction
- Add PaymentGatewayInterface contract for all payment providers - Add PayPalGateway (reads credentials from config, not hardcoded) - Add ManualGateway for admin-triggered payments - Add StripeGateway stub for future implementation - Add GatewayFactory for gateway instantiation by name - Add BillingRepository: parameterized-SQL data layer - Add BillingService: pricing, invoice creation, payment processing - Add gsp_billing_transactions table (DB version 2) for audit trail - Add new columns to gsp_billing_invoices (home_id, rate_type, players, period_start/end, subtotal, total_due, payment_status) - Add gsp_billing_service_remote_servers mapping table - Move PayPal credentials from api files into config.inc.php - Fix double session_start() bug in capture_order.php - Replace raw SQL with prepared statements throughout - Refactor admin_invoices.php to use billing_invoices + BillingRepository - Refactor admin_payments.php to read from gsp_billing_transactions - Update admin.php with links to Transaction Log and Manage Invoices Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
parent
b0e00c9370
commit
986a4e53b4
14 changed files with 1227 additions and 749 deletions
30
modules/billing/classes/GatewayFactory.php
Normal file
30
modules/billing/classes/GatewayFactory.php
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
<?php
|
||||
require_once __DIR__ . '/../classes/PaymentGatewayInterface.php';
|
||||
require_once __DIR__ . '/../classes/PayPalGateway.php';
|
||||
require_once __DIR__ . '/../classes/ManualGateway.php';
|
||||
require_once __DIR__ . '/../classes/StripeGateway.php';
|
||||
|
||||
/**
|
||||
* Factory for instantiating payment gateways by name.
|
||||
*/
|
||||
class GatewayFactory
|
||||
{
|
||||
/**
|
||||
* @param string $name Gateway name: 'paypal', 'stripe', 'manual'
|
||||
* @return PaymentGatewayInterface
|
||||
* @throws InvalidArgumentException
|
||||
*/
|
||||
public static function make(string $name): PaymentGatewayInterface
|
||||
{
|
||||
switch (strtolower($name)) {
|
||||
case 'paypal':
|
||||
return PayPalGateway::fromConfig();
|
||||
case 'manual':
|
||||
return new ManualGateway();
|
||||
case 'stripe':
|
||||
return new StripeGateway();
|
||||
default:
|
||||
throw new InvalidArgumentException("Unknown payment gateway: {$name}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue