private Account addTestExternalPaymentMethod(final Account account, final PaymentMethodPlugin paymentMethodInfo) throws Exception { final UUID paymentMethodId = paymentApi.addPaymentMethod(account, paymentMethodInfo.getExternalPaymentMethodId(), ExternalPaymentProviderPlugin.PLUGIN_NAME, true, paymentMethodInfo, ImmutableList.<PluginProperty>of(), callContext); return accountApi.getAccountById(account.getId(), internalCallContext); }
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(), in.getExternalKey(), account.getId(), isDefault, in.getPluginName(), pluginDetailJson, toAuditLogJson(accountAuditLogs == null ? null : accountAuditLogs.getAuditLogsForPaymentMethod(in.getId()))); }
Assert.assertEquals(plugin.getExternalPaymentMethodId(), "myToken", "Wrong externalPaymentMethodId"); Assert.assertEquals(plugin.isDefaultPaymentMethod(), true, "Wrong defaultPaymentMethod"); Assert.assertNotNull(plugin.getProperties(), "Wrong properties");
Assert.assertEquals(plugin.getExternalPaymentMethodId(), null, "Wrong externalPaymentMethodId"); Assert.assertEquals(plugin.isDefaultPaymentMethod(), true, "Wrong defaultPaymentMethod"); Assert.assertNotNull(plugin.getProperties(), "Wrong properties");
public UUID addTestPaymentMethod(final String pluginName, final Account account, final PaymentMethodPlugin paymentMethodInfo, final Iterable<PluginProperty> pluginProperties) throws Exception { final boolean setDefault = paymentMethodInfo.isDefaultPaymentMethod(); final UUID paymentMethodId = paymentApi.addPaymentMethod(account, paymentMethodInfo.getExternalPaymentMethodId(), pluginName, setDefault, paymentMethodInfo, pluginProperties, context); if (isFastTest() && setDefault) { final Account account1 = new MockAccountBuilder(account).paymentMethodId(paymentMethodId).build(); accountApi.updateAccount(account1, context); } return paymentMethodId; }