use of org.killbill.billing.payment.core.sm.payments.VoidInitiated 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();
}
Aggregations