| 1 |
<?php |
| 2 |
|
| 3 |
namespace Give\PaymentGateways\Stripe; |
| 4 |
|
| 5 |
use Give\PaymentGateways\Stripe\Admin\AccountManagerSettingField; |
| 6 |
use Give\PaymentGateways\Stripe\Admin\CustomizeAccountField; |
| 7 |
|
| 8 |
/** |
| 9 |
* Class DonationFormSettingPage |
| 10 |
* |
| 11 |
* @package Give\PaymentGateways\Stripe |
| 12 |
* |
| 13 |
* @since 2.13.0 |
| 14 |
*/ |
| 15 |
class DonationFormSettingPage |
| 16 |
{ |
| 17 |
/** |
| 18 |
* @since 2.13.0 |
| 19 |
* |
| 20 |
* @param array $settings Settings List. |
| 21 |
* @param $formId |
| 22 |
* |
| 23 |
* @return array |
| 24 |
*/ |
| 25 |
function __invoke($settings, $formId) |
| 26 |
{ |
| 27 |
if ( ! $this->canRegisterTab()) { |
| 28 |
return $settings; |
| 29 |
} |
| 30 |
|
| 31 |
$settings['stripe_form_account_options'] = [ |
| 32 |
'id' => 'stripe_form_account_options', |
| 33 |
'title' => esc_html__('Stripe Account', 'give'), |
| 34 |
'icon-html' => '<i class="fab fa-stripe-s"></i>', |
| 35 |
'fields' => $this->getMainSettingFields($formId), |
| 36 |
]; |
| 37 |
|
| 38 |
return $settings; |
| 39 |
} |
| 40 |
|
| 41 |
/** |
| 42 |
* @since 2.13.0 |
| 43 |
* |
| 44 |
* @param int $formId |
| 45 |
* |
| 46 |
* @return array[] |
| 47 |
*/ |
| 48 |
private function getMainSettingFields($formId) |
| 49 |
{ |
| 50 |
$formAccount = give_is_setting_enabled( |
| 51 |
give_get_meta( |
| 52 |
$formId, |
| 53 |
'give_stripe_per_form_accounts', |
| 54 |
true |
| 55 |
) |
| 56 |
); |
| 57 |
|
| 58 |
return [ |
| 59 |
[ |
| 60 |
'id' => 'give_stripe_per_form_accounts', |
| 61 |
'type' => 'give_stripe_per_form_accounts', |
| 62 |
'callback' => [give(CustomizeAccountField::class), 'handle'], |
| 63 |
'default' => CustomizeAccountField::DEFAULT_VALUE, |
| 64 |
], |
| 65 |
[ |
| 66 |
'id' => 'give_manage_accounts', |
| 67 |
'type' => 'give_manage_accounts', |
| 68 |
'callback' => [give(AccountManagerSettingField::class), 'handle'], |
| 69 |
'wrapper_class' => $formAccount ? 'give-stripe-manage-account-options' : 'give-stripe-manage-account-options give-hidden', |
| 70 |
], |
| 71 |
[ |
| 72 |
'name' => 'donation_stripe_per_form_docs', |
| 73 |
'type' => 'docs_link', |
| 74 |
'url' => 'http://docs.givewp.com/stripe-free', |
| 75 |
'title' => esc_html__('Stripe Documentation', 'give'), |
| 76 |
], |
| 77 |
]; |
| 78 |
} |
| 79 |
|
| 80 |
/** |
| 81 |
* @since 2.13.0 |
| 82 |
* @return bool |
| 83 |
*/ |
| 84 |
private function canRegisterTab() |
| 85 |
{ |
| 86 |
return give_stripe_is_any_payment_method_active(); |
| 87 |
} |
| 88 |
} |
| 89 |
|