Skip to content

Commit

Permalink
Fixed compatibility issue with latest Magento
Browse files Browse the repository at this point in the history
  • Loading branch information
fraudlabspro committed May 12, 2022
1 parent 31c9ede commit 2771d18
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 23 deletions.
31 changes: 19 additions & 12 deletions Block/Fraudlabsprosmsverification.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function getOrder($id)

public function methodBlock()
{
if($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/active')){
if ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/active')) {
$smsInstruction = ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/sms_instruction')) ? ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/sms_instruction')) : 'You are required to verify your phone number using SMS verification. Please make sure you enter the complete phone number (including the country code) and click on the below button to request for an OTP (One Time Password) SMS.';
$smsDefaultCc = ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/sms_default_cc')) ? ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/sms_default_cc')) : 'US';

Expand All @@ -35,17 +35,24 @@ public function methodBlock()
$siteUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
}

$sms_order_id = (filter_input(INPUT_GET, 'orderid')) ? (filter_input(INPUT_GET, 'orderid')) : '';
$sms_order_id = (filter_input(INPUT_GET, 'id')) ? (filter_input(INPUT_GET, 'id')) : '';
$sms_code = (filter_input(INPUT_GET, 'code')) ? (filter_input(INPUT_GET, 'code')) : '';
$phone = (filter_input(INPUT_GET, 'phone')) ? (filter_input(INPUT_GET, 'phone')) : '';
$response = '';
$errors = [];

if ( $sms_order_id != '' ) {
if ( !empty( $sms_code ) ) {
$order = $this->getOrder($sms_order_id);
if(is_null(json_decode($order->getfraudlabspro_response(), true))){
if($order->getfraudlabspro_response()){
try {
$order = $this->getOrder($sms_order_id);
} catch(\Exception $e) {
return '
<div>
<span>Order not found. Verification failed.</span>
</div>';
}
if ($order->getfraudlabspro_response() === null) {
if ($order->getfraudlabspro_response()) {
$flpdata = $this->_unserialize($order->getfraudlabspro_response());
}
} else {
Expand Down Expand Up @@ -83,7 +90,7 @@ public function methodBlock()
<script language="Javascript">
var phoneNum, defaultCc;
jQuery( document ).ready(function() {
if( jQuery("#sms_phone_cc").length ){
if ( jQuery("#sms_phone_cc").length ) {
defaultCc = jQuery("#sms_phone_cc").val();
} else {
defaultCc = "US";
Expand Down Expand Up @@ -116,14 +123,14 @@ public function methodBlock()
});
jQuery("#resend_otp").click(function() {
if(typeof(Storage) !== "undefined") {
if (typeof(Storage) !== "undefined") {
if (sessionStorage.resent_count) {
sessionStorage.resent_count = Number(sessionStorage.resent_count)+1;
} else {
sessionStorage.resent_count = 1;
}
if(sessionStorage.resent_count == 3){
if (sessionStorage.resent_count == 3) {
jQuery("#sms_err").html("Maximum number of retries to send verification SMS exceeded. Please wait for your OTP code.");
jQuery("#sms_err").show();
jQuery("#get_otp").hide();
Expand All @@ -140,7 +147,7 @@ public function methodBlock()
checkOTP();
});
if(sessionStorage.resent_count >= 3){
if (sessionStorage.resent_count >= 3) {
jQuery("#sms_err").html("Maximum number of retries to send verification SMS exceeded. Please wait for your OTP code.");
jQuery("#sms_err").show();
jQuery("#get_otp").hide();
Expand Down Expand Up @@ -216,7 +223,7 @@ function sms_checkOTP_success(data) {
if (data.includes("FLPOK")) {
jQuery("#sms_verified").val("YES");
jQuery(".btn-checkout").prop("disabled",false);
if(typeof(Storage) !== "undefined") {
if (typeof(Storage) !== "undefined") {
sessionStorage.sms_vrf = "YES";
sessionStorage.resent_count = 0;
}
Expand Down Expand Up @@ -244,7 +251,7 @@ function sms_checkOTP_error() {
jQuery("#sms_err").show();
}
if(sessionStorage.sms_vrf == "YES") {
if (sessionStorage.sms_vrf == "YES") {
jQuery("#sms_verified").val("YES");
jQuery(".btn-checkout").prop("disabled",false);
jQuery("#enter_sms_otp").hide();
Expand Down Expand Up @@ -318,7 +325,7 @@ private function _unserialize($data){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$serializer = $objectManager->create(\Magento\Framework\Serialize\SerializerInterface::class);
return $serializer->unserialize($data);
} else if (class_exists(\Magento\Framework\Unserialize\Unserialize::class)) {
} elseif (class_exists(\Magento\Framework\Unserialize\Unserialize::class)) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$serializer = $objectManager->create(\Magento\Framework\Unserialize\Unserialize::class);
return $serializer->unserialize($data);
Expand Down
4 changes: 2 additions & 2 deletions Block/Fraudlabsprosmsverificationsend.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public function methodBlock()
if ($sms_order_id != "") {
$order = $this->getOrder($sms_order_id);
if ($order->getfraudlabspro_response()) {
if (is_null(json_decode($order->getfraudlabspro_response(), true))){
if ($order->getfraudlabspro_response() === null) {
if ($order->getfraudlabspro_response()){
$flpData = $this->_unserialize($order->getfraudlabspro_response());
}
Expand Down Expand Up @@ -96,7 +96,7 @@ private function _unserialize($data){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$serializer = $objectManager->create(\Magento\Framework\Serialize\SerializerInterface::class);
return $serializer->unserialize($data);
} else if (class_exists(\Magento\Framework\Unserialize\Unserialize::class)) {
} elseif (class_exists(\Magento\Framework\Unserialize\Unserialize::class)) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$serializer = $objectManager->create(\Magento\Framework\Unserialize\Unserialize::class);
return $serializer->unserialize($data);
Expand Down
2 changes: 1 addition & 1 deletion Block/Fraudlabsprosmsverificationverify.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public function methodBlock()
if ( $sms_code != "" ) {
$order = $this->getOrder($sms_order_id);
if ($order->getfraudlabspro_response()) {
if(is_null(json_decode($order->getfraudlabspro_response(), true))){
if ($order->getfraudlabspro_response() === null) {
if($order->getfraudlabspro_response()){
$flpdata = $this->_unserialize($order->getfraudlabspro_response());
}
Expand Down
7 changes: 5 additions & 2 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Revision History for FraudLabs Pro Magento 2
Revision History for FraudLabs Pro SMS Verification Magento 2
1.0.0 2019-05-24
First release.

Expand All @@ -24,4 +24,7 @@ Revision History for FraudLabs Pro Magento 2
Support common messages customization.

1.2.1 2021-10-20
Add new common messages customization.
Add new common messages customization.

1.2.2 2022-05-12
Fix compatibility issue with latest Magento.
6 changes: 3 additions & 3 deletions Controller/Observer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public function sendRequestToFraudLabsProSmsVerification($observer) {
$customerEmail = $order->getCustomerEmail();

if ($order->getfraudlabspro_response()) {
if(is_null(json_decode($order->getfraudlabspro_response(), true))){
if ($order->getfraudlabspro_response() === null) {
if($order->getfraudlabspro_response()){
$data = $this->_unserialize($order->getfraudlabspro_response());
}
Expand All @@ -63,7 +63,7 @@ public function sendRequestToFraudLabsProSmsVerification($observer) {
} else {
$siteUrl = $this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB);
}
$link = $siteUrl . '/fraudlabsprosmsverification?orderid=' . $orderId . '&code=' . $code;
$link = $siteUrl . '/fraudlabsprosmsverification?id=' . $orderId . '&code=' . $code;
if ( strpos( $content, '{email_verification_link}' ) !== false ) {
$content = str_replace( '{email_verification_link}', $link, $content );
}
Expand Down Expand Up @@ -118,7 +118,7 @@ private function _unserialize($data){
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$serializer = $objectManager->create(\Magento\Framework\Serialize\SerializerInterface::class);
return $serializer->unserialize($data);
} else if (class_exists(\Magento\Framework\Unserialize\Unserialize::class)) {
} elseif (class_exists(\Magento\Framework\Unserialize\Unserialize::class)) {
$objectManager = \Magento\Framework\App\ObjectManager::getInstance();
$serializer = $objectManager->create(\Magento\Framework\Unserialize\Unserialize::class);
return $serializer->unserialize($data);
Expand Down
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"name": "hexasoft/module-fraudlabsprosmsverification",
"description": "FraudLabs Pro SMS Verification extension for Magento 2 that help merchants to authenticate the client's identity by sending them a SMS for verification.",
"version": "1.2.1",
"version": "1.2.2",
"type": "magento2-module",
"require": {
"php": "~5.5.0|~5.6.0|~7.0"
"php": ">=5.5"
},
"license": [
"OSL-3.0",
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="../../../../../lib/internal/Magento/Framework/Module/etc/module.xsd">
<module name="Hexasoft_FraudLabsProSmsVerification" setup_version="1.0.0">
<module name="Hexasoft_FraudLabsProSmsVerification" setup_version="1.2.2">
<sequence>
<module name="Magento_Sales"/>
</sequence>
Expand Down

0 comments on commit 2771d18

Please sign in to comment.