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
40
modules/billing/classes/PaymentGatewayInterface.php
Normal file
40
modules/billing/classes/PaymentGatewayInterface.php
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
/**
|
||||
* Payment Gateway Interface
|
||||
* All payment providers must implement this contract.
|
||||
*/
|
||||
interface PaymentGatewayInterface
|
||||
{
|
||||
/**
|
||||
* Create a payment/order on the provider side.
|
||||
* @param array $params { amount, currency, invoice_id, description, return_url, cancel_url, items? }
|
||||
* @return array { success: bool, provider_order_id: string, redirect_url?: string, error?: string }
|
||||
*/
|
||||
public function createPayment(array $params): array;
|
||||
|
||||
/**
|
||||
* Handle a provider callback/capture (webhook or return).
|
||||
* @param array $params Provider-specific parameters (e.g. { order_id } for PayPal)
|
||||
* @return array { success: bool, transaction_id: string, amount: float, status: string, raw_response: array, error?: string }
|
||||
*/
|
||||
public function handleCallback(array $params): array;
|
||||
|
||||
/**
|
||||
* Verify that a payment/webhook is authentic.
|
||||
* @param array $payload Raw request body / headers
|
||||
* @return bool
|
||||
*/
|
||||
public function verifyPayment(array $payload): bool;
|
||||
|
||||
/**
|
||||
* Get the provider's external transaction ID from a capture result.
|
||||
* @param array $captureResult Result from handleCallback()
|
||||
* @return string|null
|
||||
*/
|
||||
public function getTransactionId(array $captureResult): ?string;
|
||||
|
||||
/**
|
||||
* Return a short machine name for this gateway (e.g. 'paypal', 'stripe', 'manual').
|
||||
*/
|
||||
public function getName(): string;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue