PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.18.0.1
GiveWP – Donation Plugin and Fundraising Platform v4.18.0.1
4.18.0.1 4.18.0 4.17.0 4.16.9 4.16.8.1 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 All 258 releases
give / src / PaymentGateways / Gateways / Stripe / StripePaymentElementGateway / Actions / UpdateStripeFormBuilderSettingsMeta.php

UpdateStripeFormBuilderSettingsMeta.php in GiveWP – Donation Plugin and Fundraising Platform 4.18.0.1, at src/PaymentGateways/Gateways/Stripe/StripePaymentElementGateway/Actions/UpdateStripeFormBuilderSettingsMeta.php

46 lines 1.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\PaymentGateways\Gateways\Stripe\StripePaymentElementGateway\Actions;
4
5 use Give\DonationForms\Models\DonationForm;
6
7 /**
8 * Update Stripe settings on backwards compatible form meta.
9 *
10 * @since 3.0.0
11 */
12 class UpdateStripeFormBuilderSettingsMeta
13 {
14 /**
15 * @since 3.0.0
16 * @param DonationForm $form
17 */
18 public function __invoke(DonationForm $form)
19 {
20 $paymentGatewaysBlock = $form->blocks->findByName('givewp/payment-gateways');
21 if (!$paymentGatewaysBlock) {
22 return;
23 }
24
25 [
26 'stripeUseGlobalDefault' => $stripeUseGlobalDefault,
27 'stripeAccountId' => $stripeAccountId
28 ] = $paymentGatewaysBlock->getAttributes() + ['stripeUseGlobalDefault' => true, 'stripeAccountId' => ''];
29
30 if (is_bool($stripeUseGlobalDefault)) {
31 give()->form_meta->update_meta(
32 $form->id,
33 "give_stripe_per_form_accounts",
34 $stripeUseGlobalDefault ? 'disabled' : 'enabled'
35 );
36
37 if ($stripeUseGlobalDefault === false && $stripeAccountId && strpos(
38 $stripeAccountId,
39 'acct_'
40 ) !== false) {
41 give()->form_meta->update_meta($form->id, "_give_stripe_default_account", $stripeAccountId);
42 }
43 }
44 }
45 }
46