use of org.killbill.billing.control.plugin.api.OnFailurePaymentControlResult in project killbill by killbill.
the class ControlPluginRunner method executePluginOnFailureCalls.
public OnFailurePaymentControlResult executePluginOnFailureCalls(final Account account, final UUID paymentMethodId, final String pluginName, final UUID paymentAttemptId, final UUID paymentId, final String paymentExternalKey, final UUID transactionId, final String paymentTransactionExternalKey, final PaymentApiType paymentApiType, final TransactionType transactionType, final HPPType hppType, final BigDecimal amount, final Currency currency, final BigDecimal processedAmount, final Currency processedCurrency, final boolean isApiPayment, final List<String> paymentControlPluginNames, final Iterable<PluginProperty> pluginProperties, final CallContext callContext) {
final UUID accountId = account != null ? account.getId() : null;
final PaymentControlContext inputPaymentControlContext = new DefaultPaymentControlContext(accountId, paymentMethodId, pluginName, paymentAttemptId, paymentId, paymentExternalKey, transactionId, paymentTransactionExternalKey, paymentApiType, transactionType, hppType, amount, currency, processedAmount, processedCurrency, isApiPayment, callContext);
DateTime candidate = null;
Iterable<PluginProperty> inputPluginProperties = pluginProperties;
for (final String controlPluginName : paymentControlPluginNames) {
final PaymentControlPluginApi plugin = paymentControlPluginRegistry.getServiceForName(controlPluginName);
if (plugin != null) {
try {
log.debug("Calling onSuccessCall of plugin {}", controlPluginName);
final OnFailurePaymentControlResult result = plugin.onFailureCall(inputPaymentControlContext, inputPluginProperties);
log.debug("Successful executed onSuccessCall of plugin {}", controlPluginName);
if (result == null) {
// Nothing returned by the plugin
continue;
}
if (candidate == null) {
candidate = result.getNextRetryDate();
} else if (result.getNextRetryDate() != null) {
candidate = candidate.compareTo(result.getNextRetryDate()) > 0 ? result.getNextRetryDate() : candidate;
}
if (result.getAdjustedPluginProperties() != null) {
inputPluginProperties = result.getAdjustedPluginProperties();
}
} catch (final PaymentControlApiException e) {
log.warn("Error during onFailureCall for plugin='{}', paymentExternalKey='{}'", controlPluginName, inputPaymentControlContext.getPaymentExternalKey(), e);
return new DefaultFailureCallResult(candidate, inputPluginProperties);
}
}
}
return new DefaultFailureCallResult(candidate, inputPluginProperties);
}
use of org.killbill.billing.control.plugin.api.OnFailurePaymentControlResult in project killbill by killbill.
the class OperationControlCallback method executePluginOnFailureCalls.
private DateTime executePluginOnFailureCalls(final List<String> paymentControlPluginNames, final PaymentControlContext paymentControlContext) {
final OnFailurePaymentControlResult result = controlPluginRunner.executePluginOnFailureCalls(paymentStateContext.getAccount(), paymentControlContext.getPaymentMethodId(), null, paymentStateControlContext.getAttemptId(), paymentControlContext.getPaymentId(), paymentControlContext.getPaymentExternalKey(), paymentControlContext.getTransactionId(), paymentControlContext.getTransactionExternalKey(), PaymentApiType.PAYMENT_TRANSACTION, paymentControlContext.getTransactionType(), null, paymentControlContext.getAmount(), paymentControlContext.getCurrency(), paymentControlContext.getProcessedAmount(), paymentControlContext.getProcessedCurrency(), paymentStateControlContext.isApiPayment(), paymentControlPluginNames, paymentStateContext.getProperties(), paymentStateContext.getCallContext());
adjustStateContextPluginProperties(paymentStateContext, result.getAdjustedPluginProperties());
return result.getNextRetryDate();
}
Aggregations