Search in sources :

Example 1 with AddGatewayAccountParams

use of uk.gov.pay.connector.util.AddGatewayAccountParams in project pay-connector by alphagov.

the class ChargesApiResourceCreateIT method shouldCreateChargeForProvidedPaymentProvider.

@Test
public void shouldCreateChargeForProvidedPaymentProvider() {
    String accountId = String.valueOf(RandomUtils.nextInt());
    AddGatewayAccountCredentialsParams credentialsToUse = anAddGatewayAccountCredentialsParams().withPaymentProvider("worldpay").withState(GatewayAccountCredentialState.ENTERED).withGatewayAccountId(Long.parseLong(accountId)).build();
    AddGatewayAccountCredentialsParams activeCredentials = anAddGatewayAccountCredentialsParams().withPaymentProvider("sandbox").withState(GatewayAccountCredentialState.ACTIVE).withGatewayAccountId(Long.parseLong(accountId)).build();
    AddGatewayAccountParams gatewayAccountParams = anAddGatewayAccountParams().withPaymentGateway("sandbox").withGatewayAccountCredentials(List.of(credentialsToUse, activeCredentials)).withAccountId(accountId).build();
    databaseTestHelper.addGatewayAccount(gatewayAccountParams);
    String postBody = toJson(Map.of(JSON_AMOUNT_KEY, AMOUNT, JSON_REFERENCE_KEY, JSON_REFERENCE_VALUE, JSON_DESCRIPTION_KEY, JSON_DESCRIPTION_VALUE, JSON_RETURN_URL_KEY, RETURN_URL, JSON_PROVIDER_KEY, "worldpay"));
    connectorRestApiClient.postCreateCharge(postBody, accountId).statusCode(Status.CREATED.getStatusCode()).contentType(JSON).body(JSON_PROVIDER_KEY, is("worldpay"));
}
Also used : AddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams) AddGatewayAccountParamsBuilder.anAddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams.AddGatewayAccountParamsBuilder.anAddGatewayAccountParams) AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams) AddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams) Test(org.junit.Test)

Example 2 with AddGatewayAccountParams

use of uk.gov.pay.connector.util.AddGatewayAccountParams in project pay-connector by alphagov.

the class ChargesApiResourceCreateIT method shouldReturn400WhenNoCredentialsInUsableStateForProvider.

@Test
public void shouldReturn400WhenNoCredentialsInUsableStateForProvider() {
    String accountId = String.valueOf(RandomUtils.nextInt());
    AddGatewayAccountCredentialsParams credentials = anAddGatewayAccountCredentialsParams().withPaymentProvider("worldpay").withState(GatewayAccountCredentialState.RETIRED).withGatewayAccountId(Long.parseLong(accountId)).build();
    AddGatewayAccountParams gatewayAccountParams = anAddGatewayAccountParams().withPaymentGateway("worldpay").withGatewayAccountCredentials(List.of(credentials)).withAccountId(accountId).build();
    databaseTestHelper.addGatewayAccount(gatewayAccountParams);
    String postBody = toJson(Map.of(JSON_AMOUNT_KEY, AMOUNT, JSON_REFERENCE_KEY, JSON_REFERENCE_VALUE, JSON_DESCRIPTION_KEY, JSON_DESCRIPTION_VALUE, JSON_RETURN_URL_KEY, RETURN_URL, JSON_PROVIDER_KEY, "worldpay"));
    connectorRestApiClient.postCreateCharge(postBody, accountId).statusCode(Status.BAD_REQUEST.getStatusCode()).contentType(JSON).body("message", contains("Payment provider details are not configured on this account")).body("error_identifier", is(ErrorIdentifier.ACCOUNT_NOT_LINKED_WITH_PSP.toString()));
}
Also used : AddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams) AddGatewayAccountParamsBuilder.anAddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams.AddGatewayAccountParamsBuilder.anAddGatewayAccountParams) AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams) AddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams) Test(org.junit.Test)

Example 3 with AddGatewayAccountParams

use of uk.gov.pay.connector.util.AddGatewayAccountParams in project pay-connector by alphagov.

the class ChargesApiResourceCreateIT method shouldReturn400WhenCredentialsInCreatedState.

@Test
public void shouldReturn400WhenCredentialsInCreatedState() {
    String accountId = String.valueOf(RandomUtils.nextInt());
    AddGatewayAccountCredentialsParams credentials = anAddGatewayAccountCredentialsParams().withPaymentProvider("worldpay").withState(GatewayAccountCredentialState.CREATED).withGatewayAccountId(Long.parseLong(accountId)).build();
    AddGatewayAccountParams gatewayAccountParams = anAddGatewayAccountParams().withPaymentGateway("worldpay").withGatewayAccountCredentials(List.of(credentials)).withAccountId(accountId).build();
    databaseTestHelper.addGatewayAccount(gatewayAccountParams);
    String postBody = toJson(Map.of(JSON_AMOUNT_KEY, AMOUNT, JSON_REFERENCE_KEY, JSON_REFERENCE_VALUE, JSON_DESCRIPTION_KEY, JSON_DESCRIPTION_VALUE, JSON_RETURN_URL_KEY, RETURN_URL));
    connectorRestApiClient.postCreateCharge(postBody, accountId).statusCode(Status.BAD_REQUEST.getStatusCode()).contentType(JSON).body("message", contains("Payment provider details are not configured on this account")).body("error_identifier", is(ErrorIdentifier.ACCOUNT_NOT_LINKED_WITH_PSP.toString()));
}
Also used : AddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams) AddGatewayAccountParamsBuilder.anAddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams.AddGatewayAccountParamsBuilder.anAddGatewayAccountParams) AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams) AddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams) Test(org.junit.Test)

Example 4 with AddGatewayAccountParams

use of uk.gov.pay.connector.util.AddGatewayAccountParams in project pay-connector by alphagov.

the class ChargesApiResourceCreateIT method shouldReturn400WhenNoCredentialsForProviderSpecified.

@Test
public void shouldReturn400WhenNoCredentialsForProviderSpecified() {
    String accountId = String.valueOf(RandomUtils.nextInt());
    AddGatewayAccountCredentialsParams credentials = anAddGatewayAccountCredentialsParams().withPaymentProvider("sandbox").withState(GatewayAccountCredentialState.ACTIVE).withGatewayAccountId(Long.parseLong(accountId)).build();
    AddGatewayAccountParams gatewayAccountParams = anAddGatewayAccountParams().withPaymentGateway("sandbox").withGatewayAccountCredentials(List.of(credentials)).withAccountId(accountId).build();
    databaseTestHelper.addGatewayAccount(gatewayAccountParams);
    String postBody = toJson(Map.of(JSON_AMOUNT_KEY, AMOUNT, JSON_REFERENCE_KEY, JSON_REFERENCE_VALUE, JSON_DESCRIPTION_KEY, JSON_DESCRIPTION_VALUE, JSON_RETURN_URL_KEY, RETURN_URL, JSON_PROVIDER_KEY, "worldpay"));
    connectorRestApiClient.postCreateCharge(postBody, accountId).statusCode(Status.BAD_REQUEST.getStatusCode()).contentType(JSON).body("message", contains("Account does not support payment provider [worldpay]")).body("error_identifier", is(ErrorIdentifier.GENERIC.toString()));
}
Also used : AddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams) AddGatewayAccountParamsBuilder.anAddGatewayAccountParams(uk.gov.pay.connector.util.AddGatewayAccountParams.AddGatewayAccountParamsBuilder.anAddGatewayAccountParams) AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams) AddGatewayAccountCredentialsParams(uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 AddGatewayAccountCredentialsParams (uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams)4 AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams (uk.gov.pay.connector.util.AddGatewayAccountCredentialsParams.AddGatewayAccountCredentialsParamsBuilder.anAddGatewayAccountCredentialsParams)4 AddGatewayAccountParams (uk.gov.pay.connector.util.AddGatewayAccountParams)4 AddGatewayAccountParamsBuilder.anAddGatewayAccountParams (uk.gov.pay.connector.util.AddGatewayAccountParams.AddGatewayAccountParamsBuilder.anAddGatewayAccountParams)4