package org.killbill.billing.payment.core.sm.payments;
import org.killbill.automaton.OperationResult;
import org.killbill.billing.payment.api.PaymentApiException;
import org.killbill.billing.payment.core.sm.PaymentAutomatonDAOHelper;
import org.killbill.billing.payment.core.sm.PaymentStateContext;
import org.killbill.billing.payment.dispatcher.PluginDispatcher;
import org.killbill.billing.payment.plugin.api.PaymentPluginApiException;
import org.killbill.billing.payment.plugin.api.PaymentTransactionInfoPlugin;
import org.killbill.commons.locker.GlobalLocker;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class RefundOperation extends PaymentOperation {
private final Logger logger = LoggerFactory.getLogger(RefundOperation.class);
public RefundOperation(final PaymentAutomatonDAOHelper daoHelper,
final GlobalLocker locker, final PluginDispatcher<OperationResult> paymentPluginDispatcher,
final PaymentStateContext paymentStateContext) throws PaymentApiException {
super(locker, daoHelper, paymentPluginDispatcher, paymentStateContext);
}
@Override
protected PaymentTransactionInfoPlugin doCallSpecificOperationCallback() throws PaymentPluginApiException {
logger.debug("Starting REFUND for payment {} ({} {})", paymentStateContext.getPaymentId(), paymentStateContext.getAmount(), paymentStateContext.getCurrency());
return plugin.refundPayment(paymentStateContext.getAccount().getId(),
paymentStateContext.getPaymentId(),
paymentStateContext.getTransactionId(),
paymentStateContext.getPaymentMethodId(),
paymentStateContext.getAmount(),
paymentStateContext.getCurrency(),
paymentStateContext.getProperties(),
paymentStateContext.getCallContext());
}
}