Magento 2 Order Verification

Magento 2 Order Verification extension help prevent fake orders by validating the orders at the checkout, via OTP sent to the mobile numbers.

 

Table of Content

  1. Extension Installation Guide
  2. Msg91 Registration
  3. Twilio Registration
  4. Create Twilio WhatsApp Templates
  5. Textlocal Registration
  6. Configuration
  7. API Settings
  8. OTP Custom Message Settings
  9. Order Verification via OTP in Frontend

 

  1. Extension Installation
  • For Magento Marketplace Customers
    • Create a folder structure in Magento root as app/code/Meetanshi/OrderVerify
    • Download and extract the zip folder and upload our extension files to the app/code/Meetanshi/OrderVerify via FTP.
    • Login to your SSH and run below commands step by step:
      • composer require twilio/sdk
      • php bin/magento setup:upgrade
      • For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy
      • For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f
      • php bin/magento cache:flush

 

  • For Meetanshi Customers
    • Extract the zip folder and upload our extension to the root of your Magento 2 directory via FTP.
    • Login to your SSH and run below commands step by step:
      • composer require twilio/sdk
      • php bin/magento setup:upgrade
      • For Magento version 2.0.x to 2.1.x - php bin/magento setup:static-content:deploy
      • For Magento version 2.2.x & above - php bin/magento setup:static-content:deploy –f
      • php bin/magento cache:flush

Note: Don’t forget to install Twilio library even if you are not using Twilio SMS gateway for our extension.

 

  1. Msg91 Registration
    The extension allows the configuration of the Msg91 SMS gateway to send OTP for the order verification. If you choose to use Msg91 SMS gateway integration, follow the steps below to get the sender ID and API key.


 

  • You will get and code or a magic link in the Email to verify the Email address.




 

  • You will be asked to enter the mobile number for verification.




 

  • Enter the OTP to verify the mobile number and you will be registered successfully. Login with the credentials.




 

  • Under the settings, you can find the Sender ID which you need to copy and paste in the Magento configuration.




 

  • Now move to API, where you can find the API key for the Magento configuration.





 

  • You can find the Message type under the Send SMS tab. Select the SMS type in Msg91 configuration in Magento as per your requirement.




 

  1. Twilio Registration
    If you are going to use Twilio as an SMS gateway to send OTP for the order verification, you need to register with the Twilio to get Account SID, Auth Token and Twilio Phone Number.
  • First of all, Sign Up for the Twilio account. Add the details and click to get started.




 

  • After the Email verification, enter your mobile number and click to “Verify”.



 

  • Once you click “Verify”, you will get an OTP on the added mobile number. Enter the OTP and verify the mobile number. Now move to Settings > General where you can see API details both for live and testing. Copy the Account SID and Auth Token to use them in Magento backend configuration for Twilio account.




 

  • Now, click three dots from the left sidebar, go to Programmable SMS and click Build under the Learn and Build option. From here, you can get Twilio phone number to use for sending the SMSs. Click on the “Get a number” button.




 

  • You will get a number to choose. Click “Choose This Number”.




 

  • Once you click the button, you will get a Twilio phone number. Copy this number and set it in the Magento backend configuration for Twilio account. 


 

  1.  Twilio WhatsApp Message Templates
    You need to configure the same Twilio settings to get API details for Twilio WhatsApp. Once you are done, login to your Twilio account, go to https://www.twilio.com/console/sms/whatsapp/senders/, and click on “Submit a WhatsApp Sender”.

 

Clicking the button will ask you to create your first Business Profile. Complete the form and submit your WhatsApp Business Profile request along with message templates.

Note: All Display Names must show consistency with the Business Name on the Facebook Business Manager provided. See Display Name rules.

 

 

Twilio will use this information to provision your Business Profile in the next 5-10 business days.

Once your WhatsApp Sender is approved and enabled, you can see your WhatsApp number with the approved status.

Under the “WhatsApp Templates” option, click “Submit a message template”.

 

Make use of variables to add the message text same as Magento backend. Follow this guide to write the message template in a proper format.

 

 

  1. Textlocal Registration
    The extension allows configuration of the Textlocal SMS gateway to send OTP for the order verification. If you choose to use Textlocal SMS gateway integration, follow the steps below to get the sender ID and API key.

  • After the registration, you will get a verification link in your registered Email ID, clicking the link will land you to add additional information page. Here, add the account details and submit to activate your Textlocal account.

 

  • Navigate to Settings > API Keys and create new key to use. Copy the created API Key and paste it in Magento 2 extension configuration.

 

  • Now move to Settings > All Settings and click on “Sender Names” to get your sender name.

 

  • You can copy your Textlocal sender name from here and paste it in Magento 2 extension configuration.

 

  • Textlocal requires to create message template to send OTP verification message. Go to Send > Templates & Drafts and click to create and request new SMS template.

 

  • You have to create new message template for both the send and resend OTP SMS enabled in Magento 2 Order Verification extension configuration. Enter title, select category and sender name. Set message text same as SMS text in extension configuration. You have to create new SMS template in Textlocal for both the OTP texts in Magento 2. For example, create a message template for “Send OTP Text” in Textlocal having exactly the same SMS text as in Magento 2 configuration.

 

  • For the dynamic values in text message input, click “Insert Restricted Template Items”. Click “Insert an Input Box” and it will open a popup to create new placeholder for the dynamic value. Add placeholder text name and set maximum length for the dynamic value. Insert it into the SMS text and while sending the OTP message, this placeholder will match the variable in Magento 2 SMS text and replace it with the real value.

 

  • Once message templates have been created and submitted for each SMS notification, it will take approximately a week to be approved by the Textlocal. You can send OTP SMSs only after the message templates are approved by the Textlocal.
  1. Configuration
    For configuring the extension, login to Magento 2, move to Stores > Configuration > Order Verification where you can find various settings to enable the extension.
  • Order Verification: Enable the Order Verification extension from here.
  • Enable for Payment methods: Select payment methods for which you want to enable order verification.
  • Allowed Customer Groups: Select the customer groups for which you want to enable order verification.


  

  1. API Settings
    Here, you can select the SMS gateway to send SMS for the Order Verification via OTP. Make SMS gateway API settings here.
  • API URL: Enter API URL provided by the SMS gateway while registration.
  • Message Type: Select the message type you are going to send for the Order Verification.
  • API Provider: Select a preferred SMS gateway API.
  • Sender ID: Enter sender ID provided by the SMS gateway while registration.
  • API Key: Enter API key provided by the SMS gateway while registration.
  • OTP Length: Set length of the OTP for the order verification.


For Other SMS API:
If you are going to use custom SMS API other than Msg91, Twilio or Textlocal, you have to add your CURL URL as below:

 

Format: https://yoursmsapi.com/sms/submitsms.jsp?user=yourusername&senderid=yoursenderid&key=yoursmskey&mobile={mobile}&message={msg}

Sample CURL URL:
https://foxxsms.com/sms/submitsms.jsp?user=METANSHI&senderid=FOXGLV&accusage=6&key=587e05afbcXX&mobile={mobile}&message={msg}

  1. OTP Custom Message Settings
    Here, you can set custom text for the OTP SMS you will be sending to the customers for the order verification.
  • Send OTP Text: Add text for sending OTP to the customers.
  • Resend OTP Text: Enter text for the resend OTP message to the customers.


  

  1. Order Verification in Frontend
    Once the extension is enabled, whenever a customer of a specific customer group tries to place an order using a specified payment method, he gets OTP SMS or WhatsApp message as API settings configured in the backend on the registered mobile number for the Order Verification.


 

  • OTP SMS on Registered Mobile Number
    Customers get OTP SMS on their registered mobile number.


  

  • OTP WhatsApp Message on Registered Mobile Number
    Customers get OTP WhatsApp message on their registered mobile number if configured Twilio WhatsApp API settings for the order verification.

 

  • Order Verification Successful
    Once customer enters the correct OTP and click verify button, order verification success message is displayed and order gets placed successfully.