Users Not Redirected to External Payment System

In Vinson releases of SCA, if a user chooses an external payment method during checkout, SuiteCommerce Advanced does not correctly open the third-party payment system.

When a user clicks the Continue to External Payment button during checkout, instead of sending the user to the external payment system, SCA redirects the user to the beginning of the checkout process.

This error occurs because SuiteCommerce Advanced deprecated the existing payment processing status result, HOLD, in 17.1. Instead, SCA uses a new status result, PENDING. As a result, any SCA sites implementing the Vinson release requires this patch to use third-party payment systems.

To implement this patch, you must extend the prototype object for the ExternalPaymentModel function that includes the _isDone(), _validateRecordStatus(), and _validateStatusFromRequest() methods. This function is located in ExternalPayment.Model.js for the ExternalPayment module. You can download the code samples described in this procedure here: UsersNotRedirectedExternalPaymentSystem.zip.

Step 1: Extend the ExternalPayment.Model.js File

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

    Give this directory a name similar to the module being customized. For example, create Modules/extensions/ExternalPaymentExtension@1.0.0

  2. In your new ExternalPaymentExtension@1.0.0 directory, create a subdirectory called JavaScript.

    For example: Modules/extensions/ExternalPaymentExtension@1.0.0/SuiteScript

  3. In your new JavaScript subdirectory, create a JavaScript file to extend ExternalPayment.Model.js.

    Name this file according to best practices. For example:

    ExternalPayment.Model.Extension.js

  4. Open this file and extend the ExternalPaymentModel() function as shown in the following code snippet.

                    define('ExternalPayment.Model.Extension'
    ,  [
          'ExternalPayment.Model'
        , 'underscore'
    ]
    ,  function (
          ExternalPaymentModel
          , _
       )
    {
      'use strict';
    
        _.extend(ExternalPaymentModel.prototype,
        {
          _isDone: function (request, record_type)
          {
            var status = this._getStatusFromRequest(request, record_type)
            ,  status_accept_value = this._getConfiguration(record_type, 'statusAcceptValue','ACCEPT')
            ,  status_hold_value = this._getConfiguration(record_type, 'statusHoldValue', 'HOLD')
            
            //Added by payment
            ,  status_pending_value = this._getConfiguration(record_type, 'statusPendingValue', 'PENDING')
            return status === status_accept_value || status === status_hold_value || status === status_pending_value;
          }
        
          , _validateRecordStatus: function (record)
          {
            //Modified by Payment
            return record.getFieldValue('paymenteventholdreason') === 'FORWARD_REQUESTED';
          }
    
          , _validateStatusFromRequest: function (request, record_type)
          {
            var status = this._getStatusFromRequest(request, record_type)
            ,  status_accept_value = this._getConfiguration(record_type, 'statusAcceptValue' , 'ACCEPT')
            ,  status_hold_value = this._getConfiguration(record_type, 'statusHoldValue' , 'HOLD')
    
            //Added by Payment
            ,  status_pending_value = this._getConfiguration(record_type, 'statusPendingValue', 'PENDING')
            ,  status_reject_value = this._getConfiguration(record_type, 'statusRejectValue' , 'REJECT');
    
            //Modified by Payment
            return status === status_accept_value || status === status_pending_value || status === status_hold_value || status === status_reject_value;
          }
        });
    }); 
    
                  
  5. Save the file.

Step 2: Prepare the Developer Tools For Your Customization

  1. Open your new ExternalPaymentExtension@1.0.0 module directory.

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

    Modules/extensions/ExternalPaymentExtension@1.0.0/ns.package.json

  3. Build the ns.package.json file using the following code:

                    {
      "gulp": {
        "ssp-libraries": [
          "SuiteScript/*.js"
        ]
      }
    } 
    
                  
  4. Open the distro.json file. This is located in your root directory.

  5. Add your custom modules to the modules object.

    Your code should look similar to the following example:

                    {
        "name": "SuiteCommerce Advanced Vinson Release",
        "version": "2.0",
        "buildToolsVersion": "1.2.1",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
        "modules": {
            "extensions/ExternalPaymentExtension": "1.0.0",
            "suitecommerce/Account": "2.2.0", 
                ... 
    
                  

    This ensures that the Gulp tasks include your module when you deploy. In this example, the custom modules are added at the beginning of the list of modules. However, you can add the modules anywhere in the modules object. The order of precedence in this list does not matter.

  6. Add ExternalPaymentExtension as a dependency to SCA entry point within the SC.Checkout.Starter entrypoint of the JavaScript array.

    Your distro.json file should look similar to the following:

                    "tasksConfig": {
    // ...
    "javascript": [
             // ...
             {
               "entryPoint": "SC.Checkout.Starter",
               "exportFile": "checkout.js",
                 "dependencies": [
                   "ExternalPaymentExtension",
                   "Backbone.View.Plugins",
                   "jQuery.html",
                   // ...
                   ],
                   // ... 
    
                  
  7. Add your custom module to the ssp-libraries dependencies.

    Your code should look similar to the following example:

                    "ssp-libraries": {
                "entryPoint": "SCA",
                "dependencies": [
                    "ExternalPaymentExtension",
                    "Application",
                    "Account.ForgotPassword.ServiceController",
                    // ...
                   ], 
    
                  
  8. Save the distro.json file.

Step 3: Test and Deploy Your Customization

  1. Deploy your source code customizations to your NetSuite account and test the functionality. See Deploy SCA Customizations to NetSuite for details.

    Note:

    Since this patch modifies a SuiteScript file, changes are not visible in your local environment. SuiteScript files run on the server and must be deployed to NetSuite to take effect.

  2. Confirm your results.

    Upon successful deployment, the checkout process redirects to an external payment system when you click Continue to External Payment.

Related Topics

SCA Patches

General Notices