Skip to content

Commit

Permalink
Fixed bug for localhost webhook url validation (#257)
Browse files Browse the repository at this point in the history
* Fixed bug for localhost webhook url validation
  • Loading branch information
ramth05 authored Jun 23, 2021
1 parent 3369316 commit 736c928
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,15 @@
# Change Log


## [3.6.0] - 2021-06-17
## [3.6.2] - 2021-06-23

### Changed
### Fixed
- [Fixed webhook localhost url validation](https://github.com/razorpay/razorpay-magento/pull/257).

Fixed webhook localhost url validation.

## [3.6.1] - 2021-06-17

### Changed
### Fixed
Expand Down
8 changes: 6 additions & 2 deletions Observer/AfterConfigSaveObserver.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,15 @@ public function execute(Observer $observer)

$razorpayParams = $this->request->getParam('groups')['razorpay']['fields'];

if(in_array($_SERVER['SERVER_ADDR'], ["127.0.0.1","::1"]))
$domain = parse_url($this->webhookUrl, PHP_URL_HOST);

$domain_ip = gethostbyname($domain);

if (!filter_var($domain_ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4 | FILTER_FLAG_NO_PRIV_RANGE | FILTER_FLAG_NO_RES_RANGE))
{
$this->config->setConfigData('enable_webhook', 0);

$this->logger->info("Can't enable/disable webhook on localhost.");
$this->logger->info("Can't enable/disable webhook on $domain or private ip($domain_ip).");
return;
}

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ panel (System -> Cache Management).

### Note: Don't mix composer and zip install.

### Note: Make sure "zipcode" must be required field for billing and shipping address.**


### Working with GraphQL

Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "razorpay/magento",
"description": "Razorpay Magento 2.0 plugin for accepting payments.",
"version": "3.6.1",
"version": "3.6.2",
"require": {
"php": "~5.5.0|~5.6.0|^7.0",
"razorpay/razorpay": "2.*"
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Razorpay_Magento" setup_version="3.6.1">
<module name="Razorpay_Magento" setup_version="3.6.2">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 736c928

Please sign in to comment.