Broadleaf Microservices
  • v1.0.0-latest-prod

Environment Setup

Adding this module to your project

Once you have registered your account with Checkout.com, add the Broadleaf Checkout.com Maven dependency to your PaymentTransactionServices project.

<dependency>
    <groupId>com.broadleafcommerce.microservices</groupId>
    <artifactId>broadleaf-checkout-com</artifactId>
</dependency>
Note
The dependency’s version will be pulled from the Broadleaf release train pom.xml.

Configuration

Gather the values of Public Key and Secret Key from Checkout.com and populate following properties:

broadleaf:
  checkout-com:
    public-key: {Your Checkout.com Public Key}
    secret-key: {Your Checkout.com Secret Key}

Cart Operation Service Configuration

Add the following properties to declare the CHECKOUT_COM gateway as an available payment method.

broadleaf:
  cartoperation:
    service:
      checkout:
        checkout-payment-method-options:
          - payment-method-type: CREDIT_CARD
            payment-method-gateway-type: CHECKOUT_COM

CHECKOUT_COM should be added to the following property to declare when transactions for this gateway should be executed, relative to other gateways, during checkout processing.

broadleaf:
  cartoperation:
    service:
      checkout:
        payment-gateway-priorities:
          - ...
          - CHECKOUT_COM
          - ...

By default, Authorize transactions are executed by CartOps during checkout. If you wish to execute AuthorizeAndCapture transactions instead, define the following property:

broadleaf:
  cartoperation:
    service:
      checkout:
        checkout-transaction-types:
          CHECKOUT_COM: AUTHORIZE_AND_CAPTURE
Note

This property is application-discriminated, allowing different values to be provided on a per-tenant or per-application basis using the following property paths:

  • broadleaf.cartoperation.service.checkout.tenant.mytenant.checkout-transaction-types.CHECKOUT_COM=AUTHORIZE_AND_CAPTURE

  • broadleaf.cartoperation.service.checkout.application.myapplication.checkout-transaction-types.CHECKOUT_COM=AUTHORIZE_AND_CAPTURE

"mytenant" & "myapplication" being the Broadleaf Tenant and Application ids.

Configuration for OrderOperationServices

CHECKOUT_COM should be added to the following property to declare when ReverseAuthorize or Refund transactions for this gateway should be executed, relative to other gateways, when cancelling a fulfillment.

broadleaf:
  orderoperation:
    service:
      payment:
        cancel-payment-gateway-priorities:
          - ...
          - CHECKOUT_COM
          - ...

CHECKOUT_COM should be added to the following property to declare when Capture transactions for this gateway should be executed, relative to other gateways, when capturing payment for a fulfillment.

broadleaf:
  orderoperation:
    service:
      payment:
        capture-payment-gateway-priorities:
          - ...
          - CHECKOUT_COM
          - ...

CHECKOUT_COM should be added to the following property to declare when Refund transactions for this gateway should be executed, relative to other gateways, when refunding payment for a fulfillment return.

broadleaf:
  orderoperation:
    service:
      payment:
        refund-payment-gateway-priorities:
          - ...
          - CHECKOUT_COM
          - ...

Configuring Webhooks to Understand Transaction Results

To understand the results for Capture, Refund, & Reverse-Authorize (Void) transactions, Checkout.com requires that you leverage webhooks. The webhooks can be setup & configured in the Checkout.com admin hub using the following steps:

  • Go to Settings → Channels.

  • Select "New Webhook" from the Webhook Section.

  • Enter your endpoint url where you want to receive webhook notifications.

  • Note: This url should point to PaymentTransactionService’s webhook-handling endpoint.

  • Select event types and then select Create to complete the configuration.

The following event types supported by default:

  • payment_approved

  • payment_declined

  • payment_captured

  • payment_capture_declined

  • payment_refunded

  • payment_refund_declined

  • payment_voided

  • payment_void_declined

If you need to add the support for other events you have to implement the com.broadleafcommerce.payment.service.gateway.constants.CheckoutComWebhookType interface and override com.broadleafcommerce.payment.service.gateway.webhooks.DefaultCheckoutComGatewayWebhookHandler.getWebhookType to return your implementation.

For example:

    public enum MyWebhookTypesEnum implements CheckoutComWebhookType {

        PAYMENT_CANCELED("payment_canceled", "Void", true);

        private final String webhookType;
        private final String transactionType;
        private final boolean isSuccessful;

        WebhookTypesEnum(String webhookType, String transactionType, boolean isSuccessful) {
            this.webhookType = webhookType;
            this.transactionType = transactionType;
            this.isSuccessful = isSuccessful;
        }

        @Override
        public TransactionType toBroadleafTransactionType() {
            // PAYMENT_CANCELED is equivalent of REVERSE_AUTH in Broadleaf
            if (this == PAYMENT_CANCELED) {
                return DefaultTransactionTypes.REVERSE_AUTH;
            }

            return EnumUtils.getEnumIgnoreCase(DefaultTransactionTypes.class, transactionType);
        }
    }

    ...

    @Nullable
    @Override
    protected CheckoutComWebhookType getWebhookType(
            @lombok.NonNull CheckoutComWebhookResponse webhookResponse) {
        CheckoutComWebhookType type = super.getWebhookType(webhookResponse);
        return type != null ? type : EnumUtils.getEnumIgnoreCase(MyWebhookTypesEnum.class,
                webhookResponse.getType());
    }