PluginProbe
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More / 6.28
Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More v6.28
6.35 6.34 6.33.1 6.33 6.32.1 6.32 6.31 6.25 6.25.1 6.26 6.26.1 6.27 6.28 6.29 6.3 6.3.1 6.3.2 6.30 6.4 6.4.1 6.4.2 6.5 6.5.1 6.5.2 6.5.3 All 141 releases
formidable / stripe / models / FrmStrpLitePaymentTypeHandler.php

FrmStrpLitePaymentTypeHandler.php in Formidable Forms – WordPress Form Builder for Contact Forms, Calculators, Quizzes & More 6.28, at stripe/models/FrmStrpLitePaymentTypeHandler.php

83 lines 2.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2 if ( ! defined( 'ABSPATH' ) ) {
3 die( 'You are not allowed to call this page directly.' );
4 }
5
6 /**
7 * @since 6.5, introduced in v3.1 of the Stripe add on.
8 */
9 class FrmStrpLitePaymentTypeHandler {
10
11 /**
12 * @var array
13 */
14 private static $types_by_action_id = array();
15
16 /**
17 * When no payment method types are added, default to automatic.
18 *
19 * @since 6.5, introduced in v3.1 of the Stripe add on.
20 *
21 * @param WP_Post $action
22 *
23 * @return bool
24 */
25 public static function should_use_automatic_payment_methods( $action ) {
26 return ! self::get_payment_method_types( $action );
27 }
28
29 /**
30 * Get the payment method types for a target Stripe action.
31 *
32 * @since 6.5, introduced in v3.1 of the Stripe add on.
33 *
34 * @param WP_Post $action
35 *
36 * @return string[] An empty array is treated as automatic.
37 */
38 public static function get_payment_method_types( $action ) {
39 if ( ! isset( self::$types_by_action_id[ $action->ID ] ) ) {
40 self::$types_by_action_id[ $action->ID ] = self::get_filtered_payment_method_types( $action );
41 }
42 return self::$types_by_action_id[ $action->ID ];
43 }
44
45 /**
46 * @since 6.5, introduced in v3.1 of the Stripe add on.
47 *
48 * @param WP_Post $action
49 *
50 * @return string[]
51 */
52 private static function get_filtered_payment_method_types( $action ) {
53 /**
54 * Allow users to filter payment method types to add possible other options like "us_bank_account".
55 * An empty array is treated as automatic.
56 *
57 * @since 6.5, introduced in v3.1 of the Stripe add on.
58 *
59 * @param array<string> $payment_method_types
60 * @param array $args {
61 *
62 * @type WP_Post $action
63 * }
64 */
65 $payment_method_types = apply_filters(
66 'frm_stripe_payment_method_types',
67 array(),
68 array(
69 'action' => $action,
70 'form_id' => $action->menu_order,
71 )
72 );
73
74 if ( ! is_array( $payment_method_types ) ) {
75 _doing_it_wrong( __METHOD__, 'Payment method types should always be an array. All other values are invalid.', '3.1' );
76 // Fallback to automatic when an invalid value is used.
77 $payment_method_types = array();
78 }
79
80 return $payment_method_types;
81 }
82 }
83