PluginProbe
GiveWP – Donation Plugin and Fundraising Platform / 4.16.8.1
GiveWP – Donation Plugin and Fundraising Platform v4.16.8.1
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 2.3.1 2.3.2 2.30.0 All 255 releases
give / src / FormMigration / Steps / RazorpayPerFormSettings.php

RazorpayPerFormSettings.php in GiveWP – Donation Plugin and Fundraising Platform 4.16.8.1, at src/FormMigration/Steps/RazorpayPerFormSettings.php

57 lines 1.6 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
7 /**
8 * @since 3.14.0
9 */
10 class RazorpayPerFormSettings extends FormMigrationStep
11 {
12 /**
13 * @since 3.14.0
14 */
15 public function canHandle(): bool
16 {
17 return $this->formV2->isRazorpayPerFormSettingsEnabled();
18 }
19
20 /**
21 * @since 3.14.0
22 */
23 public function process()
24 {
25 $oldFormId = $this->formV2->id;
26
27 $paymentGatewaysBlock = $this->fieldBlocks->findByName('givewp/payment-gateways');
28
29 $paymentGatewaysBlock->setAttribute('razorpayUseGlobalSettings',
30 $this->getMetaValue($oldFormId, 'razorpay_per_form_account_options', 'global') === 'global');
31
32 $paymentGatewaysBlock->setAttribute('razorpayLiveKeyId',
33 $this->getMetaValue($oldFormId, 'razorpay_per_form_live_merchant_key_id', ''));
34 $paymentGatewaysBlock->setAttribute('razorpayLiveSecretKey',
35 $this->getMetaValue($oldFormId, 'razorpay_per_form_live_merchant_secret_key', ''));
36
37 $paymentGatewaysBlock->setAttribute('razorpayTestKeyId',
38 $this->getMetaValue($oldFormId, 'razorpay_per_form_test_merchant_key_id', ''));
39 $paymentGatewaysBlock->setAttribute('razorpayTestSecretKey',
40 $this->getMetaValue($oldFormId, 'razorpay_per_form_test_merchant_secret_key', ''));
41 }
42
43 /**
44 * @since 3.14.0
45 */
46 private function getMetaValue(int $formId, string $metaKey, $defaultValue)
47 {
48 $metaValue = give()->form_meta->get_meta($formId, $metaKey, true);
49
50 if ( ! $metaValue) {
51 return $defaultValue;
52 }
53
54 return $metaValue;
55 }
56 }
57