Skip to content

Commit

Permalink
Merge pull request #581 from razorpay/auth-validation-checks
Browse files Browse the repository at this point in the history
PO-272 validation for instrumentation
  • Loading branch information
abdulwahidsharief authored Jan 13, 2025
2 parents 864d26a + 6979d38 commit f505eea
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
6 changes: 5 additions & 1 deletion includes/plugin-instrumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,11 @@ public function getDefaultProperties($timestamp = true)
}

$paymentSettings = get_option('woocommerce_razorpay_settings');
if ($paymentSettings !== false)
if (($paymentSettings !== false) and
(isset($paymentSettings['key_id']) === true) and
(empty($paymentSettings['key_id']) === false) and
(isset($paymentSettings['key_secret']) === true) and
(empty($paymentSettings['key_secret']) === false))
{
$api = new Api($paymentSettings['key_id'], $paymentSettings['key_secret']);

Expand Down
5 changes: 5 additions & 0 deletions woo-razorpay.php
Original file line number Diff line number Diff line change
Expand Up @@ -460,6 +460,11 @@ public function init_form_fields()
$api = $this->getRazorpayApiInstance();
}

if (empty($key_id) === true)
{
return;
}

$merchantPreferences = $api->request->request('GET', 'accounts/me/features');
if (isset($merchantPreferences) === false or
isset($merchantPreferences['assigned_features']) === false)
Expand Down

0 comments on commit f505eea

Please sign in to comment.