Search in sources :

Example 1 with PaymentMethodPlugin

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;
}
Also used : Account(org.killbill.billing.account.api.Account) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin)

Example 2 with PaymentMethodPlugin

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);
}
Also used : Account(org.killbill.billing.account.api.Account) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin)

Example 3 with PaymentMethodPlugin

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);
}
Also used : PaymentPluginApi(org.killbill.billing.payment.plugin.api.PaymentPluginApi) PaymentPluginApiException(org.killbill.billing.payment.plugin.api.PaymentPluginApiException) DefaultNoOpPaymentMethodPlugin(org.killbill.billing.payment.provider.DefaultNoOpPaymentMethodPlugin) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin) PaymentApiException(org.killbill.billing.payment.api.PaymentApiException) DefaultPaymentMethod(org.killbill.billing.payment.api.DefaultPaymentMethod)

Example 4 with 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");
}
Also used : Account(org.killbill.billing.account.api.Account) PluginProperty(org.killbill.billing.payment.api.PluginProperty) PaymentMethodPlugin(org.killbill.billing.payment.api.PaymentMethodPlugin) PaymentMethod(org.killbill.billing.payment.api.PaymentMethod) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 5 with PaymentMethodPlugin

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);
}
Also used : AccountData(org.killbill.billing.account.api.AccountData) 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