Search in sources :

Example 21 with Invoices

use of org.killbill.billing.client.model.Invoices in project killbill by killbill.

the class TestInvoicePayment method testWithFailedInvoicePayment.

@Test(groups = "slow")
public void testWithFailedInvoicePayment() throws Exception {
    mockPaymentProviderPlugin.makeNextPaymentFailWithError();
    final DateTime initialDate = new DateTime(2012, 4, 25, 0, 3, 42, 0);
    clock.setDeltaFromReality(initialDate.getMillis() - clock.getUTCNow().getMillis());
    final Account accountJson = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
    InvoicePayments invoicePayments = accountApi.getInvoicePayments(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
    assertEquals(invoicePayments.size(), 1);
    final InvoicePayment invoicePayment = invoicePayments.get(0);
    // Verify targetInvoiceId is not Null. See #593
    assertNotNull(invoicePayment.getTargetInvoiceId());
    // Verify targetInvoiceId is not null. See #1014
    assertEquals(invoicePaymentApi.getInvoicePayment(invoicePayment.getPaymentId(), NULL_PLUGIN_PROPERTIES, requestOptions).getTargetInvoiceId(), invoicePayment.getTargetInvoiceId());
    final Invoices invoices = accountApi.getInvoicesForAccount(accountJson.getAccountId(), null, null, null, requestOptions);
    assertEquals(invoices.size(), 2);
    final Invoice invoice = invoices.get(1);
    // Verify this is the correct value
    assertEquals(invoicePayment.getTargetInvoiceId(), invoice.getInvoiceId());
    // Make a payment and verify both invoice payment point to the same targetInvoiceId
    final Invoices paidInvoices = accountApi.payAllInvoices(accountJson.getAccountId(), null, false, null, null, NULL_PLUGIN_PROPERTIES, requestOptions);
    assertEquals(paidInvoices.size(), 1);
    invoicePayments = accountApi.getInvoicePayments(accountJson.getAccountId(), NULL_PLUGIN_PROPERTIES, requestOptions);
    assertEquals(invoicePayments.size(), 2);
    for (final InvoicePayment cur : invoicePayments) {
        assertEquals(cur.getTargetInvoiceId(), invoice.getInvoiceId());
    }
}
Also used : Account(org.killbill.billing.client.model.gen.Account) InvoicePayment(org.killbill.billing.client.model.gen.InvoicePayment) Invoice(org.killbill.billing.client.model.gen.Invoice) Invoices(org.killbill.billing.client.model.Invoices) InvoicePayments(org.killbill.billing.client.model.InvoicePayments) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Example 22 with Invoices

use of org.killbill.billing.client.model.Invoices in project killbill by killbill.

the class TestInvoicePayment method testPayZeroInvoice.

@Test(groups = "slow", description = "Trigger payments for account with no unpaid invoices")
public void testPayZeroInvoice() throws Exception {
    clock.setTime(new DateTime(2012, 4, 25, 0, 3, 42, 0));
    // No payment method
    final Account accountJson = createAccountWithExternalPaymentMethod();
    // Pay all invoices - nothing to pay
    final Invoices paidInvoices = accountApi.payAllInvoices(accountJson.getAccountId(), null, true, null, null, NULL_PLUGIN_PROPERTIES, requestOptions);
    assertEquals(paidInvoices.size(), 0);
}
Also used : Account(org.killbill.billing.client.model.gen.Account) Invoices(org.killbill.billing.client.model.Invoices) DateTime(org.joda.time.DateTime) Test(org.testng.annotations.Test)

Aggregations

Invoices (org.killbill.billing.client.model.Invoices)22 Test (org.testng.annotations.Test)20 Account (org.killbill.billing.client.model.gen.Account)19 DateTime (org.joda.time.DateTime)11 Invoice (org.killbill.billing.client.model.gen.Invoice)10 InvoiceItem (org.killbill.billing.client.model.gen.InvoiceItem)9 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)8 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)7 Payments (org.killbill.billing.client.model.Payments)6 InvoicePaymentTransaction (org.killbill.billing.client.model.gen.InvoicePaymentTransaction)6 UUID (java.util.UUID)4 Payment (org.killbill.billing.client.model.gen.Payment)4 BigDecimal (java.math.BigDecimal)3 LocalDate (org.joda.time.LocalDate)3 InvoiceItems (org.killbill.billing.client.model.InvoiceItems)2 Tags (org.killbill.billing.client.model.Tags)2 AuditLog (org.killbill.billing.client.model.gen.AuditLog)2 Subscription (org.killbill.billing.client.model.gen.Subscription)2 Predicate (com.google.common.base.Predicate)1 KillBillClientException (org.killbill.billing.client.KillBillClientException)1