| 1 |
<?php |
| 2 |
if ( ! defined( 'ABSPATH' ) ) { |
| 3 |
die( 'You are not allowed to call this page directly.' ); |
| 4 |
} |
| 5 |
|
| 6 |
class FrmSquareLiteAppHelper { |
| 7 |
|
| 8 |
/** |
| 9 |
* @var FrmSquareLiteSettings|null |
| 10 |
*/ |
| 11 |
private static $settings; |
| 12 |
|
| 13 |
/** |
| 14 |
* @return string |
| 15 |
*/ |
| 16 |
public static function plugin_path() { |
| 17 |
return FrmAppHelper::plugin_path() . '/square/'; |
| 18 |
} |
| 19 |
|
| 20 |
/** |
| 21 |
* @return string |
| 22 |
*/ |
| 23 |
public static function plugin_folder() { |
| 24 |
return basename( self::plugin_path() ); |
| 25 |
} |
| 26 |
|
| 27 |
/** |
| 28 |
* @return string |
| 29 |
*/ |
| 30 |
public static function plugin_url() { |
| 31 |
return FrmAppHelper::plugin_url() . '/square/'; |
| 32 |
} |
| 33 |
|
| 34 |
/** |
| 35 |
* @return FrmSquareLiteSettings |
| 36 |
*/ |
| 37 |
public static function get_settings() { |
| 38 |
if ( ! isset( self::$settings ) ) { |
| 39 |
self::$settings = new FrmSquareLiteSettings(); |
| 40 |
} |
| 41 |
return self::$settings; |
| 42 |
} |
| 43 |
|
| 44 |
/** |
| 45 |
* @return string |
| 46 |
* |
| 47 |
* @psalm-return 'live'|'test' |
| 48 |
*/ |
| 49 |
public static function active_mode() { |
| 50 |
$settings = self::get_settings(); |
| 51 |
return $settings->settings->test_mode ? 'test' : 'live'; |
| 52 |
} |
| 53 |
|
| 54 |
/** |
| 55 |
* Add education about Stripe fees. |
| 56 |
* |
| 57 |
* @return void |
| 58 |
*/ |
| 59 |
public static function fee_education( $medium = 'tip', $gateway = false ) { |
| 60 |
$license_type = FrmAddonsController::license_type(); |
| 61 |
if ( in_array( $license_type, array( 'elite', 'business' ), true ) ) { |
| 62 |
return; |
| 63 |
} |
| 64 |
|
| 65 |
$classes = 'frm-light-tip show_square'; |
| 66 |
if ( $gateway && ! array_intersect( (array) $gateway, array( 'square' ) ) ) { |
| 67 |
$classes .= ' frm_hidden'; |
| 68 |
} |
| 69 |
|
| 70 |
FrmTipsHelper::show_tip( |
| 71 |
array( |
| 72 |
'link' => array( |
| 73 |
'content' => 'square-fee', |
| 74 |
'medium' => $medium, |
| 75 |
), |
| 76 |
'tip' => 'Pay as you go pricing: 3% fee per-transaction + Square fees.', |
| 77 |
'call' => __( 'Upgrade to save on fees.', 'formidable' ), |
| 78 |
'class' => $classes, |
| 79 |
), |
| 80 |
'p' |
| 81 |
); |
| 82 |
} |
| 83 |
} |
| 84 |
|