use of org.killbill.billing.client.model.gen.InvoicePayment in project killbill by killbill.
the class TestChargeback method testAddChargebackForDeletedPaymentMethod.
@Test(groups = "slow", description = "Can add a chargeback for deleted payment methods")
public void testAddChargebackForDeletedPaymentMethod() throws Exception {
final InvoicePayment payment = createAccountWithInvoiceAndPayment();
// Check the payment method exists
assertEquals(accountApi.getAccount(payment.getAccountId(), requestOptions).getPaymentMethodId(), payment.getPaymentMethodId());
assertEquals(paymentMethodApi.getPaymentMethod(payment.getPaymentMethodId(), NULL_PLUGIN_PROPERTIES, requestOptions).getAccountId(), payment.getAccountId());
// Delete the payment method
paymentMethodApi.deletePaymentMethod(payment.getPaymentMethodId(), true, false, NULL_PLUGIN_PROPERTIES, requestOptions);
// Check the payment method was deleted
assertNull(accountApi.getAccount(payment.getAccountId(), requestOptions).getPaymentMethodId());
createAndVerifyChargeback(payment);
}
use of org.killbill.billing.client.model.gen.InvoicePayment 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 InvoicePayment payment = createAccountWithInvoiceAndPayment();
final InvoicePaymentTransaction input = new InvoicePaymentTransaction();
input.setPaymentId(payment.getPaymentId());
try {
invoicePaymentApi.createChargeback(payment.getPaymentId(), input, NULL_PLUGIN_PROPERTIES, requestOptions);
fail();
} catch (final KillBillClientException e) {
}
}
use of org.killbill.billing.client.model.gen.InvoicePayment in project killbill by killbill.
the class TestChargeback method createAndVerifyChargeback.
private void createAndVerifyChargeback(final InvoicePayment payment) throws KillBillClientException {
List<Invoice> invoices = accountApi.getInvoicesForAccount(payment.getAccountId(), null, null, null, requestOptions);
// We should have two invoices, one for the trial (zero dollar amount) and one for the first month
Assert.assertEquals(invoices.size(), 2);
Assert.assertEquals(invoices.get(1).getBalance().compareTo(BigDecimal.ZERO), 0);
// Create the chargeback
final InvoicePaymentTransaction chargeback = new InvoicePaymentTransaction();
chargeback.setPaymentId(payment.getPaymentId());
chargeback.setAmount(BigDecimal.TEN);
final InvoicePayment chargebackJson = invoicePaymentApi.createChargeback(payment.getPaymentId(), chargeback, NULL_PLUGIN_PROPERTIES, requestOptions);
final List<PaymentTransaction> chargebackTransactions = getInvoicePaymentTransactions(ImmutableList.of(chargebackJson), TransactionType.CHARGEBACK);
assertEquals(chargebackTransactions.size(), 1);
assertEquals(chargebackTransactions.get(0).getAmount().compareTo(chargeback.getAmount()), 0);
assertEquals(chargebackTransactions.get(0).getPaymentId(), chargeback.getPaymentId());
// Find the chargeback by account
final List<InvoicePayment> payments = accountApi.getInvoicePayments(payment.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
final List<PaymentTransaction> transactions = getInvoicePaymentTransactions(payments, TransactionType.CHARGEBACK);
Assert.assertEquals(transactions.size(), 1);
assertEquals(transactions.get(0).getAmount().compareTo(chargeback.getAmount()), 0);
assertEquals(transactions.get(0).getPaymentId(), chargeback.getPaymentId());
// Verify invoice balance
invoices = accountApi.getInvoicesForAccount(payment.getAccountId(), null, null, null, requestOptions);
Assert.assertEquals(invoices.size(), 2);
Assert.assertEquals(invoices.get(1).getBalance().compareTo(BigDecimal.ZERO), 1);
}
use of org.killbill.billing.client.model.gen.InvoicePayment in project killbill by killbill.
the class TestChargeback method testAddChargeback.
@Test(groups = "slow", description = "Can create a chargeback")
public void testAddChargeback() throws Exception {
final InvoicePayment payment = createAccountWithInvoiceAndPayment();
createAndVerifyChargeback(payment);
}
Aggregations