/* * #%L * BroadleafCommerce Framework Web * %% * Copyright (C) 2009 - 2013 Broadleaf Commerce * %% * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * #L% */ package org.broadleafcommerce.core.payment.service; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; import org.broadleafcommerce.common.money.Money; import org.broadleafcommerce.common.payment.PaymentTransactionType; import org.broadleafcommerce.common.payment.PaymentType; import org.broadleafcommerce.common.payment.dto.PaymentRequestDTO; import org.broadleafcommerce.common.payment.dto.PaymentResponseDTO; import org.broadleafcommerce.common.payment.service.PaymentGatewayRollbackService; import org.broadleafcommerce.common.vendor.service.exception.PaymentException; import org.springframework.stereotype.Service; /** * @author Elbert Bautista (elbertbautista) */ @Service("blNullPaymentGatewayRollbackService") public class NullPaymentGatewayRollbackServiceImpl implements PaymentGatewayRollbackService { protected static final Log LOG = LogFactory.getLog(NullPaymentGatewayRollbackServiceImpl.class); @Override public PaymentResponseDTO rollbackAuthorize(PaymentRequestDTO transactionToBeRolledBack) throws PaymentException { if (LOG.isTraceEnabled()) { LOG.trace("Null Payment Gateway - Rolling back authorize transaction with amount: " + transactionToBeRolledBack.getTransactionTotal()); } return new PaymentResponseDTO(PaymentType.CREDIT_CARD, NullPaymentGatewayType.NULL_GATEWAY) .rawResponse("rollback authorize - successful") .successful(true) .paymentTransactionType(PaymentTransactionType.REVERSE_AUTH) .amount(new Money(transactionToBeRolledBack.getTransactionTotal())); } @Override public PaymentResponseDTO rollbackCapture(PaymentRequestDTO transactionToBeRolledBack) throws PaymentException { throw new PaymentException("The Rollback Capture method is not supported for this module"); } @Override public PaymentResponseDTO rollbackAuthorizeAndCapture(PaymentRequestDTO transactionToBeRolledBack) throws PaymentException { if (LOG.isTraceEnabled()) { LOG.trace("Null Payment Gateway - Rolling back authorize and capture transaction with amount: " + transactionToBeRolledBack.getTransactionTotal()); } return new PaymentResponseDTO(PaymentType.CREDIT_CARD, NullPaymentGatewayType.NULL_GATEWAY) .rawResponse("rollback authorize and capture - successful") .successful(true) .paymentTransactionType(PaymentTransactionType.VOID) .amount(new Money(transactionToBeRolledBack.getTransactionTotal())); } @Override public PaymentResponseDTO rollbackRefund(PaymentRequestDTO transactionToBeRolledBack) throws PaymentException { throw new PaymentException("The Rollback Refund method is not supported for this module"); } }