PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.15.2
GiveWP – Donation Plugin and Fundraising Platform v4.15.2
4.16.8 4.16.7.2 4.16.7.1 4.16.7 4.16.6.1 4.16.6 4.16.5.1 4.16.5 4.16.4 4.16.3 4.16.2 4.16.1 4.16.0 4.15.5 4.15.4 4.15.3 4.15.2 4.15.1 4.15.0 2.3.0 2.3.1 2.3.2 2.30.0 2.31.0 2.31.1 All 253 releases
give / src / FormMigration / Steps / FeeRecovery.php
FeeRecovery.php
67 lines 2.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace Give\FormMigration\Steps;
4
5 use Give\FormMigration\Contracts\FormMigrationStep;
6 use Give\Framework\Blocks\BlockModel;
7
8 class FeeRecovery extends FormMigrationStep
9 {
10
11 /**
12 * @since 3.0.0
13 */
14 public function process()
15 {
16 $feeRecoverySettings = $this->formV2->getFeeRecoverySettings();
17
18 if (empty($feeRecoverySettings) || (
19 $feeRecoverySettings['useGlobalSettings'] === true &&
20 !give_is_setting_enabled(give_get_option('give_fee_recovery', 'disabled'))
21 )) {
22 return;
23 }
24
25 if ($feeRecoverySettings['useGlobalSettings']) {
26 $feeRecoverySettings = $this->getGlobalSettings();
27 }
28
29 $feeRecoveryBlock = BlockModel::make([
30 'name' => 'givewp-fee-recovery/fee-recovery',
31 'attributes' => $feeRecoverySettings,
32 ]);
33 $this->fieldBlocks->insertAfter('givewp/donation-amount', $feeRecoveryBlock);
34 }
35
36 /**
37 * @since 3.0.0
38 */
39 private function getGlobalSettings(): array
40 {
41 return [
42 'useGlobalSettings' => true,
43 'feeSupportForAllGateways' => give_get_option('give_fee_configuration', 'all_gateways') === 'all_gateways',
44 'perGatewaySettings' => [],
45 'feePercentage' => (float)give_get_option('give_fee_percentage', 2.9),
46 'feeBaseAmount' => (float)give_get_option('give_fee_base_amount', 0.30),
47 'maxFeeAmount' => (float)give_get_option(
48 'give_fee_maximum_fee_amount',
49 give_format_decimal(['amount' => '0.00'])
50 ),
51 'includeInDonationSummary' => give_get_option('give_fee_breakdown', 'enabled') === 'enabled',
52 'donorOptIn' => give_get_option('give_fee_mode', 'donor_opt_in') === 'donor_opt_in',
53 'feeCheckboxLabel' => give_get_option(
54 'give_fee_checkbox_label',
55 __(
56 'I\'d like to help cover the transaction fees of {fee_amount} for my donation.',
57 'give-fee-recovery'
58 )
59 ),
60 'feeMessage' => give_get_option(
61 'give_fee_explanation',
62 __('Plus an additional {fee_amount} to cover gateway fees.', 'give-fee-recovery')
63 ),
64 ];
65 }
66 }
67