PayPal Payments Cause Error at Checkout

In Mont Blanc releases of SuiteCommerce Advanced, customers may receive the following error message when placing orders using PayPal as the payment option:

Your order is below the minimum order amount of 0.

Although the error message is displayed, a sales order is created in NetSuite. To prevent this error message from displaying, extend the past() method as described in this procedure. Note that the error message is returned intermittently and is related to how PayPal returns sales amounts. You should apply this patch to avoid any cases of the error message being returned incorrectly.

Note:

Before proceeding, familiarize yourself with the Best Practices for Customizing SCA.

Step 1: Extend the OrderWizard.Module.PaymentMethod.PayPal.js File

  1. This step explains how to extend the OrderWizard.Module.PaymentMethod.PayPal.js file, which is located in the OrderWizard.Module.PaymentMethod module. You can download the code samples described in this procedure here: PaymentMethod.PayPal.Extension@1.0.0.zip

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

  2. Open this directory and create a subdirectory to maintain your customizations.

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

    Modules/extensions/PaymentMethod.PayPal.Extension@1.0.0

  3. In your new PaymentMethod.PayPal.Extension@1.0.0 module, create a subdirectory called JavaScript.

    Modules/extensions/PaymentMethod.PayPal.Extension@1.0.0/JavaScript

  4. In your new JavaScript subdirectory, create a JavaScript file to extend OrderWizard.Module.PaymentMethod.PayPal.js .

    Name this file according to best practices. For example:

    OrderWizard.Module.PaymentMethod.PayPal.Extension.js

  5. Open this file and extend the past() method as shown in the following code snippet.

                    define('OrderWizard.Module.PaymentMethod.PayPal.Extension'
    , [
       'OrderWizard.Module.PaymentMethod.PayPal'
       , 'underscore'
    ]
    , function (
        OrderWizardModulePaymentMethodPayPal
    ,    _
    )
    {
    'use strict';
       _.extend(OrderWizardModulePaymentMethodPayPal.prototype,
          {
             past: function()
             {
                if (this.isActive() && !this.wizard.isPaypalComplete() && !this.wizard.hidePayment() && this.wizard.model.get('confirmation').isNew())
                {
    
                   var checkout_url = Session.get('touchpoints.checkout')
                   ,   joint = ~checkout_url.indexOf('?') ? '&' : '?'
                   ,   previous_step_url = this.wizard.getPreviousStepUrl();
    
                   checkout_url += joint + 'paypal=T&next_step=' + previous_step_url;
    
                   Backbone.history.navigate(previous_step_url, {trigger: false, replace: true});
    
                   document.location.href = checkout_url;
    
                   throw new Error('This is not an error. This is just to abort javascript');
                }
             }
          });
    }
    ); 
    
                  
  6. Save the file.

Step 2: Prepare the Developer Tools for Your Extension

  1. Open the PaymentMethod.PayPal.Extension@1.0.0 module.

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

    Modules/extensions/PaymentMethod.PayPal.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.

    This ensures that the Gulp tasks include your extension when you deploy. In this example, the extensions/PaymentMethod.PayPal.Extension module is added at the beginning of the list of modules. However, you can add the module anywhere in the modules object. The order of precedence in this list does not matter.

                    {
        "name": "SuiteCommerce Advanced Elbrus",
        "version": "2.0",
        "buildToolsVersion": "1.3.0",
        "folders": {
            "modules": "Modules",
            "suitecommerceModules": "Modules/suitecommerce",
            "extensionsModules": "Modules/extensions",
            "thirdPartyModules": "Modules/third_parties",
            "distribution": "LocalDistribution",
            "deploy": "DeployDistribution"
        },
             "modules": {
                   "extensions/PaymentMethod.PayPal.Extension": "1.0.0",
                   "suitecommerce/Account": "2.3.0",
                   "suitecommerce/Address": "2.4.0",
                   ... 
    
                  
  7. Include the module definition (“OrderWizard.Module.PaymentMethod.PayPal”) in the dependencies array of the Shopping application of the JavaScript object.

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

                    "tasksConfig": {
    //...
    "javascript": [
             //...
             {
                   "entryPoint": "SC.Shopping.Starter",
                   "exportFile": "shopping.js",
                   "dependencies": [
                      //...
                         "Newsletter",
                         "ProductDetailToQuote",
                         //..
                         "OrderWizard.Module.PaymentMethod.PayPal.Extension"
                   ], 
    
                  
    Note:

    Best practice is to place any new modules at the bottom of the list in the dependencies array.

  8. Save the distro.json file.

Step 3: Test and Deploy Your Extension

  1. 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.

  2. Confirm your results.

    An order placed in your web store using PayPal as the payment method should not display an error after the customer clicks Place Order. The customer should see an order confirmation and summary.

Related Topics

SCA Patches

General Notices