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);
}
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())));
}
Aggregations