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