Mont Blanc – Mastercard Regex Patch

This topic applies to

Applies to

SuiteCommerce Advanced | Mont Blanc

In your Mont Blanc implementation, the credit card regex values reside in the SC.Configuration.js file, which is located in the SCA module. To update this module, extend the paymentmethods array as described in this section. You can download the code samples described in this procedure here: MastercardBinRegex---MontBlancCodeSample.zip.

Step 1: Extend the SC.Configuration.js File

  1. If you have not done so already, create a directory to store your custom module.

    Following best practices, name this directory extensions and place it in your Modules directory. Depending on your implementation and customizations, this directory might already exist.

  2. Open your extensions directory and create a custom module to maintain your configuration modifications.

    Give this directory a unique name that is similar to the module being customized. For example:

    Modules/extensions/SCA.Extension@1.0.0/
  3. In your new SCA.Extension@1.0.0 module, create a subdirectory called JavaScript.

  4. In your JavaScript subdirectory, create a new JavaScript file.

    Give this file a unique name that is similar to the file being modified. For example:

    Modules/extensions/SCA.Extension@1.0.0/JavaScript/SC.Configuration.Extension.js
  5. Open this file and set it up to extend the paymentmethods array of the SC.Configuration.js file.

    Important

    This must be wrapped inside the mountToApp() method.


    Your file should match the following code snippet:

    define(
       'SC.Configuration.Extension'
    ,   [
    
          'SC.Configuration'
    
       ,   'underscore'
       ]
    
    ,   function (
    
          Configuration
    
       ,   _
       )
    {
    
       'use strict';
    
       return {
          mountToApp: function ()
          {
             _.extend(Configuration,
             {
                paymentmethods: [
                   {
                      key: '5,5,1555641112' //'VISA'
                   ,   regex: /^4[0-9]{12}(?:[0-9]{3})?$/
                   }
                ,   {
                      key: '4,5,1555641112' //'Master Card'
                   ,   regex: /^(5[1-5][0-9]{14}|2(2(2[1-9]|[3-9][0-9])|[3-6][0-9][0-9]|7([0-1][0-9]|20))[0-9]{12})$/
                   }
                ,   {
                      key: '6,5,1555641112' //'American Express'
                   ,   regex: /^3[47][0-9]{13}$/
                   }
                ,   {
                      key: '3,5,1555641112' // 'Discover'
                   ,   regex: /^6(?:011|5[0-9]{2})[0-9]{12}$/
                   }
                ,   {
                      key: '16,5,1555641112' // 'Maestro'
                   ,   regex: /^(?:5[0678]\d\d|6304|6390|67\d\d)\d{8,15}$/
                   }
                ,   {
                      key: '17,3,1555641112' // External
                   ,   description: 'This company allows both private individuals and businesses to accept payments over the Internet'
                   }
                ]
             });   
          }
       }
    });      
  6. Save the file.

Step 2: Prepare the Developer Tools for Your Customizations

  1. Open the SCA.Extension@1.0.0 module module.

  2. Create a file in this module and name it ns.package.json.

    Modules/extensions/SCA.Extension@1.0.0/ns.package.json
  3. Build the ns.package.json file using the following code

    {
        "gulp": {
            "javascript": [
                "JavaScript/*.js"
            ]
        }
    }
  4. Save the ns.package.json file.

  5. Open the distro.json file.

    This file is located in the top-level directory of your SuiteCommerce Advanced source code.

  6. Add your custom module to the modules object to ensure that the Gulp tasks include your extension when you deploy.

    Your code should look similar to the following example:

    {
        "name": "SuiteCommerce Advanced Mont Blanc",
        "version": "2.0",
        "buildToolsVersion": "1.1.0",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
        "modules": {
            "extensions/SCA.Extension": "1.0.0",
            "suitecommerce/Account": "2.1.0",
                       //...
  7. Add SC.Configuration.Extension as a dependency to the following entry points of the JavaScript object:

    • SC.Shopping.Starter

    • SC.MyAccount.Starter

    • SC.Checkout.Starter

    Your code should look similar to the following example:

    //...
    "javascript": [
        {
            "entryPoint": "SC.Shopping.Starter",
            "exportFile": "shopping.js",
            "dependencies": [
                "Backbone.View.Plugins",
                            //...
                            "SC.Configuration.Extension"
                      ],
             //...
             },
        {
            "entryPoint": "SC.MyAccount.Starter",
            "exportFile": "myaccount.js",
            "dependencies": [
                "Backbone.View.Plugins",
                            //...
                            "SC.Configuration.Extension"
                      ],
             //...
             },
        {
            "entryPoint": "SC.Checkout.Starter",
            "exportFile": "checkout.js",
            "dependencies": [
                "Backbone.View.Plugins",
                            //...
                            "SC.Configuration.Extension"
                      ],
             //...
             },
    //...
  8. Save the distro.json file.

Step 3: Test and Deploy Your Extension

  1. Test your source code customizations on a local server (see SCA on a Local Server) or deploy them to your NetSuite account (see Deploy to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.

  2. Confirm your results.

    Upon successful deployment, the new Mastercard regex should be included in your compiled shopping.js, myaccount.js, and checkout.js files.