PluginProbe
Booktics – Appointment Booking Calendar for Service Businesses / 1.0.0
Booktics – Appointment Booking Calendar for Service Businesses v1.0.0
1.0.25 1.0.24 1.0.23 1.0.22 1.0.21 1.0.20 1.0.19 trunk 1.0.0 1.0.1 1.0.10 1.0.11 1.0.12 1.0.13 1.0.14 1.0.15 1.0.16 1.0.17 1.0.18 1.0.2 1.0.3 1.0.4 1.0.5 1.0.6 1.0.7 All 27 releases
booktics / core / payment / payment-method-manager.php

payment-method-manager.php in Booktics – Appointment Booking Calendar for Service Businesses 1.0.0, at core/payment/payment-method-manager.php

43 lines 1.0 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Booktics\Payment;
4
5 use Booktics\Payment\Contracts\Payment_Method_Interface;
6 use WP_Error;
7
8 /**
9 * Manager for payment methods.
10 *
11 * Allows registering and retrieving payment methods. Also handles processing
12 * payments using a specified payment method.
13 *
14 * @package Booktics\Core\Payment
15 * @since 1.0.0
16 */
17 class Payment_Method_Manager {
18
19 private $payment_methods = array();
20
21 public function __construct() {
22 $this->payment_methods = apply_filters( 'booktics_payment_methods', array() );
23 }
24
25 /**
26 * Get all registered payment methods
27 *
28 * @return array
29 */
30 public function get_payment_methods(): array {
31 return apply_filters( 'booktics_payment_methods', $this->payment_methods );
32 }
33
34 public function get_payment_method( string $id ): ?Payment_Method_Interface {
35 $payment_methods = $this->get_payment_methods();
36 if ( ! isset( $payment_methods[ $id ] ) ) {
37 return null;
38 }
39
40 return new $payment_methods[ $id ]();
41 }
42 }
43