Search in sources :

Example 1 with AuthorizeOperation

use of org.killbill.billing.payment.core.sm.payments.AuthorizeOperation in project killbill by killbill.

the class PaymentAutomatonRunner method run.

public UUID run(final PaymentStateContext paymentStateContext, final PaymentAutomatonDAOHelper daoHelper, @Nullable final String currentStateNameOrNull, final TransactionType transactionType) throws PaymentApiException {
    final String currentStateName = MoreObjects.firstNonNull(currentStateNameOrNull, paymentSMHelper.getInitStateNameForTransaction());
    final OperationCallback operationCallback;
    final LeavingStateCallback leavingStateCallback;
    final EnteringStateCallback enteringStateCallback;
    Boolean includeDeletedPaymentMethod = Boolean.FALSE;
    switch(transactionType) {
        case PURCHASE:
            operationCallback = new PurchaseOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new PurchaseInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new PurchaseCompleted(daoHelper, paymentStateContext);
            break;
        case AUTHORIZE:
            operationCallback = new AuthorizeOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new AuthorizeInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new AuthorizeCompleted(daoHelper, paymentStateContext);
            break;
        case CAPTURE:
            operationCallback = new CaptureOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new CaptureInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new CaptureCompleted(daoHelper, paymentStateContext);
            break;
        case VOID:
            operationCallback = new VoidOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new VoidInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new VoidCompleted(daoHelper, paymentStateContext);
            includeDeletedPaymentMethod = Boolean.TRUE;
            break;
        case REFUND:
            operationCallback = new RefundOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new RefundInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new RefundCompleted(daoHelper, paymentStateContext);
            includeDeletedPaymentMethod = Boolean.TRUE;
            break;
        case CREDIT:
            operationCallback = new CreditOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new CreditInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new CreditCompleted(daoHelper, paymentStateContext);
            break;
        case CHARGEBACK:
            operationCallback = new ChargebackOperation(daoHelper, locker, paymentPluginDispatcher, paymentConfig, paymentStateContext);
            leavingStateCallback = new ChargebackInitiated(daoHelper, paymentStateContext);
            enteringStateCallback = new ChargebackCompleted(daoHelper, paymentStateContext);
            includeDeletedPaymentMethod = Boolean.TRUE;
            break;
        default:
            throw new IllegalStateException("Unsupported transaction type " + transactionType);
    }
    runStateMachineOperation(currentStateName, transactionType, leavingStateCallback, operationCallback, enteringStateCallback, includeDeletedPaymentMethod, paymentStateContext, daoHelper);
    return paymentStateContext.getPaymentId();
}
Also used : RefundOperation(org.killbill.billing.payment.core.sm.payments.RefundOperation) PurchaseOperation(org.killbill.billing.payment.core.sm.payments.PurchaseOperation) VoidOperation(org.killbill.billing.payment.core.sm.payments.VoidOperation) CaptureCompleted(org.killbill.billing.payment.core.sm.payments.CaptureCompleted) RefundInitiated(org.killbill.billing.payment.core.sm.payments.RefundInitiated) AuthorizeCompleted(org.killbill.billing.payment.core.sm.payments.AuthorizeCompleted) AuthorizeOperation(org.killbill.billing.payment.core.sm.payments.AuthorizeOperation) CreditCompleted(org.killbill.billing.payment.core.sm.payments.CreditCompleted) ChargebackInitiated(org.killbill.billing.payment.core.sm.payments.ChargebackInitiated) PurchaseInitiated(org.killbill.billing.payment.core.sm.payments.PurchaseInitiated) CreditInitiated(org.killbill.billing.payment.core.sm.payments.CreditInitiated) RefundCompleted(org.killbill.billing.payment.core.sm.payments.RefundCompleted) CreditOperation(org.killbill.billing.payment.core.sm.payments.CreditOperation) PurchaseCompleted(org.killbill.billing.payment.core.sm.payments.PurchaseCompleted) CaptureOperation(org.killbill.billing.payment.core.sm.payments.CaptureOperation) LeavingStateCallback(org.killbill.automaton.State.LeavingStateCallback) VoidCompleted(org.killbill.billing.payment.core.sm.payments.VoidCompleted) EnteringStateCallback(org.killbill.automaton.State.EnteringStateCallback) CaptureInitiated(org.killbill.billing.payment.core.sm.payments.CaptureInitiated) ChargebackOperation(org.killbill.billing.payment.core.sm.payments.ChargebackOperation) VoidInitiated(org.killbill.billing.payment.core.sm.payments.VoidInitiated) ChargebackCompleted(org.killbill.billing.payment.core.sm.payments.ChargebackCompleted) OperationCallback(org.killbill.automaton.Operation.OperationCallback) AuthorizeInitiated(org.killbill.billing.payment.core.sm.payments.AuthorizeInitiated)

Aggregations

OperationCallback (org.killbill.automaton.Operation.OperationCallback)1 EnteringStateCallback (org.killbill.automaton.State.EnteringStateCallback)1 LeavingStateCallback (org.killbill.automaton.State.LeavingStateCallback)1 AuthorizeCompleted (org.killbill.billing.payment.core.sm.payments.AuthorizeCompleted)1 AuthorizeInitiated (org.killbill.billing.payment.core.sm.payments.AuthorizeInitiated)1 AuthorizeOperation (org.killbill.billing.payment.core.sm.payments.AuthorizeOperation)1 CaptureCompleted (org.killbill.billing.payment.core.sm.payments.CaptureCompleted)1 CaptureInitiated (org.killbill.billing.payment.core.sm.payments.CaptureInitiated)1 CaptureOperation (org.killbill.billing.payment.core.sm.payments.CaptureOperation)1 ChargebackCompleted (org.killbill.billing.payment.core.sm.payments.ChargebackCompleted)1 ChargebackInitiated (org.killbill.billing.payment.core.sm.payments.ChargebackInitiated)1 ChargebackOperation (org.killbill.billing.payment.core.sm.payments.ChargebackOperation)1 CreditCompleted (org.killbill.billing.payment.core.sm.payments.CreditCompleted)1 CreditInitiated (org.killbill.billing.payment.core.sm.payments.CreditInitiated)1 CreditOperation (org.killbill.billing.payment.core.sm.payments.CreditOperation)1 PurchaseCompleted (org.killbill.billing.payment.core.sm.payments.PurchaseCompleted)1 PurchaseInitiated (org.killbill.billing.payment.core.sm.payments.PurchaseInitiated)1 PurchaseOperation (org.killbill.billing.payment.core.sm.payments.PurchaseOperation)1 RefundCompleted (org.killbill.billing.payment.core.sm.payments.RefundCompleted)1 RefundInitiated (org.killbill.billing.payment.core.sm.payments.RefundInitiated)1