use of uk.gov.pay.api.model.search.card.PaymentForSearchResult in project pay-publicapi by alphagov.
the class TransactionSearchService method processResponse.
private TransactionSearchResults processResponse(Response connectorResponse) {
PaymentSearchResponse<TransactionResponse> response;
try {
response = connectorResponse.readEntity(new GenericType<PaymentSearchResponse<TransactionResponse>>() {
});
} catch (ProcessingException ex) {
throw new SearchTransactionsException(ex);
}
List<PaymentForSearchResult> chargeFromResponses = response.getPayments().stream().map(this::getPaymentForSearchResult).collect(toList());
return new TransactionSearchResults(response.getTotal(), response.getCount(), response.getPage(), chargeFromResponses, transformLinks(response.getLinks()));
}
use of uk.gov.pay.api.model.search.card.PaymentForSearchResult in project pay-publicapi by alphagov.
the class TransactionSearchServiceTest method testSearchTransaction.
@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-search-transaction" })
public void testSearchTransaction() {
Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, "a-token-link");
TransactionSearchParams searchParams = new TransactionSearchParams();
TransactionSearchResults searchResults = transactionSearchService.doSearch(account, searchParams);
PaymentForSearchResult payment = searchResults.getResults().get(0);
assertThat(payment.getAmount(), is(1000L));
assertThat(payment.getState(), is(new PaymentState("created", false)));
assertThat(payment.getDescription(), is("Test description"));
assertThat(payment.getReference(), is("aReference"));
assertThat(payment.getLanguage(), is(SupportedLanguage.ENGLISH));
assertThat(payment.getPaymentId(), is(CHARGE_ID));
assertThat(payment.getReturnUrl().get(), is("https://example.org"));
assertThat(payment.getEmail().get(), is("someone@example.org"));
assertThat(payment.getPaymentProvider(), is("sandbox"));
assertThat(payment.getCreatedDate(), is("2018-09-22T10:13:16.067Z"));
assertThat(payment.getDelayedCapture(), is(false));
assertThat(payment.getCardDetails().get().getCardHolderName(), is("J. Smith"));
assertThat(payment.getCardDetails().get().getCardBrand(), is(""));
Address address = payment.getCardDetails().get().getBillingAddress().get();
assertThat(address.getLine1(), is("line1"));
assertThat(address.getLine2(), is("line2"));
assertThat(address.getPostcode(), is("AB1 2CD"));
assertThat(address.getCity(), is("London"));
assertThat(address.getCountry(), is("GB"));
assertThat(payment.getLinks().getSelf().getHref(), containsString("v1/payments/" + CHARGE_ID));
assertThat(payment.getLinks().getSelf().getMethod(), is("GET"));
assertThat(payment.getLinks().getRefunds().getHref(), containsString("v1/payments/" + CHARGE_ID + "/refunds"));
assertThat(payment.getLinks().getRefunds().getMethod(), is("GET"));
assertThat(searchResults.getCount(), is(1));
assertThat(searchResults.getTotal(), is(1));
assertThat(searchResults.getPage(), is(1));
assertThat(searchResults.getLinks().getSelf().getHref(), containsString("/v1/transactions?display_size=500&page=1"));
assertThat(searchResults.getLinks().getFirstPage().getHref(), containsString("/v1/transactions?display_size=500&page=1"));
assertThat(searchResults.getLinks().getLastPage().getHref(), containsString("/v1/transactions?display_size=500&page=1"));
}
Aggregations