Search in sources :

Example 6 with PaymentMethodPlugin

use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.

the class MockPaymentProviderPlugin method addPaymentMethod.

@Override
public void addPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final PaymentMethodPlugin paymentMethodProps, final boolean setDefault, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException {
    // externalPaymentMethodId is set to a random value
    final PaymentMethodPlugin realWithID = new TestPaymentMethodPlugin(kbPaymentMethodId, paymentMethodProps, UUID.randomUUID().toString());
    paymentMethods.put(kbPaymentMethodId.toString(), realWithID);
    final PaymentMethodInfoPlugin realInfoWithID = new DefaultPaymentMethodInfoPlugin(kbAccountId, kbPaymentMethodId, setDefault, UUID.randomUUID().toString());
    paymentMethodsInfo.put(kbPaymentMethodId.toString(), realInfoWithID);
}
Also used : PaymentMethodInfoPlugin(org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin) TestPaymentMethodPlugin(org.killbill.billing.payment.api.TestPaymentMethodPlugin) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin) TestPaymentMethodPlugin(org.killbill.billing.payment.api.TestPaymentMethodPlugin)

Example 7 with PaymentMethodPlugin

use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.

the class PaymentMethodJson method toPaymentMethodJson.

public static PaymentMethodJson toPaymentMethodJson(final Account account, final PaymentMethod in, @Nullable final AccountAuditLogs accountAuditLogs) {
    final boolean isDefault = account.getPaymentMethodId() != null && account.getPaymentMethodId().equals(in.getId());
    final PaymentMethodPlugin pluginDetail = in.getPluginDetail();
    PaymentMethodPluginDetailJson pluginDetailJson = null;
    if (pluginDetail != null) {
        List<PluginPropertyJson> properties = null;
        if (pluginDetail.getProperties() != null) {
            properties = new ArrayList<PluginPropertyJson>(Collections2.transform(pluginDetail.getProperties(), new Function<PluginProperty, PluginPropertyJson>() {

                @Override
                public PluginPropertyJson apply(final PluginProperty input) {
                    return new PluginPropertyJson(input.getKey(), input.getValue() == null ? null : input.getValue().toString(), input.getIsUpdatable());
                }
            }));
        }
        pluginDetailJson = new PaymentMethodPluginDetailJson(pluginDetail.getExternalPaymentMethodId(), pluginDetail.isDefaultPaymentMethod(), properties);
    }
    return new PaymentMethodJson(in.getId().toString(), in.getExternalKey(), account.getId().toString(), isDefault, in.getPluginName(), pluginDetailJson, toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForPaymentMethod(in.getId())));
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin)

Aggregations

PaymentMethodPlugin (org.killbill.billing.payment.api.PaymentMethodPlugin)7 Account (org.killbill.billing.account.api.Account)3 PluginProperty (org.killbill.billing.payment.api.PluginProperty)2 DefaultNoOpPaymentMethodPlugin (org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin)2 UUID (java.util.UUID)1 AccountData (org.killbill.billing.account.api.AccountData)1 DefaultPaymentMethod (org.killbill.billing.payment.api.DefaultPaymentMethod)1 PaymentApiException (org.killbill.billing.payment.api.PaymentApiException)1 PaymentMethod (org.killbill.billing.payment.api.PaymentMethod)1 TestPaymentMethodPlugin (org.killbill.billing.payment.api.TestPaymentMethodPlugin)1 PaymentMethodInfoPlugin (org.killbill.billing.payment.plugin.api.PaymentMethodInfoPlugin)1 PaymentPluginApi (org.killbill.billing.payment.plugin.api.PaymentPluginApi)1 PaymentPluginApiException (org.killbill.billing.payment.plugin.api.PaymentPluginApiException)1 Test (org.testng.annotations.Test)1