@Override public UUID getTenantId() { return delegate.getTenantId(); } }
@Override public void uploadOverdueConfig(final OverdueConfig overdueConfig, final CallContext callContext) throws OverdueApiException { try { final String overdueXML = XMLWriter.writeXML((DefaultOverdueConfig) overdueConfig, DefaultOverdueConfig.class); uploadOverdueConfig(overdueXML, callContext); } catch (final Exception e) { throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, callContext.getTenantId()); } }
public TestCallContext(final CallContext context, final DateTime utcNow) { this.userName = context.getUserName(); this.createdDate = utcNow; this.updatedDate = utcNow; this.userToken = context.getUserToken(); this.accountId = context.getAccountId(); this.tenantId = context.getTenantId(); }
public DefaultCallContext(final CallContext callContext) { super(callContext.getAccountId(), callContext.getTenantId(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), callContext.getUserToken()); this.createdDate = callContext.getCreatedDate(); this.updateDate = callContext.getUpdatedDate(); }
@Override public UUID getTenantId() { return delegate.getTenantId(); } }
@Override public List<PaymentMethodInfoPlugin> getPaymentMethods(final UUID kbAccountId, final boolean refreshFromGateway, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException { final List<PM_R> records; try { records = dao.getPaymentMethods(kbAccountId, context.getTenantId()); } catch (final SQLException e) { throw new PaymentPluginApiException("Unable to retrieve payment methods for kbAccountId " + kbAccountId, e); } return Lists.<PM_R, PaymentMethodInfoPlugin>transform(records, new Function<PM_R, PaymentMethodInfoPlugin>() { @Override public PaymentMethodInfoPlugin apply(final PM_R record) { return buildPaymentMethodInfoPlugin(record); } }); }
@Override public void deletePaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException { final DateTime utcNow = clock.getUTCNow(); try { dao.deletePaymentMethod(kbPaymentMethodId, utcNow, context.getTenantId()); } catch (final SQLException e) { throw new PaymentPluginApiException("Unable to delete payment method for kbPaymentMethodId " + kbPaymentMethodId, e); } }
@Override public void uploadOverdueConfig(final OverdueConfig overdueConfig, final CallContext callContext) throws OverdueApiException { try { final String overdueXML = XMLWriter.writeXML((DefaultOverdueConfig) overdueConfig, DefaultOverdueConfig.class); uploadOverdueConfig(overdueXML, callContext); } catch (final Exception e) { throw new OverdueApiException(ErrorCode.OVERDUE_INVALID_FOR_TENANT, callContext.getTenantId()); } }
@Override public void setDefaultPaymentMethod(final UUID kbAccountId, final UUID kbPaymentMethodId, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException { final DateTime utcNow = clock.getUTCNow(); try { dao.setDefaultPaymentMethod(kbAccountId, kbPaymentMethodId, utcNow, context.getTenantId()); } catch (final SQLException e) { throw new PaymentPluginApiException("Unable to set default payment method for kbPaymentMethodId " + kbPaymentMethodId, e); } }
@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 { // Note: query parameters have precedence by convention final Map<String, String> mergedProperties = PluginProperties.toStringMap(paymentMethodProps.getProperties(), properties); final DateTime utcNow = clock.getUTCNow(); try { dao.addPaymentMethod(kbAccountId, kbPaymentMethodId, setDefault, mergedProperties, utcNow, context.getTenantId()); } catch (final SQLException e) { throw new PaymentPluginApiException("Unable to add payment method for kbPaymentMethodId " + kbPaymentMethodId, e); } }
@Override public void resetPaymentMethods(final UUID kbAccountId, final List<PaymentMethodInfoPlugin> paymentMethods, final Iterable<PluginProperty> properties, final CallContext context) throws PaymentPluginApiException { final List<PM_R> records; try { records = dao.getPaymentMethods(kbAccountId, context.getTenantId()); } catch (final SQLException e) { throw new PaymentPluginApiException("Unable to retrieve payment methods for kbAccountId " + kbAccountId, e); } final Set<UUID> existingPaymentMethodIds = ImmutableSet.<UUID>copyOf(Iterables.<PM_R, UUID>transform(records, new Function<PM_R, UUID>() { @Override public UUID apply(final PM_R input) { return UUID.fromString(getPaymentMethodId(input)); } })); final DateTime utcNow = clock.getUTCNow(); for (final PaymentMethodInfoPlugin existingPaymentMethod : paymentMethods) { if (!existingPaymentMethodIds.contains(existingPaymentMethod.getPaymentMethodId())) { try { dao.addPaymentMethod(kbAccountId, existingPaymentMethod.getPaymentMethodId(), existingPaymentMethod.isDefault(), PluginProperties.toStringMap(properties), utcNow, context.getTenantId()); } catch (final SQLException e) { throw new PaymentPluginApiException("Unable to add payment method for kbPaymentMethodId " + existingPaymentMethod.getPaymentMethodId(), e); } } } } }
final Long tenantRecordId = recordIdApi.getRecordId(callContext.getTenantId(), ObjectType.TENANT, callContext); final Long accountRecordId = accountId == null ? null : recordIdApi.getRecordId(accountId, ObjectType.ACCOUNT, callContext); for (final NotificationQueue notificationQueue : notificationQueueService.getNotificationQueues()) {
public TestCallContext(final CallContext context, final DateTime utcNow) { this.userName = context.getUserName(); this.createdDate = utcNow; this.updatedDate = utcNow; this.userToken = context.getUserToken(); this.accountId = context.getAccountId(); this.tenantId = context.getTenantId(); }
api.addPaymentMethod(account2.getId(), kbPaymentMethodId3, account2Method, true, TestUtils.toProperties(propertiesMap), context); dao.setDefaultPaymentMethod(account.getId(), kbPaymentMethodId2, DateTime.now(), context.getTenantId()); final TestPaymentMethodsRecord account1Method1Record = dao.getPaymentMethod(kbPaymentMethodId1, context.getTenantId()); final TestPaymentMethodsRecord account1Method2Record = dao.getPaymentMethod(kbPaymentMethodId2, context.getTenantId()); final TestPaymentMethodsRecord account2Method1Record = dao.getPaymentMethod(kbPaymentMethodId3, context.getTenantId());
public DefaultCallContext(final CallContext callContext) { super(callContext.getAccountId(), callContext.getTenantId(), callContext.getUserName(), callContext.getCallOrigin(), callContext.getUserType(), callContext.getReasonCode(), callContext.getComments(), callContext.getUserToken()); this.createdDate = callContext.getCreatedDate(); this.updateDate = callContext.getUpdatedDate(); }
api.addPaymentMethod(account.getId(), kbPaymentMethodId, method, true, properties, context); final TestPaymentMethodsRecord record = dao.getPaymentMethod(kbPaymentMethodId, context.getTenantId()); Assert.assertEquals(record.getKbTenantId(), context.getTenantId().toString(), "Wrong kbTenantId"); Assert.assertEquals(record.getCcFirstName(), null, "Wrong ccFirstName"); Assert.assertEquals(record.getCcLastName(), null, "Wrong ccLastName");
api.addPaymentMethod(account.getId(), kbPaymentMethodId, method, true, TestUtils.toProperties(propertiesMap), context); final TestPaymentMethodsRecord record = dao.getPaymentMethod(kbPaymentMethodId, context.getTenantId()); Assert.assertEquals(record.getKbTenantId(), context.getTenantId().toString(), "Wrong kbTenantId"); Assert.assertEquals(record.getCcFirstName(), "myCcFirstName", "Wrong ccFirstName"); Assert.assertEquals(record.getCcLastName(), "myCcLAstName", "Wrong ccLastName");
@Override @BeforeClass(groups = "slow") public void setUpBeforeClass() throws Exception { super.setUpBeforeClass(); this.dao = new TestPluginPaymentDao(embeddedDB.getDataSource()); final Clock clock = new DefaultClock(); final UUID tenantId = UUID.randomUUID(); context = Mockito.mock(CallContext.class); Mockito.when(context.getTenantId()).thenReturn(tenantId); account = TestUtils.buildAccount(Currency.JPY, "JP"); final OSGIKillbillAPI killbillApi = TestUtils.buildOSGIKillbillAPI(account); final Payment payment = TestUtils.buildPayment(account.getId(), account.getPaymentMethodId(), account.getCurrency(), killbillApi); final OSGIKillbillLogService logService = TestUtils.buildLogService(); final OSGIConfigPropertiesService configPropertiesService = Mockito.mock(OSGIConfigPropertiesService.class); api = new TestPaymentPluginApi(killbillApi, configPropertiesService, logService, clock, dao); TestUtils.updateOSGIKillbillAPI(killbillApi, api); }
public DefaultInvoiceContext(final LocalDate targetDate, final Invoice invoice, final List<Invoice> existingInvoices, final boolean isDryRun, final boolean isRescheduled, final CallContext context) { super(context.getAccountId(), context.getTenantId(), context.getUserName(), context.getCallOrigin(), context.getUserType(), context.getReasonCode(), context.getComments(), context.getUserToken(), context.getCreatedDate(), context.getUpdatedDate()); this.targetDate = targetDate; this.invoice = invoice; this.existingInvoices = existingInvoices; this.isDryRun = isDryRun; this.isRescheduled = isRescheduled; }