Search in sources :

Example 1 with CardAuthorisationGatewayRequest

use of uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest in project pay-connector by alphagov.

the class EpdqPaymentProviderTest method shouldCheckAuthorisationStatusSuccessfully.

@Test
public void shouldCheckAuthorisationStatusSuccessfully() throws Exception {
    setUpAndCheckThatEpdqIsUp();
    var request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetailsFixture().build());
    GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
    assertThat(response.isSuccessful(), is(true));
    assertThat(response.getBaseResponse().get().authoriseStatus(), is(BaseAuthoriseResponse.AuthoriseStatus.AUTHORISED));
    Gateway3DSAuthorisationResponse queryResponse = paymentProvider.authorise3dsResponse(buildQueryRequest(chargeEntity, Auth3dsResult.Auth3dsResultOutcome.AUTHORISED.name()));
    assertThat(queryResponse.isSuccessful(), is(true));
    assertThat(response.getBaseResponse().get().authoriseStatus(), is(BaseAuthoriseResponse.AuthoriseStatus.AUTHORISED));
}
Also used : BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) Gateway3DSAuthorisationResponse(uk.gov.pay.connector.gateway.model.response.Gateway3DSAuthorisationResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 2 with CardAuthorisationGatewayRequest

use of uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest in project pay-connector by alphagov.

the class EpdqPaymentProviderTest method shouldAuthoriseWith3dsOnAndNoAddressInRequestSuccessfully.

@Test
public void shouldAuthoriseWith3dsOnAndNoAddressInRequestSuccessfully() throws Exception {
    setUpFor3dsAndCheckThatEpdqIsUp();
    AuthCardDetails authCardDetails = authCardDetailsFixture().withCardNo(VISA_CARD_NUMBER_RECOGNISED_AS_REQUIRING_3DS1_BY_EPDQ).withAddress(null).build();
    var request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetails);
    GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
    assertThat(response.isSuccessful(), is(true));
    assertThat(response.getBaseResponse().get().authoriseStatus(), is(REQUIRES_3DS));
}
Also used : BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 3 with CardAuthorisationGatewayRequest

use of uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest in project pay-connector by alphagov.

the class EpdqPaymentProviderTest method shouldQueryPaymentStatusSuccessfully.

@Test
public void shouldQueryPaymentStatusSuccessfully() throws Exception {
    setUpAndCheckThatEpdqIsUp();
    var request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetailsFixture().build());
    GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
    assertThat(response.isSuccessful(), is(true));
    ChargeQueryGatewayRequest chargeQueryGatewayRequest = ChargeQueryGatewayRequest.valueOf(Charge.from(chargeEntity), chargeEntity.getGatewayAccount(), chargeEntity.getGatewayAccountCredentialsEntity());
    ChargeQueryResponse chargeQueryResponse = paymentProvider.queryPaymentStatus(chargeQueryGatewayRequest);
    assertThat(chargeQueryResponse.getMappedStatus(), is(Optional.of(ChargeStatus.AUTHORISATION_SUCCESS)));
    assertThat(chargeQueryResponse.foundCharge(), is(true));
}
Also used : ChargeQueryGatewayRequest(uk.gov.pay.connector.gateway.ChargeQueryGatewayRequest) ChargeQueryResponse(uk.gov.pay.connector.gateway.ChargeQueryResponse) BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 4 with CardAuthorisationGatewayRequest

use of uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest in project pay-connector by alphagov.

the class EpdqPaymentProviderTest method shouldCaptureSuccessfully.

@Test
public void shouldCaptureSuccessfully() throws Exception {
    setUpAndCheckThatEpdqIsUp();
    var request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetailsFixture().build());
    GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
    assertThat(response.isSuccessful(), is(true));
    String transactionId = response.getBaseResponse().get().getTransactionId();
    assertThat(transactionId, is(not(nullValue())));
    CaptureGatewayRequest captureRequest = buildCaptureRequest(chargeEntity, transactionId);
    CaptureResponse captureResponse = paymentProvider.capture(captureRequest);
    assertThat(captureResponse.isSuccessful(), is(true));
    assertThat(captureResponse.state(), Is.is(CaptureResponse.ChargeState.PENDING));
}
Also used : CaptureGatewayRequest(uk.gov.pay.connector.gateway.model.request.CaptureGatewayRequest) BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) CaptureResponse(uk.gov.pay.connector.gateway.CaptureResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 5 with CardAuthorisationGatewayRequest

use of uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest in project pay-connector by alphagov.

the class EpdqPaymentProviderTest method shouldAuthoriseSuccessfullyWhenCardholderNameContainsRightSingleQuotationMark.

@Test
public void shouldAuthoriseSuccessfullyWhenCardholderNameContainsRightSingleQuotationMark() throws Exception {
    setUpAndCheckThatEpdqIsUp();
    // That’s a U+2019 RIGHT SINGLE QUOTATION MARK, not a U+0027 APOSTROPHE
    String cardholderName = "John O’Connor";
    AuthCardDetails authCardDetails = authCardDetailsFixture().withCardHolder(cardholderName).build();
    var request = new CardAuthorisationGatewayRequest(chargeEntity, authCardDetails);
    GatewayResponse<BaseAuthoriseResponse> response = paymentProvider.authorise(request);
    assertThat(response.isSuccessful(), is(true));
}
Also used : BaseAuthoriseResponse(uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Aggregations

CardAuthorisationGatewayRequest (uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest)70 Test (org.junit.Test)43 AuthCardDetails (uk.gov.pay.connector.gateway.model.AuthCardDetails)33 Test (org.junit.jupiter.api.Test)21 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)21 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)21 BaseAuthoriseResponse (uk.gov.pay.connector.gateway.model.response.BaseAuthoriseResponse)21 AuthCardDetailsFixture.anAuthCardDetails (uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails)15 WorldpayPaymentProvider (uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider)14 URI (java.net.URI)13 GatewayOrder (uk.gov.pay.connector.gateway.GatewayOrder)13 GatewayResponse (uk.gov.pay.connector.gateway.model.response.GatewayResponse)13 WorldpayOrderStatusResponse (uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse)13 Address (uk.gov.pay.connector.common.model.domain.Address)11 PaymentProvider (uk.gov.pay.connector.gateway.PaymentProvider)10 SmartpayPaymentProvider (uk.gov.pay.connector.gateway.smartpay.SmartpayPaymentProvider)10 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)7 CaptureResponse (uk.gov.pay.connector.gateway.CaptureResponse)5 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)4 Document (org.w3c.dom.Document)4