Mont Blanc – Mastercard Regex Patch
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
-
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.
-
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/
-
In your new SCA.Extension@1.0.0 module, create a subdirectory called JavaScript.
-
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
-
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' } ] }); } } });
-
Save the file.
Step 2: Prepare the Developer Tools for Your Customizations
-
Open the SCA.Extension@1.0.0 module module.
-
Create a file in this module and name it ns.package.json.
Modules/extensions/SCA.Extension@1.0.0/ns.package.json
-
Build the ns.package.json file using the following code
{ "gulp": { "javascript": [ "JavaScript/*.js" ] } }
-
Save the ns.package.json file.
-
Open the distro.json file.
This file is located in the top-level directory of your SuiteCommerce Advanced source code.
-
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", //...
-
Add
SC.Configuration.Extension
as a dependency to the following entry points of theJavaScript
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" ], //... }, //...
-
-
Save the distro.json file.
Step 3: Test and Deploy Your Extension
-
Test your source code customizations on a local server (see Test SCA Customizations on a Local Server) or deploy them to your NetSuite account (see Deploy SCA Customizations to NetSuite). If you are currently running SCA on a local server, your changes should appear on your local site immediately.
-
Confirm your results.
Upon successful deployment, the new Mastercard regex should be included in your compiled shopping.js, myaccount.js, and checkout.js files.