Documentation Home Quick Start

Broadleaf Commerce offers an out-of-the-box solution that requires little configuration and is easily set up.
The quick start solution implements the [[Accept.js |]] model offered by
This implementation should be useful for those with a simple checkout flow.

You must have completed the Environment Setup before continuing

Adding Checkout Support

These instructions assume integration with the default Heat Clinic Demo Site provided with the framework.

  1. Make sure the JS library is loaded on your checkout page:
<!-- For Sandbox/Testing, use: -->
    <script type="text/javascript" src="" charset="utf-8"></script>
<!-- For Production, use: -->
    <script type="text/javascript" src="" charset="utf-8"></script>
<!-- To resolve the url from the gateway.authorizenet.acceptJsUrl system variable, use: -->
    <script type="text/javascript" th:src="${#authorizenet.getAcceptJsUrl()}" charset="utf-8"></script>
  1. Modify the Payment Form on your checkout page to look something like:
<blc:form id="anet_checkout_form" th:action="@{checkout/authnet/complete}" method="POST">
    <input type="text" id="cardNumber" autocomplete="off" placeholder="Card Number" />
    <input type="text" id="nameOnCard" placeholder="Name on Card" />
    <input type="text" id="cardExpDate" autocomplete="off" placeholder="MM-YYYY" />
    <input type="text" id="securityCode" autocomplete="off" placeholder="CVV" />
    <input type="hidden" name="OPAQUE_DATA_DESCRIPTOR" id="OPAQUE_DATA_DESCRIPTOR"/>
    <input type="hidden" name="OPAQUE_DATA_VALUE" id="OPAQUE_DATA_VALUE"/>
    <input type="submit" id="anet_checkout_form_button" value="Complete Order" />

Note: IMPORTANT! Make sure you don't include the name attribute on sensitive data form elements. If the form is accidentally submitted and name attributes are present, sensitive data can reach your server.

  1. Insert the following Javascript into your checkout html in order to generate the client token and retrieve the payment nonce:
    <script type="text/javascript" th:inline="javascript">

        function sendPaymentDataToAnet() {
            var secureData = {}, authData = {}, cardData = {};

            cardData.cardNumber = document.getElementById('cardNumber').value;
            cardData.month = document.getElementById('cardExpDate').value.substring(0,2);
            cardData.year = document.getElementById('cardExpDate').value.substring(3,7);
            secureData.cardData = cardData;

            authData.clientKey = [[${#authorizenet.getClientKey()}]];
            authData.apiLoginID = [[${#authorizenet.getApiLoginId()}]];
            secureData.authData = authData;

            Accept.dispatchData(secureData, 'responseHandler');
            return false;

        function responseHandler(response) {
            if (response.messages.resultCode === 'Error') {
                for (var i = 0; i < response.messages.message.length; i++) {
                    console.log(response.messages.message[i].code + ':' + response.messages.message[i].text);
            } else {

        function useOpaqueData(responseData) {

You'll also want to create an "on click" listener for submit button on the payment form.
In our example, we'll create a separate Javascript file authnet.js to be loaded later with the following:

$(document).ready(function() {
    $('#anet_checkout_form_button').on("click", function(e) {

Note: the above sample JS assumes jQuery is loaded

  1. Create a Spring MVC Controller to handle the form you created above in order to process the payment nonce and confirm the transaction. It would look something like this:
public class AuthorizeNetCheckoutController extends BroadleafCheckoutController {

    @Resource(name = "blAddressService")
    protected AddressService addressService;

    @RequestMapping(value = "/checkout/authnet/complete")
    public String completeAuthorizeNetCheckout(Model model, HttpServletRequest request, RedirectAttributes redirectAttributes, @PathVariable Map<String, String> pathVars) throws PaymentException, PricingException {
        //Get Cart
        Order cart = CartState.getCart();
        //Get Payment Nonce From Request
        String dataDescriptor = request.getParameter("OPAQUE_DATA_DESCRIPTOR");
        String dataValue = request.getParameter("OPAQUE_DATA_VALUE");

        //Create a new PAYMENT_NONCE Order Payment
        OrderPayment paymentNonce = orderPaymentService.create();

        //Populate Billing Address per UI requirements
        //For this example, we'll copy the address from the temporary Credit Card's Billing address and archive the payment,
        // (since Heat Clinic's checkout template saves and validates the address in a previous section).
        OrderPayment tempPayment = null;
        for (OrderPayment payment : cart.getPayments()) {
            if (PaymentGatewayType.TEMPORARY.equals(payment.getGatewayType()) &&
                    PaymentType.CREDIT_CARD.equals(payment.getType())) {
                tempPayment = payment;

        if (tempPayment != null){
            orderService.removePaymentFromOrder(cart, tempPayment);

        // Create the UNCONFIRMED transaction for the payment
        PaymentTransaction transaction = orderPaymentService.createTransaction();
        transaction.setRawResponse(" Accept.js Payment Nonce");
        transaction.getAdditionalFields().put("OPAQUE_DATA_DESCRIPTOR", dataDescriptor);
        transaction.getAdditionalFields().put("OPAQUE_DATA_VALUE", dataValue);

        orderService.addPaymentToOrder(cart, paymentNonce, null);, true);

        return processCompleteCheckoutOrderFinalized(redirectAttributes);


When processCompleteCheckoutOrderFinalized is called, the checkout workflow is invoked and the ValidateAndConfirmPaymentActivity
is executed to confirm the payment nonce.


At this point, all the configuration should be complete and you are now ready to test your integration with Accept.js. Add something to your cart and proceed with checkout.

Note: When checking out, make sure that your credit card expiration date is in the form of MM-YYYY.

Note: To view transactions, go to the Sandbox and click on "Search" at the top. You can view both settled and unsettled transactions this way.