Search in sources :

Example 1 with CardPayment

use of uk.gov.pay.api.model.CardPayment 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 CardPayment

use of uk.gov.pay.api.model.CardPayment 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 CardPayment

use of uk.gov.pay.api.model.CardPayment 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 CardPayment

use of uk.gov.pay.api.model.CardPayment 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 CardPayment

use of uk.gov.pay.api.model.CardPayment 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

CardPayment (uk.gov.pay.api.model.CardPayment)13 PactVerification (au.com.dius.pact.consumer.PactVerification)12 Test (org.junit.Test)12 Account (uk.gov.pay.api.auth.Account)12 PaymentWithAllLinks (uk.gov.pay.api.model.links.PaymentWithAllLinks)12 Pacts (uk.gov.service.payments.commons.testing.pact.consumers.Pacts)12 PaymentState (uk.gov.pay.api.model.PaymentState)4 PostLink (uk.gov.pay.api.model.links.PostLink)3 Timed (com.codahale.metrics.annotation.Timed)1 ImmutableMap (com.google.common.collect.ImmutableMap)1 GsonBuilder (com.google.gson.GsonBuilder)1 Auth (io.dropwizard.auth.Auth)1 Operation (io.swagger.v3.oas.annotations.Operation)1 Parameter (io.swagger.v3.oas.annotations.Parameter)1 Content (io.swagger.v3.oas.annotations.media.Content)1 Schema (io.swagger.v3.oas.annotations.media.Schema)1 ApiResponse (io.swagger.v3.oas.annotations.responses.ApiResponse)1 SecurityRequirement (io.swagger.v3.oas.annotations.security.SecurityRequirement)1 Tag (io.swagger.v3.oas.annotations.tags.Tag)1 String.format (java.lang.String.format)1