Search in sources :

Example 1 with DefaultPaymentControlProviderPluginRegistry

use of org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry in project killbill by killbill.

the class DefaultPaymentControlProviderPluginRegistryProvider method get.

@Override
public OSGIServiceRegistration<PaymentControlPluginApi> get() {
    final DefaultPaymentControlProviderPluginRegistry pluginRegistry = new DefaultPaymentControlProviderPluginRegistry();
    // Make the external payment provider plugin available by default
    final OSGIServiceDescriptor desc = new OSGIServiceDescriptor() {

        @Override
        public String getPluginSymbolicName() {
            return null;
        }

        @Override
        public String getPluginName() {
            return DefaultPaymentControlProviderPlugin.PLUGIN_NAME;
        }

        @Override
        public String getRegistrationName() {
            return DefaultPaymentControlProviderPlugin.PLUGIN_NAME;
        }
    };
    pluginRegistry.registerService(desc, externalPaymentControlProviderPlugin);
    // Hack, because this is not a real plugin, so it can't register itself during lifecycle as it should.
    final OSGIServiceDescriptor desc2 = new OSGIServiceDescriptor() {

        @Override
        public String getPluginSymbolicName() {
            return null;
        }

        @Override
        public String getPluginName() {
            return InvoicePaymentControlPluginApi.PLUGIN_NAME;
        }

        @Override
        public String getRegistrationName() {
            return InvoicePaymentControlPluginApi.PLUGIN_NAME;
        }
    };
    pluginRegistry.registerService(desc2, invoicePaymentControlPlugin);
    return pluginRegistry;
}
Also used : DefaultPaymentControlProviderPluginRegistry(org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry) OSGIServiceDescriptor(org.killbill.billing.osgi.api.OSGIServiceDescriptor)

Example 2 with DefaultPaymentControlProviderPluginRegistry

use of org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry in project killbill by killbill.

the class TestControlPluginRunner method testPriorCallWithUnknownPlugin.

@Test(groups = "fast")
public void testPriorCallWithUnknownPlugin() throws Exception {
    final Account account = Mockito.mock(Account.class);
    final UUID paymentMethodId = UUIDs.randomUUID();
    final UUID paymentId = UUIDs.randomUUID();
    final String paymentExternalKey = UUIDs.randomUUID().toString();
    final UUID paymentTransactionId = UUIDs.randomUUID();
    final String paymentTransactionExternalKey = UUIDs.randomUUID().toString();
    final BigDecimal amount = BigDecimal.ONE;
    final Currency currency = Currency.USD;
    final ImmutableList<String> paymentControlPluginNames = ImmutableList.<String>of("not-registered");
    final ImmutableList<PluginProperty> pluginProperties = ImmutableList.<PluginProperty>of();
    final ControlPluginRunner controlPluginRunner = new ControlPluginRunner(new DefaultPaymentControlProviderPluginRegistry(), paymentConfig);
    final PriorPaymentControlResult paymentControlResult = controlPluginRunner.executePluginPriorCalls(account, paymentMethodId, null, null, paymentId, paymentExternalKey, paymentTransactionId, paymentTransactionExternalKey, PaymentApiType.PAYMENT_TRANSACTION, TransactionType.AUTHORIZE, null, amount, currency, null, null, true, paymentControlPluginNames, pluginProperties, callContext);
    Assert.assertEquals(paymentControlResult.getAdjustedAmount(), amount);
    Assert.assertEquals(paymentControlResult.getAdjustedCurrency(), currency);
    Assert.assertEquals(paymentControlResult.getAdjustedPaymentMethodId(), paymentMethodId);
    Assert.assertEquals(paymentControlResult.getAdjustedPluginProperties(), pluginProperties);
    Assert.assertFalse(paymentControlResult.isAborted());
}
Also used : Account(org.killbill.billing.account.api.Account) PluginProperty(org.killbill.billing.payment.api.PluginProperty) DefaultPaymentControlProviderPluginRegistry(org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry) Currency(org.killbill.billing.catalog.api.Currency) PriorPaymentControlResult(org.killbill.billing.control.plugin.api.PriorPaymentControlResult) UUID(java.util.UUID) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Example 3 with DefaultPaymentControlProviderPluginRegistry

use of org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry in project killbill by killbill.

the class TestControlPluginRunner method testPriorCallWithNullAccountAndPaymentMethodId.

// This tests the PSP notification processing case
@Test(groups = "fast")
public void testPriorCallWithNullAccountAndPaymentMethodId() throws Exception {
    final UUID paymentId = UUIDs.randomUUID();
    final String paymentExternalKey = UUIDs.randomUUID().toString();
    final UUID paymentTransactionId = UUIDs.randomUUID();
    final String paymentTransactionExternalKey = UUIDs.randomUUID().toString();
    final BigDecimal amount = BigDecimal.ONE;
    final Currency currency = Currency.USD;
    final ImmutableList<String> paymentControlPluginNames = ImmutableList.<String>of("not-registered");
    final ImmutableList<PluginProperty> pluginProperties = ImmutableList.<PluginProperty>of();
    final ControlPluginRunner controlPluginRunner = new ControlPluginRunner(new DefaultPaymentControlProviderPluginRegistry(), paymentConfig);
    final PriorPaymentControlResult paymentControlResult = controlPluginRunner.executePluginPriorCalls(null, null, null, null, paymentId, paymentExternalKey, paymentTransactionId, paymentTransactionExternalKey, PaymentApiType.PAYMENT_TRANSACTION, TransactionType.AUTHORIZE, null, amount, currency, null, null, true, paymentControlPluginNames, pluginProperties, callContext);
    Assert.assertNotNull(paymentControlResult);
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) DefaultPaymentControlProviderPluginRegistry(org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry) Currency(org.killbill.billing.catalog.api.Currency) PriorPaymentControlResult(org.killbill.billing.control.plugin.api.PriorPaymentControlResult) UUID(java.util.UUID) BigDecimal(java.math.BigDecimal) Test(org.testng.annotations.Test)

Aggregations

DefaultPaymentControlProviderPluginRegistry (org.killbill.billing.payment.provider.DefaultPaymentControlProviderPluginRegistry)3 BigDecimal (java.math.BigDecimal)2 UUID (java.util.UUID)2 Currency (org.killbill.billing.catalog.api.Currency)2 PriorPaymentControlResult (org.killbill.billing.control.plugin.api.PriorPaymentControlResult)2 PluginProperty (org.killbill.billing.payment.api.PluginProperty)2 Test (org.testng.annotations.Test)2 Account (org.killbill.billing.account.api.Account)1 OSGIServiceDescriptor (org.killbill.billing.osgi.api.OSGIServiceDescriptor)1