use of org.killbill.billing.client.KillBillClientException in project killbill by killbill.
the class TestPayment method testComboAuthorizationAbortedPayment.
@Test(groups = "slow")
public void testComboAuthorizationAbortedPayment() throws Exception {
final Account accountJson = getAccount();
accountJson.setAccountId(null);
final String paymentExternalKey = UUID.randomUUID().toString();
final ComboPaymentTransaction comboPaymentTransaction = createComboPaymentTransaction(accountJson, paymentExternalKey);
mockPaymentControlProviderPlugin.setAborted(true);
try {
killBillClient.createPayment(comboPaymentTransaction, Arrays.asList(MockPaymentControlProviderPlugin.PLUGIN_NAME), ImmutableMap.<String, String>of(), requestOptions);
fail();
} catch (KillBillClientException e) {
assertEquals(e.getResponse().getStatusCode(), 422);
}
assertFalse(mockPaymentControlProviderPlugin.isOnFailureCallExecuted());
assertFalse(mockPaymentControlProviderPlugin.isOnSuccessCallExecuted());
}
use of org.killbill.billing.client.KillBillClientException in project killbill by killbill.
the class TestPayment method testAuthorizeCompletionUsingPaymentIdAndTransactionType.
@Test(groups = "slow")
public void testAuthorizeCompletionUsingPaymentIdAndTransactionType() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
final UUID paymentMethodId = account.getPaymentMethodId();
final BigDecimal amount = BigDecimal.TEN;
final String pending = PaymentPluginStatus.PENDING.toString();
final ImmutableMap<String, String> pendingPluginProperties = ImmutableMap.<String, String>of(MockPaymentProviderPlugin.PLUGIN_PROPERTY_PAYMENT_PLUGIN_STATUS_OVERRIDE, pending);
final ImmutableMap<String, String> pluginProperties = ImmutableMap.of();
TransactionType transactionType = TransactionType.AUTHORIZE;
final String paymentExternalKey = UUID.randomUUID().toString();
final String authTransactionExternalKey = UUID.randomUUID().toString();
final Payment initialPayment = createVerifyTransaction(account, paymentMethodId, paymentExternalKey, authTransactionExternalKey, transactionType, pending, amount, BigDecimal.ZERO, pendingPluginProperties, 1);
final PaymentTransaction completeTransactionByPaymentIdAndInvalidTransactionType = new PaymentTransaction();
completeTransactionByPaymentIdAndInvalidTransactionType.setPaymentId(initialPayment.getPaymentId());
completeTransactionByPaymentIdAndInvalidTransactionType.setTransactionType(TransactionType.CAPTURE.name());
try {
killBillClient.completePayment(completeTransactionByPaymentIdAndInvalidTransactionType, pluginProperties, requestOptions);
fail("Payment completion should fail when invalid transaction type has been provided");
} catch (final KillBillClientException expected) {
}
final PaymentTransaction completeTransactionByPaymentIdAndTransactionType = new PaymentTransaction();
completeTransactionByPaymentIdAndTransactionType.setPaymentId(initialPayment.getPaymentId());
completeTransactionByPaymentIdAndTransactionType.setTransactionType(transactionType.name());
final Payment completedPaymentByPaymentId = killBillClient.completePayment(completeTransactionByPaymentIdAndTransactionType, pluginProperties, requestOptions);
verifyPayment(account, paymentMethodId, completedPaymentByPaymentId, paymentExternalKey, authTransactionExternalKey, transactionType.toString(), TransactionStatus.SUCCESS.name(), amount, amount, BigDecimal.ZERO, BigDecimal.ZERO, 1, 1);
}
use of org.killbill.billing.client.KillBillClientException in project killbill by killbill.
the class TestAdmin method doCapture.
private void doCapture(final Payment payment, final boolean expectException) throws KillBillClientException {
// Payment object does not export state, this is purely internal, so to verify that we indeed changed to Failed, we can attempt
// a capture, which should fail
final String capture1TransactionExternalKey = UUID.randomUUID().toString();
final PaymentTransaction captureTransaction = new PaymentTransaction();
captureTransaction.setPaymentId(payment.getPaymentId());
captureTransaction.setAmount(BigDecimal.ONE);
captureTransaction.setCurrency(payment.getCurrency());
captureTransaction.setPaymentExternalKey(payment.getPaymentExternalKey());
captureTransaction.setTransactionExternalKey(capture1TransactionExternalKey);
try {
killBillClient.captureAuthorization(captureTransaction, requestOptions);
if (expectException) {
Assert.fail("Capture should not succeed, after auth was moved to a PAYMENT_FAILURE");
}
} catch (final KillBillClientException mabeExpected) {
if (!expectException) {
throw mabeExpected;
}
}
}
use of org.killbill.billing.client.KillBillClientException in project killbill by killbill.
the class TestChargeback method testBadRequest.
@Test(groups = "slow", description = "Cannot add a badly formatted chargeback")
public void testBadRequest() throws Exception {
final Payment payment = createAccountWithInvoiceAndPayment();
final InvoicePaymentTransaction input = new InvoicePaymentTransaction();
input.setPaymentId(payment.getPaymentId());
try {
killBillClient.createInvoicePaymentChargeback(input, createdBy, reason, comment);
fail();
} catch (final KillBillClientException e) {
}
}
use of org.killbill.billing.client.KillBillClientException in project killbill by killbill.
the class TestCredit method testBadRequest.
@Test(groups = "slow", description = "Cannot credit a badly formatted credit")
public void testBadRequest() throws Exception {
final Credit credit = new Credit();
credit.setAccountId(accountJson.getAccountId());
credit.setCreditAmount(BigDecimal.TEN.negate());
// Try to create the credit
try {
killBillClient.createCredit(credit, true, createdBy, reason, comment);
fail();
} catch (final KillBillClientException e) {
}
}
Aggregations