Skip to content

Commit

Permalink
Implement SMS OTP timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
fraudlabspro committed Sep 3, 2020
1 parent 792e60b commit f5c9075
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Block/Fraudlabsprosmsverificationsend.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function getOrder($id)
public function methodBlock()
{
$apiKey = ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/api_key')) ? $this->getConfig()->getValue('fraudlabsprosmsverification/active_display/api_key') : 'API Key cannot be empty.';
$otpTimeout = ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/otp_timeout')) ? $this->getConfig()->getValue('fraudlabsprosmsverification/active_display/otp_timeout') : 3600;
if ($apiKey == 'Phone number cannot be empty.') return 'API Key cannot be empty.';
$tel = (filter_input(INPUT_POST, 'tel')) ? (filter_input(INPUT_POST, 'tel')) : 'Phone number cannot be empty.';
if ($tel == 'Phone number cannot be empty.') return 'Phone number cannot be empty.';
Expand All @@ -38,6 +39,7 @@ public function methodBlock()
$params['tel'] = '+' . $params['tel'];
$params['mesg'] = ($this->getConfig()->getValue('fraudlabsprosmsverification/active_display/sms_template')) ? $this->getConfig()->getValue('fraudlabsprosmsverification/active_display/sms_template') : 'Hi, your OTP for Magento is {otp}.';
$params['mesg'] = str_replace(['{', '}'], ['<', '>'], $params['mesg']);
$params['otp_timeout'] = $otpTimeout;
$url = 'https://api.fraudlabspro.com/v1/verification/send';

$query = '';
Expand Down
5 changes: 4 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,7 @@ Revision History for FraudLabs Pro Magento 2
Minor fixes.

1.0.2 2019-12-26
Bug fixes.
Bug fixes.

1.1.0 2020-09-02
Implement SMS OTP timeout.
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.0.2",
"version": "1.1.0",
"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 @@ -27,11 +27,15 @@
<label>SMS Template</label>
<comment><![CDATA[Template for SMS. Use <strong>{otp}</strong> for the generated OTP. The maximum length for SMS template must be <strong>less than 140 characters</strong>.]]></comment>
</field>
<field id="email_subject" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="otp_timeout" translate="label" type="text" sortOrder="5" showInDefault="1" showInWebsite="1" showInStore="1">
<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">
<label>Email Subject</label>
<comment><![CDATA[Subject or title of the mail.]]></comment>
</field>
<field id="email_body" translate="label" type="textarea" sortOrder="6" showInDefault="1" showInWebsite="1" showInStore="1">
<field id="email_body" translate="label" type="textarea" sortOrder="7" 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
1 change: 1 addition & 0 deletions etc/config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
<api_key></api_key>
<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.</sms_instruction>
<sms_template>Hi, your OTP for Magento is {otp}.</sms_template>
<otp_timeout>3600</otp_timeout>
<email_subject>Action Required: SMS Verification is required to process the order.</email_subject>
<email_body>Dear Customer, Thanks for your business. Before we can continue processing your order, you may require you to click on the link to complete the SMS verification: {email_verification_link} Thank you.</email_body>
</general>
Expand Down

0 comments on commit f5c9075

Please sign in to comment.