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;
}
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());
}
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);
}
Aggregations