Search in sources :

Example 96 with PluginProperty

use of org.killbill.billing.payment.api.PluginProperty in project killbill by killbill.

the class MockPaymentProviderPlugin method overridePaymentTransactionPluginResult.

public void overridePaymentTransactionPluginResult(final UUID kbPaymentId, final UUID kbTransactionId, final PaymentPluginStatus paymentPluginStatus) throws PaymentPluginApiException {
    final List<PaymentTransactionInfoPlugin> existingTransactions = paymentTransactions.get(kbPaymentId.toString());
    PaymentTransactionInfoPlugin paymentTransactionInfoPlugin = null;
    for (final PaymentTransactionInfoPlugin existingTransaction : existingTransactions) {
        if (existingTransaction.getKbTransactionPaymentId().equals(kbTransactionId)) {
            paymentTransactionInfoPlugin = existingTransaction;
            break;
        }
    }
    Preconditions.checkNotNull(paymentTransactionInfoPlugin);
    final Iterable<PluginProperty> pluginProperties = ImmutableList.<PluginProperty>of(new PluginProperty(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, paymentPluginStatus.toString(), false));
    getPaymentTransactionInfoPluginResult(kbPaymentId, kbTransactionId, TransactionType.AUTHORIZE, paymentTransactionInfoPlugin.getAmount(), paymentTransactionInfoPlugin.getCurrency(), pluginProperties);
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) PaymentTransactionInfoPlugin(org.killbill.billing.payment.plugin.api.PaymentTransactionInfoPlugin)

Example 97 with PluginProperty

use of org.killbill.billing.payment.api.PluginProperty in project killbill by killbill.

the class TestDefaultNoOpPaymentMethodPlugin method testEqualsForPluginProperty.

@Test(groups = "fast")
public void testEqualsForPluginProperty() throws Exception {
    final String key = UUID.randomUUID().toString();
    final Object value = UUID.randomUUID();
    final boolean updatable = false;
    final PluginProperty kvInfo = new PluginProperty(key, value, updatable);
    Assert.assertEquals(kvInfo, kvInfo);
    final PluginProperty sameKvInfo = new PluginProperty(key, value, updatable);
    Assert.assertEquals(sameKvInfo, kvInfo);
    final PluginProperty otherKvInfo = new PluginProperty(key, value, !updatable);
    Assert.assertNotEquals(otherKvInfo, kvInfo);
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) Test(org.testng.annotations.Test)

Example 98 with PluginProperty

use of org.killbill.billing.payment.api.PluginProperty 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());
    final PriorPaymentControlResult paymentControlResult = controlPluginRunner.executePluginPriorCalls(account, paymentMethodId, 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 99 with PluginProperty

use of org.killbill.billing.payment.api.PluginProperty in project killbill by killbill.

the class TestPaymentDao method testPaymentAttempt.

@Test(groups = "slow")
public void testPaymentAttempt() throws PluginPropertySerializerException {
    final UUID transactionId = UUID.randomUUID();
    final String paymentExternalKey = "vraiment?";
    final String transactionExternalKey = "tduteuqweq";
    final String stateName = "INIT";
    final TransactionType transactionType = TransactionType.AUTHORIZE;
    final String pluginName = "superPlugin";
    final List<PluginProperty> properties = new ArrayList<PluginProperty>();
    properties.add(new PluginProperty("key1", "value1", false));
    properties.add(new PluginProperty("key2", "value2", false));
    final byte[] serialized = PluginPropertySerializer.serialize(properties);
    final PaymentAttemptModelDao attempt = new PaymentAttemptModelDao(UUID.randomUUID(), UUID.randomUUID(), clock.getUTCNow(), clock.getUTCNow(), paymentExternalKey, transactionId, transactionExternalKey, transactionType, stateName, BigDecimal.ZERO, Currency.ALL, ImmutableList.<String>of(pluginName), serialized);
    PaymentAttemptModelDao savedAttempt = paymentDao.insertPaymentAttemptWithProperties(attempt, internalCallContext);
    assertEquals(savedAttempt.getTransactionExternalKey(), transactionExternalKey);
    assertEquals(savedAttempt.getTransactionType(), transactionType);
    assertEquals(savedAttempt.getStateName(), stateName);
    assertEquals(savedAttempt.getPluginName(), pluginName);
    final Iterable<PluginProperty> deserialized = PluginPropertySerializer.deserialize(savedAttempt.getPluginProperties());
    int i = 0;
    for (PluginProperty cur : deserialized) {
        Assert.assertEquals(cur, properties.get(i++));
    }
    final PaymentAttemptModelDao retrievedAttempt1 = paymentDao.getPaymentAttempt(attempt.getId(), internalCallContext);
    assertEquals(retrievedAttempt1.getTransactionExternalKey(), transactionExternalKey);
    assertEquals(retrievedAttempt1.getTransactionType(), transactionType);
    assertEquals(retrievedAttempt1.getStateName(), stateName);
    assertEquals(retrievedAttempt1.getPluginName(), pluginName);
    final List<PaymentAttemptModelDao> retrievedAttempts = paymentDao.getPaymentAttemptByTransactionExternalKey(transactionExternalKey, internalCallContext);
    assertEquals(retrievedAttempts.size(), 1);
    assertEquals(retrievedAttempts.get(0).getTransactionExternalKey(), transactionExternalKey);
    assertEquals(retrievedAttempts.get(0).getTransactionType(), transactionType);
    assertEquals(retrievedAttempts.get(0).getStateName(), stateName);
    assertEquals(retrievedAttempts.get(0).getPluginName(), pluginName);
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) TransactionType(org.killbill.billing.payment.api.TransactionType) ArrayList(java.util.ArrayList) UUID(java.util.UUID) Test(org.testng.annotations.Test)

Example 100 with PluginProperty

use of org.killbill.billing.payment.api.PluginProperty in project killbill by killbill.

the class TestPluginPropertySerializer method testNoPluginProperty.

@Test(groups = "fast")
public void testNoPluginProperty() throws PluginPropertySerializerException {
    final List<PluginProperty> input = new ArrayList<PluginProperty>();
    final byte[] serialized = PluginPropertySerializer.serialize(input);
    final Iterable<PluginProperty> deserialized = PluginPropertySerializer.deserialize(serialized);
    int i = 0;
    for (PluginProperty cur : deserialized) {
        Assert.assertEquals(cur, input.get(i++));
    }
}
Also used : PluginProperty(org.killbill.billing.payment.api.PluginProperty) ArrayList(java.util.ArrayList) Test(org.testng.annotations.Test)

Aggregations

PluginProperty (org.killbill.billing.payment.api.PluginProperty)105 UUID (java.util.UUID)45 Account (org.killbill.billing.account.api.Account)42 ApiOperation (io.swagger.annotations.ApiOperation)35 ApiResponses (io.swagger.annotations.ApiResponses)35 Produces (javax.ws.rs.Produces)35 TimedResource (org.killbill.commons.metrics.TimedResource)35 Test (org.testng.annotations.Test)33 Path (javax.ws.rs.Path)32 Payment (org.killbill.billing.payment.api.Payment)30 CallContext (org.killbill.billing.util.callcontext.CallContext)29 ArrayList (java.util.ArrayList)19 LocalDate (org.joda.time.LocalDate)19 Consumes (javax.ws.rs.Consumes)17 BigDecimal (java.math.BigDecimal)16 TenantContext (org.killbill.billing.util.callcontext.TenantContext)15 GET (javax.ws.rs.GET)14 POST (javax.ws.rs.POST)13 DefaultEntitlement (org.killbill.billing.entitlement.api.DefaultEntitlement)13 AccountAuditLogs (org.killbill.billing.util.audit.AccountAuditLogs)13