# packeta/trunk/src/Packetery/Module/PaymentGatewayHelper.php

Packeta, version trunk. 53 lines.

- Page: https://pluginprobe.com/plugins/packeta/trunk/code/src/Packetery/Module/PaymentGatewayHelper.php
- Raw: https://pluginprobe.com/plugins/packeta/trunk/raw/src/Packetery/Module/PaymentGatewayHelper.php
- Modified: 2025-03-10T10:47:38+00:00

Line numbers below start at 1. Link to a line or a range by appending a fragment to the
page URL, for example `https://pluginprobe.com/plugins/packeta/trunk/code/src/Packetery/Module/PaymentGatewayHelper.php#L10-L20`.

```php
<?php
/**
 * Class PaymentHelper
 *
 * @package Packetery
 */

declare( strict_types=1 );

namespace Packetery\Module;

/**
 * Class PaymentHelper
 */
class PaymentGatewayHelper {
	/**
	 * Gets available payment gateway choices.
	 *
	 * @return array<string, string>
	 */
	public static function getAvailablePaymentGatewayChoices(): array {
		$items = [];

		foreach ( self::getAvailablePaymentGateways() as $paymentGateway ) {
			$items[ $paymentGateway->id ] = $paymentGateway->get_method_title();
		}

		return $items;
	}

	/**
	 * Get available gateways.
	 *
	 * @return \WC_Payment_Gateway[]
	 */
	public static function getAvailablePaymentGateways(): array {
		$availableGateways = [];

		foreach ( WC()->payment_gateways()->payment_gateways() as $gateway ) {
			if ( $gateway->enabled === 'yes' ) {
				$availableGateways[ $gateway->id ] = $gateway;
			}
		}

		return array_filter(
			$availableGateways,
			static function ( $gateway ): bool {
				return $gateway instanceof \WC_Payment_Gateway;
			}
		);
	}
}

```
