Search in sources :

Example 1 with DefaultNoOpHostedPaymentPageFormDescriptor

use of org.killbill.billing.payment.provider.DefaultNoOpHostedPaymentPageFormDescriptor in project killbill by killbill.

the class PaymentGatewayProcessor method buildFormDescriptor.

public HostedPaymentPageFormDescriptor buildFormDescriptor(final boolean shouldDispatch, final Account account, final UUID paymentMethodId, final Iterable<PluginProperty> customFields, final Iterable<PluginProperty> properties, final CallContext callContext, final InternalCallContext internalCallContext) throws PaymentApiException {
    final String pluginName = getPaymentMethodById(paymentMethodId, true, internalCallContext).getPluginName();
    final PaymentPluginApi plugin = getPaymentPluginApi(pluginName);
    if (shouldDispatch) {
        return dispatchWithExceptionHandling(account, pluginName, new Callable<PluginDispatcherReturnType<HostedPaymentPageFormDescriptor>>() {

            @Override
            public PluginDispatcherReturnType<HostedPaymentPageFormDescriptor> call() throws PaymentApiException {
                try {
                    final HostedPaymentPageFormDescriptor result = plugin.buildFormDescriptor(account.getId(), customFields, properties, callContext);
                    return PluginDispatcher.createPluginDispatcherReturnType(result == null ? new DefaultNoOpHostedPaymentPageFormDescriptor(account.getId()) : result);
                } catch (final RuntimeException e) {
                    throw new PaymentApiException(e, ErrorCode.PAYMENT_INTERNAL_ERROR, MoreObjects.firstNonNull(e.getMessage(), ""));
                } catch (final PaymentPluginApiException e) {
                    throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_EXCEPTION, e.getErrorMessage());
                }
            }
        }, paymentPluginFormDispatcher);
    } else {
        try {
            return plugin.buildFormDescriptor(account.getId(), customFields, properties, callContext);
        } catch (final PaymentPluginApiException e) {
            throw new PaymentApiException(e, ErrorCode.PAYMENT_PLUGIN_EXCEPTION, e.getErrorMessage());
        }
    }
}
Also used : PaymentPluginApi(org.killbill.billing.payment.plugin.api.PaymentPluginApi) PluginDispatcherReturnType(org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType) DefaultNoOpHostedPaymentPageFormDescriptor(org.killbill.billing.payment.provider.DefaultNoOpHostedPaymentPageFormDescriptor) HostedPaymentPageFormDescriptor(org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor) DefaultNoOpHostedPaymentPageFormDescriptor(org.killbill.billing.payment.provider.DefaultNoOpHostedPaymentPageFormDescriptor) PaymentPluginApiException(org.killbill.billing.payment.plugin.api.PaymentPluginApiException) PaymentApiException(org.killbill.billing.payment.api.PaymentApiException)

Aggregations

PaymentApiException (org.killbill.billing.payment.api.PaymentApiException)1 PluginDispatcherReturnType (org.killbill.billing.payment.dispatcher.PluginDispatcher.PluginDispatcherReturnType)1 HostedPaymentPageFormDescriptor (org.killbill.billing.payment.plugin.api.HostedPaymentPageFormDescriptor)1 PaymentPluginApi (org.killbill.billing.payment.plugin.api.PaymentPluginApi)1 PaymentPluginApiException (org.killbill.billing.payment.plugin.api.PaymentPluginApiException)1 DefaultNoOpHostedPaymentPageFormDescriptor (org.killbill.billing.payment.provider.DefaultNoOpHostedPaymentPageFormDescriptor)1