use of org.killbill.billing.client.RequestOptions in project killbill by killbill.
the class TestPayment method testWithFailedPaymentAndScheduledAttemptsSearchPayments.
@Test(groups = "slow")
public void testWithFailedPaymentAndScheduledAttemptsSearchPayments() throws Exception {
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
createAccountWithPMBundleAndSubscriptionAndWaitForFirstInvoice();
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 = killBillClient.searchPayments("", 0L, 100L, AuditLevel.NONE, 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");
}
use of org.killbill.billing.client.RequestOptions in project killbill by killbill.
the class TestPayment method testWithFailedPaymentAndWithoutFollowLocation.
@Test(groups = "slow")
public void testWithFailedPaymentAndWithoutFollowLocation() throws Exception {
final Account account = createAccountWithDefaultPaymentMethod();
mockPaymentProviderPlugin.makeNextPaymentFailWithError();
final PaymentTransaction authTransaction = new PaymentTransaction();
authTransaction.setAmount(BigDecimal.ONE);
authTransaction.setCurrency(account.getCurrency());
authTransaction.setTransactionType(TransactionType.AUTHORIZE.name());
final RequestOptions requestOptionsWithoutFollowLocation = RequestOptions.builder().withCreatedBy(createdBy).withReason(reason).withComment(comment).withFollowLocation(false).build();
try {
killBillClient.createPayment(account.getAccountId(), account.getPaymentMethodId(), authTransaction, ImmutableMap.<String, String>of(), requestOptionsWithoutFollowLocation);
fail();
} catch (final KillBillClientException e) {
assertEquals(e.getResponse().getStatusCode(), 402);
assertEquals(e.getBillingException().getMessage(), "Payment decline by gateway. Error message: gatewayError");
}
}
Aggregations