use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.
the class TestPayment method testComboAuthorizationControlPluginException.
@Test(groups = "slow")
public void testComboAuthorizationControlPluginException() throws Exception {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final String paymentExternalKey = UUID.randomUUID().toString();
final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
mockPaymentControlProviderPlugin.throwsException(new IllegalStateException());
try {
paymentApi.createComboPayment(comboPaymentTransaction, Arrays.asList(MockPaymentControlProviderPlugin.PLUGIN_NAME), requestOptions);
fail();
} catch (KillBillClientException e) {
assertEquals(e.getResponse().getStatusCode(), 500);
}
}
use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.
the class TestPayment method testComboAuthorizationInvalidPaymentMethod.
@Test(groups = "slow")
public void testComboAuthorizationInvalidPaymentMethod() throws Exception {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
info.setProperties(null);
final UUID paymentMethodId = UUID.randomUUID();
final PaymentMethod paymentMethodJson = new PaymentMethod();
paymentMethodJson.setPluginName(PLUGIN_NAME);
paymentMethodJson.setPluginInfo(info);
paymentMethodJson.setIsDefault(true);
paymentMethodJson.setPaymentMethodId(paymentMethodId);
final ComboPaymentTransaction comboPaymentTransaction = new ComboPaymentTransaction(accountJson, paymentMethodJson, new PaymentTransaction(), ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of(), null);
final Payment payment = paymentApi.createComboPayment(comboPaymentTransaction, NULL_PLUGIN_NAMES, requestOptions);
// Client returns null in case of a 404
Assert.assertNull(payment);
}
use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.
the class TestPayment method testComboAuthorizationControlWithNullPaymentMethodId.
@Test(groups = "slow")
public void testComboAuthorizationControlWithNullPaymentMethodId() throws Exception {
final Account accountJson = createAccount();
// Non-default payment method
final PaymentMethod paymentMethod = createPaymentMethod(accountJson, false);
mockPaymentControlProviderPlugin.setAdjustedPaymentMethodId(paymentMethod.getPaymentMethodId());
accountJson.setAccountId(null);
final String paymentExternalKey = UUID.randomUUID().toString();
final PaymentTransaction authTransactionJson = new PaymentTransaction();
authTransactionJson.setPaymentExternalKey(paymentExternalKey);
authTransactionJson.setAmount(BigDecimal.TEN);
authTransactionJson.setTransactionType(TransactionType.AUTHORIZE);
final ComboPaymentTransaction comboPaymentTransaction = new ComboPaymentTransaction();
comboPaymentTransaction.setAccount(accountJson);
comboPaymentTransaction.setTransaction(authTransactionJson);
comboPaymentTransaction.setTransaction(authTransactionJson);
final Payment payment = paymentApi.createComboPayment(comboPaymentTransaction, ImmutableList.<String>of(MockPaymentControlProviderPlugin.PLUGIN_NAME), requestOptions);
verifyComboPayment(payment, paymentExternalKey, BigDecimal.TEN, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
assertEquals(paymentApi.getPayment(payment.getPaymentId(), false, true, ImmutableMap.<String, String>of(), AuditLevel.NONE, requestOptions).getPaymentAttempts().size(), 1);
}
use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.
the class TestPayment method testComboAuthorization.
@Test(groups = "slow")
public void testComboAuthorization() throws Exception {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final String paymentExternalKey = UUID.randomUUID().toString();
final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
final Payment payment = paymentApi.createComboPayment(comboPaymentTransaction, NULL_PLUGIN_NAMES, requestOptions);
verifyComboPayment(payment, paymentExternalKey, BigDecimal.TEN, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
// Void payment using externalKey
final String voidTransactionExternalKey = UUID.randomUUID().toString();
PaymentTransaction voidTransaction = new PaymentTransaction();
voidTransaction.setTransactionExternalKey(voidTransactionExternalKey);
voidTransaction.setPaymentExternalKey(paymentExternalKey);
paymentApi.voidPaymentByExternalKey(voidTransaction, NULL_PLUGIN_NAMES, NULL_PLUGIN_PROPERTIES, requestOptions);
final Payment voidPayment = paymentApi.getPayment(payment.getPaymentId(), NULL_PLUGIN_PROPERTIES, requestOptions);
verifyPaymentTransaction(accountJson, voidPayment.getPaymentId(), paymentExternalKey, voidPayment.getTransactions().get(1), voidTransactionExternalKey, null, TransactionType.VOID, TransactionStatus.SUCCESS);
}
use of org.killbill.billing.client.model.gen.ComboPaymentTransaction in project killbill by killbill.
the class TestPayment method createComboPaymentTransaction.
private ComboPaymentTransaction createComboPaymentTransaction(final Account accountJson, final String paymentExternalKey) {
final PaymentMethodPluginDetail info = new PaymentMethodPluginDetail();
info.setProperties(null);
final String paymentMethodExternalKey = UUID.randomUUID().toString();
final PaymentMethod paymentMethodJson = new PaymentMethod();
paymentMethodJson.setExternalKey(paymentMethodExternalKey);
paymentMethodJson.setPluginName(PLUGIN_NAME);
paymentMethodJson.setPluginInfo(info);
final String authTransactionExternalKey = UUID.randomUUID().toString();
final PaymentTransaction authTransactionJson = new PaymentTransaction();
authTransactionJson.setAmount(BigDecimal.TEN);
authTransactionJson.setCurrency(accountJson.getCurrency());
authTransactionJson.setPaymentExternalKey(paymentExternalKey);
authTransactionJson.setTransactionExternalKey(authTransactionExternalKey);
authTransactionJson.setTransactionType(TransactionType.AUTHORIZE);
return new ComboPaymentTransaction(accountJson, paymentMethodJson, authTransactionJson, ImmutableList.<PluginProperty>of(), ImmutableList.<PluginProperty>of(), null);
}
Aggregations