Search in sources :

Example 1 with Pacts

use of uk.gov.service.payments.commons.testing.pact.consumers.Pacts in project pay-publicapi by alphagov.

the class GetPaymentServiceLedgerTest method testGetPaymentWithSettledDate.

@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-settled-date" })
public void testGetPaymentWithSettledDate() {
    Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
    PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, "ch_123abc456settlement");
    CardPayment payment = (CardPayment) paymentResponse.getPayment();
    assertThat(payment.getSettlementSummary().isPresent(), is(true));
    assertThat(payment.getSettlementSummary().get().getSettledDate(), is("2020-09-19"));
}
Also used : Account(uk.gov.pay.api.auth.Account) CardPayment(uk.gov.pay.api.model.CardPayment) PaymentWithAllLinks(uk.gov.pay.api.model.links.PaymentWithAllLinks) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test) Pacts(uk.gov.service.payments.commons.testing.pact.consumers.Pacts)

Example 2 with Pacts

use of uk.gov.service.payments.commons.testing.pact.consumers.Pacts in project pay-publicapi by alphagov.

the class GetPaymentServiceLedgerTest method providerIdIsAvailableWhenPaymentIsSubmitted_Ledger.

@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-gateway-transaction-id" })
public void providerIdIsAvailableWhenPaymentIsSubmitted_Ledger() {
    Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
    PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, CHARGE_ID_NON_EXISTENT_IN_CONNECTOR);
    CardPayment payment = (CardPayment) paymentResponse.getPayment();
    assertThat(payment.getProviderId(), is("gateway-tx-123456"));
}
Also used : Account(uk.gov.pay.api.auth.Account) CardPayment(uk.gov.pay.api.model.CardPayment) PaymentWithAllLinks(uk.gov.pay.api.model.links.PaymentWithAllLinks) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test) Pacts(uk.gov.service.payments.commons.testing.pact.consumers.Pacts)

Example 3 with Pacts

use of uk.gov.service.payments.commons.testing.pact.consumers.Pacts in project pay-publicapi by alphagov.

the class GetPaymentServiceLedgerTest method testGetPaymentWithFeeAndNetAmountFromLedger.

@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-fee-and-net-amount" })
public void testGetPaymentWithFeeAndNetAmountFromLedger() {
    Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
    PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, CHARGE_ID_NON_EXISTENT_IN_CONNECTOR);
    CardPayment payment = (CardPayment) paymentResponse.getPayment();
    assertThat(payment.getPaymentId(), is(CHARGE_ID_NON_EXISTENT_IN_CONNECTOR));
    assertThat(payment.getPaymentProvider(), is("sandbox"));
    assertThat(payment.getAmount(), is(100L));
    assertThat(payment.getFee().get(), is(5L));
    assertThat(payment.getNetAmount().get(), is(95L));
}
Also used : Account(uk.gov.pay.api.auth.Account) CardPayment(uk.gov.pay.api.model.CardPayment) PaymentWithAllLinks(uk.gov.pay.api.model.links.PaymentWithAllLinks) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test) Pacts(uk.gov.service.payments.commons.testing.pact.consumers.Pacts)

Example 4 with Pacts

use of uk.gov.service.payments.commons.testing.pact.consumers.Pacts in project pay-publicapi by alphagov.

the class GetPaymentServiceLedgerTest method testGetPaymentWithAuthorisationSummaryFromLedger.

@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-authorisation-summary" })
public void testGetPaymentWithAuthorisationSummaryFromLedger() {
    Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
    PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, CHARGE_ID_NON_EXISTENT_IN_CONNECTOR);
    CardPayment payment = (CardPayment) paymentResponse.getPayment();
    assertThat(payment.getAuthorisationSummary().getThreeDSecure().isRequired(), is(true));
}
Also used : Account(uk.gov.pay.api.auth.Account) CardPayment(uk.gov.pay.api.model.CardPayment) PaymentWithAllLinks(uk.gov.pay.api.model.links.PaymentWithAllLinks) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test) Pacts(uk.gov.service.payments.commons.testing.pact.consumers.Pacts)

Example 5 with Pacts

use of uk.gov.service.payments.commons.testing.pact.consumers.Pacts in project pay-publicapi by alphagov.

the class GetPaymentServiceLedgerTest method testGetPaymentWithMetadataFromLedger.

@Test
@PactVerification({ "ledger" })
@Pacts(pacts = { "publicapi-ledger-get-payment-with-metadata" })
public void testGetPaymentWithMetadataFromLedger() {
    Account account = new Account(ACCOUNT_ID, TokenPaymentType.CARD, tokenLink);
    PaymentWithAllLinks paymentResponse = getPaymentService.getPayment(account, CHARGE_ID_NON_EXISTENT_IN_CONNECTOR);
    CardPayment payment = (CardPayment) paymentResponse.getPayment();
    assertThat(payment.getMetadata(), is(notNullValue()));
    assertThat(payment.getMetadata().getMetadata().isEmpty(), is(false));
}
Also used : Account(uk.gov.pay.api.auth.Account) CardPayment(uk.gov.pay.api.model.CardPayment) PaymentWithAllLinks(uk.gov.pay.api.model.links.PaymentWithAllLinks) PactVerification(au.com.dius.pact.consumer.PactVerification) Test(org.junit.Test) Pacts(uk.gov.service.payments.commons.testing.pact.consumers.Pacts)

Aggregations

PactVerification (au.com.dius.pact.consumer.PactVerification)37 Test (org.junit.Test)37 Pacts (uk.gov.service.payments.commons.testing.pact.consumers.Pacts)37 Account (uk.gov.pay.api.auth.Account)32 CardPayment (uk.gov.pay.api.model.CardPayment)12 PaymentWithAllLinks (uk.gov.pay.api.model.links.PaymentWithAllLinks)12 Response (javax.ws.rs.core.Response)7 PaymentState (uk.gov.pay.api.model.PaymentState)5 RefundResponse (uk.gov.pay.api.model.RefundResponse)4 SearchRefundsResults (uk.gov.pay.api.model.search.card.SearchRefundsResults)4 PostLink (uk.gov.pay.api.model.links.PostLink)3 LedgerTransaction (uk.gov.pay.connector.client.ledger.model.LedgerTransaction)3 Address (uk.gov.pay.api.model.Address)2 PaymentEventsResponse (uk.gov.pay.api.model.PaymentEventsResponse)2 RefundsResponse (uk.gov.pay.api.model.RefundsResponse)2 Link (uk.gov.pay.api.model.links.Link)2 CreateChargeException (uk.gov.pay.api.exception.CreateChargeException)1 SearchPaymentsException (uk.gov.pay.api.exception.SearchPaymentsException)1 SearchRefundsException (uk.gov.pay.api.exception.SearchRefundsException)1 TransactionSearchParams (uk.gov.pay.api.ledger.model.TransactionSearchParams)1