Skip to content

Commit

Permalink
Add default country code for SMS sending
Browse files Browse the repository at this point in the history
  • Loading branch information
fraudlabspro committed Jan 26, 2021
1 parent 043f404 commit 0dc9b68
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 6 deletions.
12 changes: 10 additions & 2 deletions Block/Fraudlabsprosmsverification.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function methodBlock()
{
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';

if (substr($this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB), -1) == '/') {
$siteUrl = substr($this->_storeManager->getStore()->getBaseUrl(\Magento\Framework\UrlInterface::URL_TYPE_WEB), 0, -1);
Expand Down Expand Up @@ -72,11 +73,17 @@ public function methodBlock()
<script src="//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.5/js/intlTelInput.min.js"></script>
<link rel="stylesheet" href="//cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.5/css/intlTelInput.min.css">
<script language="Javascript">
var phoneNum;
var phoneNum, defaultCc;
jQuery( document ).ready(function() {
if( jQuery("#sms_phone_cc").length ){
defaultCc = jQuery("#sms_phone_cc").val();
} else {
defaultCc = "US";
}
phoneNum = window.intlTelInput(document.querySelector("#phone_number"), {
utilsScript: "https://cdnjs.cloudflare.com/ajax/libs/intl-tel-input/17.0.5/js/utils.min.js",
separateDialCode: true
separateDialCode: true,
initialCountry: defaultCc
});
});
Expand Down Expand Up @@ -251,6 +258,7 @@ function sms_checkOTP_error() {
<input type="hidden" name="sms_ip_addr" id="sms_ip_addr" value="">
<input type="hidden" name="sms_order_id" id="sms_order_id" value="' . $sms_order_id . '"></div>
<input type="hidden" name="sms_code" id="sms_code" value="' . $sms_code . '">
<input type="hidden" name="sms_phone_cc" id="sms_phone_cc" value="' . $smsDefaultCc . '">
</div>
<div id="sms_success_status" class="page-width" style="text-align: center; border: 1px solid silver; padding: 10px; background-color: #22B14C; color: white; display: none;"><span>Your phone has been successfully verified.</span></div>
<br /><br />';
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,7 @@ Revision History for FraudLabs Pro Magento 2
Implement SMS OTP timeout.

1.1.1 2020-12-17
Improve phone number entering.
Improve phone number entering.

1.1.2 2021-01-26
Add default country code for SMS sending.
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"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.1.1",
"version": "1.1.2",
"type": "magento2-module",
"require": {
"php": "~5.5.0|~5.6.0|~7.0"
Expand Down
8 changes: 6 additions & 2 deletions etc/adminhtml/system.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,15 @@
<label>SMS OTP Timeout</label>
<comment><![CDATA[Timeout feature for OTP value in seconds. Default is 3600 seconds(1 hour). Max timeout is 86400 seconds(24 hours).]]></comment>
</field>
<field id="email_subject" translate="label" type="text" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="sms_default_cc" translate="label" type="select" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Default Country Code For SMS Sending</label>
<source_model>Magento\Directory\Model\Config\Source\Country</source_model>
</field>
<field id="email_subject" translate="label" type="text" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Email Subject</label>
<comment><![CDATA[Subject or title of the mail.]]></comment>
</field>
<field id="email_body" translate="label" type="textarea" sortOrder="7" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="email_body" translate="label" type="textarea" sortOrder="8" showInDefault="1" showInWebsite="1" showInStore="1">
<label>Email Body</label>
<comment><![CDATA[Content of the mail. The <strong>{email_verification_link}</strong> tag will be automatically replaced with the page URL for SMS verification, and must not be removed from the email body.]]></comment>
</field>
Expand Down

0 comments on commit 0dc9b68

Please sign in to comment.