Search in sources :

Example 16 with Payments

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

the class TestPayment method testWithFailedPaymentAndScheduledAttemptsGetPaymentsForAccount.

@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsGetPaymentsForAccount() throws Exception {
    mockPaymentProviderPlugin.makeNextPaymentFailWithError();
    final Account account = createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice(false);
    HashMultimap<String, String> queryParams = HashMultimap.create();
    queryParams.put("withAttempts", "true");
    RequestOptions inputOptions = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).withQueryParams(queryParams).build();
    Payments payments = accountApi.getPaymentsForAccount(account.getAccountId(), NULL_PLUGIN_PROPERTIES, inputOptions);
    Assert.assertNotNull(payments.get(0).getPaymentAttempts());
    Assert.assertEquals(payments.get(0).getPaymentAttempts().get(0).getStateName(), "RETRIED");
    Assert.assertEquals(payments.get(0).getPaymentAttempts().get(1).getStateName(), "SCHEDULED");
}
Also used : Account(org.killbill.billing.client.model.gen.Account) RequestOptions(org.killbill.billing.client.RequestOptions) InvoicePayments(org.killbill.billing.client.model.InvoicePayments) Payments(org.killbill.billing.client.model.Payments) Test(org.testng.annotations.Test)

Example 17 with Payments

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

the class TestPayment method verifyComboPayment.

private void verifyComboPayment(final Payment payment, final String paymentExternalKey, final BigDecimal authAmount, final BigDecimal capturedAmount, final BigDecimal refundedAmount, final int nbTransactions, final int paymentNb) throws KillBillClientException {
    Assert.assertNotNull(payment.getPaymentNumber());
    assertEquals(payment.getPaymentExternalKey(), paymentExternalKey);
    assertEquals(payment.getAuthAmount().compareTo(authAmount), 0);
    assertEquals(payment.getCapturedAmount().compareTo(capturedAmount), 0);
    assertEquals(payment.getRefundedAmount().compareTo(refundedAmount), 0);
    assertEquals(payment.getTransactions().size(), nbTransactions);
    final Payments Payments = paymentApi.getPayments(null, NULL_PLUGIN_PROPERTIES, requestOptions);
    assertEquals(Payments.size(), paymentNb);
    assertEquals(Payments.get(paymentNb - 1), payment);
}
Also used : InvoicePayments(org.killbill.billing.client.model.InvoicePayments) Payments(org.killbill.billing.client.model.Payments)

Aggregations

Payments (org.killbill.billing.client.model.Payments)17 InvoicePayments (org.killbill.billing.client.model.InvoicePayments)16 Test (org.testng.annotations.Test)15 InvoicePayment (org.killbill.billing.client.model.gen.InvoicePayment)11 Account (org.killbill.billing.client.model.gen.Account)10 InvoicePaymentTransaction (org.killbill.billing.client.model.gen.InvoicePaymentTransaction)8 DateTime (org.joda.time.DateTime)7 Payment (org.killbill.billing.client.model.gen.Payment)7 Invoices (org.killbill.billing.client.model.Invoices)6 RequestOptions (org.killbill.billing.client.RequestOptions)4 Invoice (org.killbill.billing.client.model.gen.Invoice)3 InvoiceItem (org.killbill.billing.client.model.gen.InvoiceItem)3 BigDecimal (java.math.BigDecimal)1 ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 Account (org.killbill.billing.client.model.Account)1 InvoiceItem (org.killbill.billing.client.model.InvoiceItem)1 PaymentMethod (org.killbill.billing.client.model.gen.PaymentMethod)1 PaymentMethodPluginDetail (org.killbill.billing.client.model.gen.PaymentMethodPluginDetail)1 PaymentTransaction (org.killbill.billing.client.model.gen.PaymentTransaction)1