| @@ -31,24 +31,16 @@ | ||
| 31 | 31 | return FrmAppHelper::plugin_url() . '/stripe/'; |
| 32 | 32 | } |
| 33 | 33 | |
| 34 | 34 | /** |
| 35 | - * @return bool | |
| 36 | - */ | |
| 37 | - public static function is_debug() { | |
| 38 | - return defined( 'WP_DEBUG' ) && WP_DEBUG; | |
| 39 | - } | |
| 40 | - | |
| 41 | - /** | |
| 42 | 35 | * @param string $function |
| 43 | 36 | * @param array ...$params |
| 37 | + * | |
| 44 | 38 | * @return mixed |
| 45 | 39 | */ |
| 46 | 40 | public static function call_stripe_helper_class( $function, ...$params ) { |
| 47 | - if ( self::should_use_stripe_connect() ) { | |
| 48 | - if ( is_callable( "FrmStrpLiteConnectApiAdapter::$function" ) ) { | |
| 49 | - return FrmStrpLiteConnectApiAdapter::$function( ...$params ); | |
| 50 | - } | |
| 41 | + if ( self::should_use_stripe_connect() && is_callable( "FrmStrpLiteConnectApiAdapter::$function" ) ) { | |
| 42 | + return FrmStrpLiteConnectApiAdapter::$function( ...$params ); | |
| 51 | 43 | } |
| 52 | 44 | return false; |
| 53 | 45 | } |
| 54 | 46 | |
| @@ -56,9 +48,9 @@ | ||
| 56 | 48 | * @return bool true if we're using connect (versus the legacy integration). |
| 57 | 49 | */ |
| 58 | 50 | public static function should_use_stripe_connect() { |
| 59 | 51 | if ( ! class_exists( 'FrmStrpLiteConnectApiAdapter' ) ) { |
| 60 | - require dirname( __FILE__ ) . '/FrmStrpLiteConnectApiAdapter.php'; | |
| 52 | + require __DIR__ . '/FrmStrpLiteConnectApiAdapter.php'; | |
| 61 | 53 | } |
| 62 | 54 | return FrmStrpLiteConnectApiAdapter::initialize_api(); |
| 63 | 55 | } |
| 64 | 56 | |
| @@ -75,11 +67,13 @@ | ||
| 75 | 67 | * @return string |
| 76 | 68 | */ |
| 77 | 69 | public static function get_customer_id_meta_name() { |
| 78 | 70 | $meta_name = '_frmstrp_customer_id'; |
| 71 | + | |
| 79 | 72 | if ( 'test' === self::active_mode() ) { |
| 80 | 73 | $meta_name .= '_test'; |
| 81 | 74 | } |
| 75 | + | |
| 82 | 76 | return $meta_name; |
| 83 | 77 | } |
| 84 | 78 | |
| 85 | 79 | /** |
| @@ -97,32 +91,39 @@ | ||
| 97 | 91 | * |
| 98 | 92 | * @psalm-return 'live'|'test' |
| 99 | 93 | */ |
| 100 | 94 | public static function active_mode() { |
| 101 | - $settings = self::get_settings(); | |
| 102 | - return $settings->settings->test_mode ? 'test' : 'live'; | |
| 95 | + return self::get_settings()->settings->test_mode ? 'test' : 'live'; | |
| 103 | 96 | } |
| 104 | 97 | |
| 105 | 98 | /** |
| 106 | 99 | * Add education about Stripe fees. |
| 107 | 100 | * |
| 101 | + * @param string $content UTM Content for the admin upgrade link. | |
| 102 | + * @param array|false|string $gateway Gateway or list of gateways this applies to. | |
| 103 | + * | |
| 108 | 104 | * @return void |
| 109 | 105 | */ |
| 110 | - public static function fee_education( $medium = 'tip' ) { | |
| 111 | - $license_type = FrmAddonsController::license_type(); | |
| 112 | - if ( in_array( $license_type, array( 'elite', 'business' ), true ) ) { | |
| 106 | + public static function fee_education( $content = 'tip', $gateway = false ) { | |
| 107 | + if ( ! FrmAddonsController::payment_fees_apply( 'stripe' ) ) { | |
| 113 | 108 | return; |
| 114 | 109 | } |
| 115 | 110 | |
| 111 | + $classes = 'frm-light-tip show_stripe'; | |
| 112 | + | |
| 113 | + if ( $gateway && ! array_intersect( (array) $gateway, array( 'stripe' ) ) ) { | |
| 114 | + $classes .= ' frm_hidden'; | |
| 115 | + } | |
| 116 | + | |
| 116 | 117 | FrmTipsHelper::show_tip( |
| 117 | 118 | array( |
| 118 | 119 | 'link' => array( |
| 119 | - 'content' => 'stripe-fee', | |
| 120 | - 'medium' => $medium, | |
| 120 | + 'campaign' => 'stripe-fee', | |
| 121 | + 'content' => $content, | |
| 121 | 122 | ), |
| 122 | 123 | 'tip' => 'Pay as you go pricing: 3% fee per-transaction + Stripe fees.', |
| 123 | 124 | 'call' => __( 'Upgrade to save on fees.', 'formidable' ), |
| 124 | - 'class' => 'frm-light-tip', | |
| 125 | + 'class' => $classes, | |
| 125 | 126 | ), |
| 126 | 127 | 'p' |
| 127 | 128 | ); |
| 128 | 129 | } |
| @@ -132,17 +133,42 @@ | ||
| 132 | 133 | * |
| 133 | 134 | * @return void |
| 134 | 135 | */ |
| 135 | 136 | public static function not_connected_warning() { |
| 137 | + // phpcs:disable Generic.WhiteSpace.ScopeIndent | |
| 136 | 138 | ?> |
| 137 | - <div class="frm_warning_style frm-with-icon"> | |
| 138 | - <?php FrmAppHelper::icon_by_class( 'frm_icon_font frm_alert_icon', array( 'style' => 'width:24px' ) ); ?> | |
| 139 | + <div class="frm_warning_style"> | |
| 139 | 140 | <span> |
| 140 | 141 | <?php |
| 141 | - /* translators: %1$s: Link HTML, %2$s: End link */ | |
| 142 | - printf( esc_html__( 'Credit Cards will not work without %1$sconnecting Stripe%2$s first.', 'formidable' ), '<a href="?page=formidable-settings&t=stripe_settings" target="_blank">', '</a>' ); | |
| 142 | + printf( | |
| 143 | + /* translators: %1$s: Link HTML, %2$s: End link */ | |
| 144 | + esc_html__( 'Credit Cards will not work without connecting %1$sStripe%2$s, %3$sSquare%4$s, or %5$sPayPal%6$s first.', 'formidable' ), | |
| 145 | + // %1$s | |
| 146 | + '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=stripe_settings' ) ) . '" target="_blank">', | |
| 147 | + // %2$s | |
| 148 | + '</a>', | |
| 149 | + // %3$s | |
| 150 | + '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=square_settings' ) ) . '" target="_blank">', | |
| 151 | + // %4$s | |
| 152 | + '</a>', | |
| 153 | + // %5$s | |
| 154 | + '<a href="' . esc_url( admin_url( 'admin.php?page=formidable-settings&t=paypal_settings' ) ) . '" target="_blank">', | |
| 155 | + // %6$s | |
| 156 | + '</a>' | |
| 157 | + ); | |
| 143 | 158 | ?> |
| 144 | 159 | </span> |
| 145 | 160 | </div> |
| 146 | 161 | <?php |
| 162 | + // phpcs:enable Generic.WhiteSpace.ScopeIndent | |
| 163 | + } | |
| 164 | + | |
| 165 | + /** | |
| 166 | + * @deprecated 6.22 | |
| 167 | + * | |
| 168 | + * @return bool | |
| 169 | + */ | |
| 170 | + public static function is_debug() { | |
| 171 | + _deprecated_function( __METHOD__, '6.22' ); | |
| 172 | + return defined( 'WP_DEBUG' ) && WP_DEBUG; | |
| 147 | 173 | } |
| 148 | 174 | } |