use of uk.gov.pay.adminusers.model.MerchantDetails in project pay-adminusers by alphagov.
the class ServiceResourceUpdateIT method shouldUpdateMerchantUrlField.
@Test
public void shouldUpdateMerchantUrlField() {
String serviceExternalId = serviceDbFixture(databaseHelper).withMerchantDetails(new MerchantDetails("name", null, "line1", null, "city", "postcode", "country", null, "https://www.example.com")).insertService().getExternalId();
JsonNode payload = mapper.valueToTree(List.of(patchRequest("replace", "merchant_details/url", "https://merchant.example.com")));
givenSetup().when().contentType(JSON).body(payload).patch(format(SERVICE_RESOURCE, serviceExternalId)).then().statusCode(200).body("merchant_details.url", is("https://merchant.example.com"));
}
use of uk.gov.pay.adminusers.model.MerchantDetails in project pay-adminusers by alphagov.
the class DatabaseTestHelper method addService.
public DatabaseTestHelper addService(Service service, String... gatewayAccountIds) {
jdbi.withHandle(handle -> {
PGobject customBranding = service.getCustomBranding() == null ? null : new CustomBrandingConverter().convertToDatabaseColumn(service.getCustomBranding());
MerchantDetails merchantDetails = service.getMerchantDetails();
if (merchantDetails == null) {
merchantDetails = new MerchantDetails();
}
return handle.createUpdate("INSERT INTO services(" + "id, custom_branding, " + "merchant_name, merchant_telephone_number, merchant_address_line1, merchant_address_line2, merchant_address_city, " + "merchant_address_postcode, merchant_address_country, merchant_email, merchant_url, external_id, experimental_features_enabled) " + "VALUES (:id, :customBranding, :merchantName, :merchantTelephoneNumber, :merchantAddressLine1, :merchantAddressLine2, " + ":merchantAddressCity, :merchantAddressPostcode, :merchantAddressCountry, :merchantEmail, :merchantUrl, :externalId, :experimentalFeaturesEnabled)").bind("id", service.getId()).bindBySqlType("customBranding", customBranding, OTHER).bind("merchantName", merchantDetails.getName()).bind("merchantTelephoneNumber", merchantDetails.getTelephoneNumber()).bind("merchantAddressLine1", merchantDetails.getAddressLine1()).bind("merchantAddressLine2", merchantDetails.getAddressLine2()).bind("merchantAddressCity", merchantDetails.getAddressCity()).bind("merchantAddressPostcode", merchantDetails.getAddressPostcode()).bind("merchantAddressCountry", merchantDetails.getAddressCountry()).bind("merchantEmail", merchantDetails.getEmail()).bind("merchantUrl", merchantDetails.getUrl()).bind("externalId", service.getExternalId()).bind("experimentalFeaturesEnabled", service.isExperimentalFeaturesEnabled()).execute();
});
addServiceName(ServiceNameEntity.from(SupportedLanguage.ENGLISH, service.getName()), service.getId());
for (String gatewayAccountId : gatewayAccountIds) {
jdbi.withHandle(handle -> handle.createUpdate("INSERT INTO service_gateway_accounts(service_id, gateway_account_id) VALUES (:serviceId, :gatewayAccountId)").bind("serviceId", service.getId()).bind("gatewayAccountId", gatewayAccountId).execute());
}
return this;
}
use of uk.gov.pay.adminusers.model.MerchantDetails in project pay-adminusers by alphagov.
the class DatabaseTestHelper method insertServiceEntity.
public DatabaseTestHelper insertServiceEntity(ServiceEntity serviceEntity) {
jdbi.withHandle(handle -> {
PGobject customBranding = serviceEntity.getCustomBranding() == null ? null : new CustomBrandingConverter().convertToDatabaseColumn(serviceEntity.getCustomBranding());
MerchantDetailsEntity merchantDetails = serviceEntity.getMerchantDetailsEntity();
return handle.createUpdate("INSERT INTO services(" + "id, custom_branding, " + "merchant_name, merchant_telephone_number, merchant_address_line1, merchant_address_line2, merchant_address_city, " + "merchant_address_postcode, merchant_address_country, merchant_email, merchant_url, external_id, redirect_to_service_immediately_on_terminal_state, " + "current_go_live_stage, experimental_features_enabled, current_psp_test_account_stage, created_date) " + "VALUES (:id, :customBranding, :merchantName, :merchantTelephoneNumber, :merchantAddressLine1, :merchantAddressLine2, " + ":merchantAddressCity, :merchantAddressPostcode, :merchantAddressCountry, :merchantEmail, :merchantUrl, :externalId, :redirectToServiceImmediatelyOnTerminalState, " + ":currentGoLiveStage, :experimentalFeaturesEnabled, :pspTestAccountStage, :createdDate)").bind("id", serviceEntity.getId()).bindBySqlType("customBranding", customBranding, OTHER).bind("merchantName", merchantDetails.getName()).bind("merchantTelephoneNumber", merchantDetails.getTelephoneNumber()).bind("merchantAddressLine1", merchantDetails.getAddressLine1()).bind("merchantAddressLine2", merchantDetails.getAddressLine2()).bind("merchantAddressCity", merchantDetails.getAddressCity()).bind("merchantAddressPostcode", merchantDetails.getAddressPostcode()).bind("merchantAddressCountry", merchantDetails.getAddressCountryCode()).bind("merchantEmail", merchantDetails.getEmail()).bind("merchantUrl", merchantDetails.getUrl()).bind("externalId", serviceEntity.getExternalId()).bind("redirectToServiceImmediatelyOnTerminalState", serviceEntity.isRedirectToServiceImmediatelyOnTerminalState()).bind("currentGoLiveStage", serviceEntity.getCurrentGoLiveStage()).bind("experimentalFeaturesEnabled", serviceEntity.isExperimentalFeaturesEnabled()).bind("pspTestAccountStage", serviceEntity.getCurrentPspTestAccountStage()).bind("createdDate", serviceEntity.getCreatedDate()).execute();
});
serviceEntity.getGatewayAccountIds().forEach(gatewayAccount -> jdbi.withHandle(handle -> handle.createUpdate("INSERT INTO service_gateway_accounts(service_id, gateway_account_id) VALUES (:serviceId, :gatewayAccountId)").bind("serviceId", serviceEntity.getId()).bind("gatewayAccountId", gatewayAccount.getGatewayAccountId()).execute()));
serviceEntity.getServiceNames().values().forEach((name) -> addServiceName(name, serviceEntity.getId()));
return this;
}
Aggregations