PluginProbe
Packeta / trunk
Packeta vtrunk
2.3.2 2.3.1 trunk 1.2.2 1.2.3 1.2.4 1.2.5 1.2.6 1.3.0 1.3.1 1.3.2 1.4 1.4.1 1.4.2 1.4.3 1.5.0 1.5.1 1.5.2 1.5.3 1.5.4 1.6.0 1.6.1 1.6.2 1.6.3 1.6.4 All 56 releases
packeta / src / Packetery / Module / PaymentGatewayHelper.php

PaymentGatewayHelper.php in Packeta trunk, at src/Packetery/Module/PaymentGatewayHelper.php

53 lines 1020 B
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 /**
3 * Class PaymentHelper
4 *
5 * @package Packetery
6 */
7
8 declare( strict_types=1 );
9
10 namespace Packetery\Module;
11
12 /**
13 * Class PaymentHelper
14 */
15 class PaymentGatewayHelper {
16 /**
17 * Gets available payment gateway choices.
18 *
19 * @return array<string, string>
20 */
21 public static function getAvailablePaymentGatewayChoices(): array {
22 $items = [];
23
24 foreach ( self::getAvailablePaymentGateways() as $paymentGateway ) {
25 $items[ $paymentGateway->id ] = $paymentGateway->get_method_title();
26 }
27
28 return $items;
29 }
30
31 /**
32 * Get available gateways.
33 *
34 * @return \WC_Payment_Gateway[]
35 */
36 public static function getAvailablePaymentGateways(): array {
37 $availableGateways = [];
38
39 foreach ( WC()->payment_gateways()->payment_gateways() as $gateway ) {
40 if ( $gateway->enabled === 'yes' ) {
41 $availableGateways[ $gateway->id ] = $gateway;
42 }
43 }
44
45 return array_filter(
46 $availableGateways,
47 static function ( $gateway ): bool {
48 return $gateway instanceof \WC_Payment_Gateway;
49 }
50 );
51 }
52 }
53