FormFields
2 years ago
FormTemplate
2 years ago
ActiveCampaign.php
2 years ago
ConstantContact.php
2 years ago
ConvertKit.php
2 years ago
CurrencySwitcher.php
2 years ago
DonationGoal.php
2 years ago
DonationOptions.php
2 years ago
DoubleTheDonation.php
2 years ago
EmailSettings.php
2 years ago
FeeRecovery.php
2 years ago
FormExcerpt.php
2 years ago
FormFeaturedImage.php
2 years ago
FormFieldManager.php
2 years ago
FormFields.php
2 years ago
FormGrid.php
2 years ago
FormMeta.php
2 years ago
FormTaxonomies.php
1 year ago
FormTitle.php
2 years ago
FundsAndDesignations.php
2 years ago
GiftAid.php
2 years ago
Mailchimp.php
2 years ago
MigrateMeta.php
2 years ago
OfflineDonations.php
2 years ago
PaymentGateways.php
2 years ago
PdfSettings.php
2 years ago
PerFormGateways.php
2 years ago
RazorpayPerFormSettings.php
1 year ago
RecurringDonationOptions.php
2 years ago
TermsAndConditions.php
2 years ago
RazorpayPerFormSettings.php
57 lines
| 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 |