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"));
}
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()));
}
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()));
}
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()));
}
Aggregations