init(); } /** * Initialize the gateway * * @since 1.0.0 * @return void */ public function init(): void { // Add any initialization logic here } /** * Get gateway name * * @since 1.0.0 * @return string */ public function getName(): string { return $this->name; } /** * Get gateway title * * @since 1.0.0 * @return string */ public function getTitle(): string { return $this->title; } /** * Get gateway description * * @since 1.0.0 * @return string */ public function getDescription(): string { return $this->description; } /** * Get gateway icon * * @since 1.0.0 * @return string */ public function getIcon(): string { return $this->icon; } /** * Check if gateway is available * * @since 1.0.0 * @return bool */ public function isAvailable(): bool { return true; // Manual payment is always available } /** * Process payment * * @since 1.0.0 * @param float $amount Payment amount * @param array $data Additional payment data * @return array */ public function processPayment(float $amount, array $data = []): array { // Manual payments are processed by admin return [ 'success' => true, 'message' => __('Manual payment submitted for verification', 'easy-invoice'), 'data' => [ 'status' => 'pending', 'requires_verification' => true ] ]; } /** * Handle callback * * @since 1.0.0 * @param array $data Callback data * @return array */ public function handleCallback(array $data): array { // Manual payments don't have callbacks return [ 'success' => true, 'message' => __('Manual payment processed', 'easy-invoice') ]; } /** * Get payment form fields * * @since 1.0.0 * @param int $invoice_id Invoice ID * @return string */ public function getPaymentForm(int $invoice_id): string { ob_start(); $this->renderPaymentForm((object)['id' => $invoice_id]); return ob_get_clean(); } /** * Render payment form * * @since 1.0.0 * @param object $invoice Invoice object * @return void */ public function renderPaymentForm($invoice): void { // Get invoice ID from invoice object $invoice_id = is_object($invoice) && method_exists($invoice, 'getId') ? $invoice->getId() : 0; ?>

' . __('Bank transfer details will be provided by the administrator.', 'easy-invoice') . '

'; return; } echo ''; if ($bank_name) { echo ''; } if ($account_name) { echo ''; } if ($account_number) { echo ''; } if ($routing_number) { echo ''; } if ($swift_code) { echo ''; } if ($bank_address) { echo ''; } echo '
' . __('Bank Name', 'easy-invoice') . '' . esc_html($bank_name) . '
' . __('Account Name', 'easy-invoice') . '' . esc_html($account_name) . '
' . __('Account Number', 'easy-invoice') . '' . esc_html($account_number) . '
' . __('Routing Number', 'easy-invoice') . '' . esc_html($routing_number) . '
' . __('SWIFT Code', 'easy-invoice') . '' . esc_html($swift_code) . '
' . __('Bank Address', 'easy-invoice') . '' . esc_html($bank_address) . '
'; } /** * Render cheque details * * @since 1.0.0 * @return void */ private function renderChequeDetails(): void { $payee_name = get_option('easy_invoice_manual_payee_name', ''); $payee_address = get_option('easy_invoice_manual_payee_address', ''); if (empty($payee_name)) { echo '

' . __('Cheque payment details will be provided by the administrator.', 'easy-invoice') . '

'; return; } echo '
'; if ($payee_name) { echo '

' . __('Make cheque payable to:', 'easy-invoice') . ' ' . esc_html($payee_name) . '

'; } if ($payee_address) { echo '

' . __('Mail cheque to:', 'easy-invoice') . ' ' . esc_html($payee_address) . '

'; } echo '
'; } /** * Get gateway settings * * @since 1.0.0 * @return array */ public function getSettings(): array { return [ 'enabled' => [ 'title' => __('Enable Manual Payment', 'easy-invoice'), 'type' => 'checkbox', 'description' => __('Enable manual payment option', 'easy-invoice'), 'default' => 'yes' ], 'title' => [ 'title' => __('Title', 'easy-invoice'), 'type' => 'text', 'description' => __('Payment method title that will be shown to customers', 'easy-invoice'), 'default' => __('Manual Payment', 'easy-invoice') ], 'description' => [ 'title' => __('Description', 'easy-invoice'), 'type' => 'textarea', 'description' => __('Payment method description that will be shown to customers', 'easy-invoice'), 'default' => __('Pay manually via cash, check, or bank transfer', 'easy-invoice') ], 'bank_name' => [ 'title' => __('Bank Name', 'easy-invoice'), 'type' => 'text', 'description' => __('Bank name for bank transfer payments', 'easy-invoice'), 'default' => '' ], 'account_name' => [ 'title' => __('Account Name', 'easy-invoice'), 'type' => 'text', 'description' => __('Account holder name', 'easy-invoice'), 'default' => '' ], 'account_number' => [ 'title' => __('Account Number', 'easy-invoice'), 'type' => 'text', 'description' => __('Bank account number', 'easy-invoice'), 'default' => '' ], 'routing_number' => [ 'title' => __('Routing Number', 'easy-invoice'), 'type' => 'text', 'description' => __('Bank routing number', 'easy-invoice'), 'default' => '' ], 'swift_code' => [ 'title' => __('SWIFT Code', 'easy-invoice'), 'type' => 'text', 'description' => __('Bank SWIFT code for international transfers', 'easy-invoice'), 'default' => '' ], 'bank_address' => [ 'title' => __('Bank Address', 'easy-invoice'), 'type' => 'textarea', 'description' => __('Bank address for payments', 'easy-invoice'), 'default' => '' ], 'payee_name' => [ 'title' => __('Payee Name', 'easy-invoice'), 'type' => 'text', 'description' => __('Name to make cheques payable to', 'easy-invoice'), 'default' => '' ], 'payee_address' => [ 'title' => __('Payee Address', 'easy-invoice'), 'type' => 'textarea', 'description' => __('Address to mail cheques to', 'easy-invoice'), 'default' => '' ] ]; } /** * Save gateway settings * * @since 1.0.0 * @param array $settings Settings to save * @return bool */ public function saveSettings(array $settings): bool { foreach ($settings as $key => $value) { update_option('easy_invoice_manual_' . $key, $value); } return true; } /** * Get gateway settings values * * @since 1.0.0 * @return array */ public function getSettingsValues(): array { return [ 'enabled' => get_option('easy_invoice_manual_enabled', 'yes'), 'title' => get_option('easy_invoice_manual_title', __('Manual Payment', 'easy-invoice')), 'description' => get_option('easy_invoice_manual_description', __('Pay manually via cash, check, or bank transfer', 'easy-invoice')), 'bank_name' => get_option('easy_invoice_manual_bank_name', ''), 'account_name' => get_option('easy_invoice_manual_account_name', ''), 'account_number' => get_option('easy_invoice_manual_account_number', ''), 'routing_number' => get_option('easy_invoice_manual_routing_number', ''), 'swift_code' => get_option('easy_invoice_manual_swift_code', ''), 'bank_address' => get_option('easy_invoice_manual_bank_address', ''), 'payee_name' => get_option('easy_invoice_manual_payee_name', ''), 'payee_address' => get_option('easy_invoice_manual_payee_address', '') ]; } }