Before submitting the order, it is a good idea to validate the data being sent, including any custom properties. To do this, you can register a callback function with the OrderViewModel that is executed when the handlePlaceOrder() function is called. You can use the callback function to add validation and error handling.

The code below registers a callback function that validates the widget data. This function first calls the widget’s validate() function. If that function returns true, the callback function adds a custom property to the payment data in the OrderViewModel. If widget.validate() returns false, the callback function adds a validation error to the OrderViewModel.

widget.validate = function {
  return true;
}

widget.order().addValidationCallback(function() {

if (widget.validate()) {
    var customProperties = {genericPaymentId: widget.genericPaymentId};
    widget.genericPayment.customProperties = customProperties;
    widget.updatePayment(widget.genericPayment);
    }
    else {
    widget.order().addValidationError("genericPayment",
      widget.translate('errorMessage'));
  }
});

Copyright © 1997, 2017 Oracle and/or its affiliates. All rights reserved. Legal Notices