use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.
the class TestPaymentHelper method createTestAccount.
public Account createTestAccount(final String email, final boolean addPaymentMethod) throws Exception {
final String name = "First" + UUID.randomUUID().toString() + " " + "Last" + UUID.randomUUID().toString();
final String externalKey = UUID.randomUUID().toString();
final Account accountData = Mockito.mock(Account.class);
Mockito.when(accountData.getId()).thenReturn(UUID.randomUUID());
Mockito.when(accountData.getExternalKey()).thenReturn(externalKey);
Mockito.when(accountData.getName()).thenReturn(name);
Mockito.when(accountData.getFirstNameLength()).thenReturn(10);
Mockito.when(accountData.getPhone()).thenReturn("123-456-7890");
Mockito.when(accountData.getEmail()).thenReturn(email);
Mockito.when(accountData.getCurrency()).thenReturn(Currency.USD);
Mockito.when(accountData.getBillCycleDayLocal()).thenReturn(1);
Mockito.when(accountData.isMigrated()).thenReturn(false);
Mockito.when(accountData.isNotifiedForInvoices()).thenReturn(false);
Mockito.when(accountData.getTimeZone()).thenReturn(DateTimeZone.UTC);
Mockito.when(accountData.getCreatedDate()).thenReturn(clock.getUTCNow());
Account account;
if (isFastTest()) {
account = GuicyKillbillTestSuiteNoDB.createMockAccount(accountData, accountApi, accountInternalApi, immutableAccountInternalApi, nonEntityDao, clock, internalCallContextFactory, context, internalCallContext);
} else {
account = accountApi.createAccount(accountData, context);
}
GuicyKillbillTestSuite.refreshCallContext(account.getId(), clock, internalCallContextFactory, context, internalCallContext);
if (addPaymentMethod) {
final PaymentMethodPlugin pm = new DefaultNoOpPaymentMethodPlugin(UUID.randomUUID().toString(), true, null);
account = addTestPaymentMethod(account, pm);
}
return account;
}
use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.
the class TestIntegrationBase method createAccountWithPaymentMethod.
private Account createAccountWithPaymentMethod(final AccountData accountData, final String paymentPluginName) throws Exception {
final Account account = accountUserApi.createAccount(accountData, callContext);
assertNotNull(account);
refreshCallContext(account.getId());
final PaymentMethodPlugin info = createPaymentMethodPlugin();
paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), paymentPluginName, true, info, PLUGIN_PROPERTIES, callContext);
return accountUserApi.getAccountById(account.getId(), callContext);
}
use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.
the class PaymentMethodProcessor method buildDefaultPaymentMethod.
private PaymentMethod buildDefaultPaymentMethod(final PaymentMethodModelDao paymentMethodModelDao, final boolean withPluginInfo, final Iterable<PluginProperty> properties, final TenantContext tenantContext, final InternalTenantContext context) throws PaymentApiException {
final PaymentMethodPlugin paymentMethodPlugin;
if (withPluginInfo) {
try {
final PaymentPluginApi pluginApi = getPaymentPluginApi(paymentMethodModelDao.getPluginName());
paymentMethodPlugin = pluginApi.getPaymentMethodDetail(paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId(), properties, tenantContext);
} catch (final PaymentPluginApiException e) {
throw new PaymentApiException(ErrorCode.PAYMENT_GET_PAYMENT_METHODS, paymentMethodModelDao.getAccountId(), paymentMethodModelDao.getId());
}
} else {
paymentMethodPlugin = null;
}
return new DefaultPaymentMethod(paymentMethodModelDao, paymentMethodPlugin);
}
use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.
the class TestPaymentMethodProcessorNoDB method testPaymentMethodExternalKeySetByPluginIfNonSpecified.
@Test(groups = "fast")
public void testPaymentMethodExternalKeySetByPluginIfNonSpecified() throws Exception {
final Account account = Mockito.mock(Account.class);
final UUID accountId = UUID.randomUUID();
Mockito.when(account.getId()).thenReturn(accountId);
Mockito.when(account.getExternalKey()).thenReturn(accountId.toString());
final PaymentMethodPlugin paymentMethodPlugin = Mockito.mock(PaymentMethodPlugin.class);
final Iterable<PluginProperty> properties = ImmutableList.<PluginProperty>of();
// By default, the external payment plugin sets the external payment method id to "unknown"
final UUID paymentMethodId2 = paymentMethodProcessor.addPaymentMethod(null, "__EXTERNAL_PAYMENT__", account, false, paymentMethodPlugin, properties, callContext, internalCallContext);
final PaymentMethod paymentMethod2 = paymentMethodProcessor.getPaymentMethodById(paymentMethodId2, false, false, properties, callContext, internalCallContext);
Assert.assertEquals(paymentMethod2.getExternalKey(), "unknown");
}
use of org.killbill.billing.payment.api.PaymentMethodPlugin in project killbill by killbill.
the class TestIntegrationWithCatalogUpdate method setupAccount.
private void setupAccount() throws Exception {
final AccountData accountData = getAccountData(0);
account = accountUserApi.createAccount(accountData, testCallContext);
assertNotNull(account);
final PaymentMethodPlugin info = createPaymentMethodPlugin();
paymentApi.addPaymentMethod(account, UUID.randomUUID().toString(), BeatrixIntegrationModule.NON_OSGI_PLUGIN_NAME, true, info, PLUGIN_PROPERTIES, testCallContext);
}
Aggregations