Skip to content

Commit

Permalink
added validation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
abdulwahidsharief committed Dec 20, 2024
1 parent eb425a2 commit 34b8341
Showing 1 changed file with 35 additions and 26 deletions.
61 changes: 35 additions & 26 deletions woo-razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,8 @@ public function toggleRtbWidget($action ,$widgetEnabled = false)
return;
}

if (empty($rtbEnable) === false)
if ((empty($rtbEnable) === false) and
(isset($rtbEnable['rtb_eligibility']) === true))
{
if ($rtbEnable['rtb_eligibility'] === true)
{
Expand Down Expand Up @@ -844,38 +845,46 @@ protected function triggerValidationInstrumentation($data)

public function autoPostInstallationCheck()
{
$response = $this->rzpPostInstallationCall('evaluate');

$checkout360Available = ($response['checkout360_status'] === true) ? 'yes' : 'no';
try
{
$response = $this->rzpPostInstallationCall('evaluate');

update_option('rzp_checkout360_status', $checkout360Available);
$checkout360Available = ((isset($response['checkout360_status']) === true) and ($response['checkout360_status'] === true)) ? 'yes' : 'no';

// remove all checkou360 settings
if ($response['merchant_status'] === 'existing_checkout360_merchant' and
$checkout360Available === 'no')
{
$checkout360Fields = [
'enable_1cc',
'enable_1cc_test_mode',
'enable_1cc_pdp_checkout',
'enable_1cc_mini_cart_checkout',
'rzp_cod_intelligence_enable'
];
$optionKey = parent::get_option_key();
$savedData = get_option($optionKey);
update_option('rzp_checkout360_status', $checkout360Available);

foreach ($checkout360Fields as $field)
// remove all checkout360 settings
if ((isset($response['merchant_status']) === true) and
($response['merchant_status'] === 'existing_checkout360_merchant') and
($checkout360Available === 'no'))
{
if ($field === 'rzp_cod_intelligence_enable')
$checkout360Fields = [
'enable_1cc',
'enable_1cc_test_mode',
'enable_1cc_pdp_checkout',
'enable_1cc_mini_cart_checkout',
'rzp_cod_intelligence_enable'
];
$optionKey = parent::get_option_key();
$savedData = get_option($optionKey);

foreach ($checkout360Fields as $field)
{
delete_option($field);
}
else
{
$savedData[$field] = 'no';
if ($field === 'rzp_cod_intelligence_enable')
{
delete_option($field);
}
else
{
$savedData[$field] = 'no';
}
}
update_option($optionKey, apply_filters('woocommerce_settings_api_sanitized_fields_' . $this->id, $savedData), 'yes');
}
update_option($optionKey, apply_filters('woocommerce_settings_api_sanitized_fields_' . $this->id, $savedData), 'yes');
}
catch (\Exception $e)
{
rzpLogError($e->getMessage());
}
}

Expand Down

0 comments on commit 34b8341

Please sign in to comment.