Search in sources :

Example 1 with WorldpayPaymentProvider

use of uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method shouldBeAbleToSendAuthorisationRequestForMerchant.

@Test
public void shouldBeAbleToSendAuthorisationRequestForMerchant() {
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    AuthCardDetails authCardDetails = anAuthCardDetails().build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) AuthCardDetailsFixture.anAuthCardDetails(uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 2 with WorldpayPaymentProvider

use of uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method submitAuthRequestWithExemptionEngineFlag.

@Test
public void submitAuthRequestWithExemptionEngineFlag() {
    validGatewayAccount.setRequires3ds(true);
    validGatewayAccount.setIntegrationVersion3ds(2);
    validGatewayAccount.setWorldpay3dsFlexCredentialsEntity(aWorldpay3dsFlexCredentialsEntity().withExemptionEngine(true).build());
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    // card holder of "EE.HONOURED_ISSUER_HONOURED.AUTHORISED" elicits an authorised response, see https://developer.worldpay.com/docs/wpg/scaexemptionservices/exemptionengine#testing-exemption-engine
    var authCardDetails = anAuthCardDetails().withCardHolder("EE.HONOURED_ISSUER_HONOURED.AUTHORISED").withWorldpay3dsFlexDdcResult(UUID.randomUUID().toString()).build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
    assertTrue(response.getBaseResponse().get().getLastEvent().isPresent());
    assertEquals(response.getBaseResponse().get().getLastEvent().get(), "AUTHORISED");
    assertTrue(response.getBaseResponse().get().getExemptionResponseResult().isPresent());
    assertEquals(response.getBaseResponse().get().getExemptionResponseResult().get(), "HONOURED");
    assertEquals(response.getBaseResponse().get().getExemptionResponseReason(), "ISSUER_HONOURED");
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 3 with WorldpayPaymentProvider

use of uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method submitAuthForSoftDecline.

@Test
public void submitAuthForSoftDecline() {
    validGatewayAccount.setRequires3ds(true);
    validGatewayAccount.setIntegrationVersion3ds(2);
    validGatewayAccount.setWorldpay3dsFlexCredentialsEntity(aWorldpay3dsFlexCredentialsEntity().withExemptionEngine(true).build());
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    // card holder of "EE.REJECTED_ISSUER_REJECTED.SOFT_DECLINED" elicits a soft decline response, see https://developer.worldpay.com/docs/wpg/scaexemptionservices/exemptionengine#testing-exemption-engine
    var authCardDetails = anAuthCardDetails().withCardHolder("EE.REJECTED_ISSUER_REJECTED.SOFT_DECLINED").withWorldpay3dsFlexDdcResult(UUID.randomUUID().toString()).build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
    assertTrue(response.getBaseResponse().get().getLastEvent().isPresent());
    assertEquals(response.getBaseResponse().get().getLastEvent().get(), "AUTHORISED");
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 4 with WorldpayPaymentProvider

use of uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method submit3DS2FlexAuthRequest_requiresChallenge.

@Test
public void submit3DS2FlexAuthRequest_requiresChallenge() {
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    AuthCardDetails authCardDetails = anAuthCardDetails().withCardHolder(MAGIC_CARDHOLDER_NAME_FOR_3DS_FLEX_CHALLENGE_REQUIRED_RESPONSE).withWorldpay3dsFlexDdcResult(UUID.randomUUID().toString()).build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
    response.getBaseResponse().ifPresent(res -> {
        assertThat(res.getGatewayParamsFor3ds().isPresent(), is(true));
        assertThat(res.getGatewayParamsFor3ds().get().toAuth3dsRequiredEntity().getWorldpayChallengeAcsUrl(), is(notNullValue()));
        assertThat(res.getGatewayParamsFor3ds().get().toAuth3dsRequiredEntity().getWorldpayChallengeTransactionId(), is(notNullValue()));
        assertThat(res.getGatewayParamsFor3ds().get().toAuth3dsRequiredEntity().getWorldpayChallengePayload(), is(notNullValue()));
        assertThat(res.getGatewayParamsFor3ds().get().toAuth3dsRequiredEntity().getThreeDsVersion(), is(notNullValue()));
    });
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) AuthCardDetailsFixture.anAuthCardDetails(uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails) AuthCardDetails(uk.gov.pay.connector.gateway.model.AuthCardDetails) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Example 5 with WorldpayPaymentProvider

use of uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider in project pay-connector by alphagov.

the class WorldpayPaymentProviderTest method submit3DS2FlexAuthRequest.

@Test
public void submit3DS2FlexAuthRequest() {
    WorldpayPaymentProvider paymentProvider = getValidWorldpayPaymentProvider();
    var authCardDetails = anAuthCardDetails().withWorldpay3dsFlexDdcResult(UUID.randomUUID().toString()).build();
    CardAuthorisationGatewayRequest request = getCardAuthorisationRequest(authCardDetails);
    GatewayResponse<WorldpayOrderStatusResponse> response = paymentProvider.authorise(request);
    assertTrue(response.getBaseResponse().isPresent());
}
Also used : WorldpayPaymentProvider(uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider) WorldpayOrderStatusResponse(uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse) CardAuthorisationGatewayRequest(uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest) Test(org.junit.Test)

Aggregations

WorldpayPaymentProvider (uk.gov.pay.connector.gateway.worldpay.WorldpayPaymentProvider)16 Test (org.junit.Test)15 CardAuthorisationGatewayRequest (uk.gov.pay.connector.gateway.model.request.CardAuthorisationGatewayRequest)14 WorldpayOrderStatusResponse (uk.gov.pay.connector.gateway.worldpay.WorldpayOrderStatusResponse)13 AuthCardDetails (uk.gov.pay.connector.gateway.model.AuthCardDetails)11 AuthCardDetailsFixture.anAuthCardDetails (uk.gov.pay.connector.model.domain.AuthCardDetailsFixture.anAuthCardDetails)11 Mockito.anyString (org.mockito.Mockito.anyString)2 ChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntity)2 ChargeEntityFixture.aValidChargeEntity (uk.gov.pay.connector.charge.model.domain.ChargeEntityFixture.aValidChargeEntity)2 Address (uk.gov.pay.connector.common.model.domain.Address)2 CaptureResponse (uk.gov.pay.connector.gateway.CaptureResponse)2 MetricRegistry (com.codahale.metrics.MetricRegistry)1 ChargeDao (uk.gov.pay.connector.charge.dao.ChargeDao)1 EventService (uk.gov.pay.connector.events.EventService)1 GatewayClient (uk.gov.pay.connector.gateway.GatewayClient)1 GatewayClientFactory (uk.gov.pay.connector.gateway.GatewayClientFactory)1 GatewayOperation (uk.gov.pay.connector.gateway.GatewayOperation)1 PaymentGatewayName (uk.gov.pay.connector.gateway.PaymentGatewayName)1 CancelGatewayRequest (uk.gov.pay.connector.gateway.model.request.CancelGatewayRequest)1 GatewayRefundResponse (uk.gov.pay.connector.gateway.model.response.GatewayRefundResponse)1