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