Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CIV-16531 add language #1661

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class FeesPaymentControllerTest extends BaseIntegrationTest {
private static final CardPaymentServiceRequestDTO CARD_PAYMENT_SERVICE_REQUEST
= CardPaymentServiceRequestDTO.builder()
.returnUrl("http://localhost:3001/general-application/payment-confirmation/1701090368574910/gaid/2801090368574910")
.language("En")
.language("en")
.amount(new BigDecimal("232.00")).currency("GBP").build();

@MockBean
Expand Down Expand Up @@ -76,7 +76,7 @@ void shouldCreateGovPayPaymentUrlForServiceRequestPayment() {
CARD_PAYMENT_SERVICE_REQUEST
)).thenReturn(response);

doPost(BEARER_TOKEN, "", FEES_PAYMENT_REQUEST_URL, "2801090368574910")
doPost(BEARER_TOKEN, "", FEES_PAYMENT_REQUEST_URL, "2801090368574910", "en")
.andExpect(content().json(toJson(CardPaymentStatusResponse.from(response))))
.andExpect(status().isOk());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
@RequiredArgsConstructor
public class FeesPaymentController {

public static final String FEES_PAYMENT_REQUEST_URL = "/fees/case/{caseReference}/payment";
public static final String FEES_PAYMENT_REQUEST_URL = "/fees/case/{caseReference}/{language}/payment";
public static final String FEES_PAYMENT_STATUS_URL = "/fees/case/{caseReference}/payment/{paymentReference}/status";
private final FeesPaymentService feesPaymentService;

Expand All @@ -34,10 +34,11 @@ public class FeesPaymentController {
@ApiResponse(responseCode = "400", description = "Bad Request")})
public ResponseEntity<CardPaymentStatusResponse> createGovPaymentRequest(
@RequestHeader(HttpHeaders.AUTHORIZATION) String authorization,
@PathVariable("caseReference") String caseReference) {
@PathVariable("caseReference") String caseReference,
@PathVariable("language") String language) {

return new ResponseEntity<>(
feesPaymentService.createGovPaymentRequest(caseReference, authorization),
feesPaymentService.createGovPaymentRequest(caseReference, language, authorization),
HttpStatus.OK
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ public class FeesPaymentService {
private final UpdatePaymentStatusService updatePaymentStatusService;
@Value("${cui-front-end.url}") String cuiFrontEndUrl;

public CardPaymentStatusResponse createGovPaymentRequest(String caseReference, String authorization) {
public CardPaymentStatusResponse createGovPaymentRequest(String caseReference, String language, String authorization) {

log.info("Creating gov Payment request url for caseId {}", caseReference);
log.info("Creating gov Payment request url for caseId {} {}", caseReference, language);
CaseDetails caseDetails = coreCaseDataService.getCase(Long.valueOf(caseReference));
CaseData caseData = caseDetailsConverter.toCaseData(caseDetails);
String parentCaseRef = caseData.getParentCaseReference();
Expand All @@ -48,7 +48,7 @@ public CardPaymentStatusResponse createGovPaymentRequest(String caseReference, S
.divide(BigDecimal.valueOf(100), RoundingMode.CEILING)
.setScale(2, RoundingMode.CEILING))
.currency("GBP")
.language(caseData.isApplicantBilingual() ? "cy" : "En")
.language(language)
.returnUrl(cuiFrontEndUrl + returnUrlSubPath + caseReference)
.build();
CardPaymentServiceRequestResponse govPayCardPaymentRequest = paymentStatusService
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class FeesPaymentServiceTest {
private static final CardPaymentServiceRequestDTO CARD_PAYMENT_SERVICE_REQUEST
= CardPaymentServiceRequestDTO.builder()
.returnUrl("${cui-front-end.url}/general-application/payment-confirmation/1701090368574910/gaid/2801090368574910")
.language("En")
.language("en")
.amount(new BigDecimal("232.00")).currency("GBP").build();

@Autowired
Expand Down Expand Up @@ -107,6 +107,7 @@ void shouldCreateGovPayPaymentUrlForServiceRequestPayment() {

CardPaymentStatusResponse govPaymentRequest = feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
);
assertThat(govPaymentRequest).isEqualTo(CardPaymentStatusResponse.from(response));
Expand All @@ -129,6 +130,7 @@ void shouldCreateGovPayPaymentUrlForServiceRequestAdditionalPayment() {

CardPaymentStatusResponse govPaymentRequest = feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
);
assertThat(govPaymentRequest).isEqualTo(CardPaymentStatusResponse.from(response));
Expand All @@ -148,6 +150,7 @@ void shouldNotCreateGovPayPaymentUrlForMissingPbaDetails() {
assertThatThrownBy(
() -> feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
)
).isInstanceOf(NullPointerException.class)
Expand All @@ -170,6 +173,7 @@ void shouldNotCreateGovPayPaymentUrlForMissingServiceRequest() {
assertThatThrownBy(
() -> feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
)
).isInstanceOf(NullPointerException.class)
Expand All @@ -190,6 +194,7 @@ void shouldRetryCreatePaymentsApiWhenInternalServerErrorThrown() {
PaymentsApiException.class,
() -> feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
)
);
Expand All @@ -213,6 +218,7 @@ void shouldNotRetryCreatePaymentsApiWhenExceptionOtherThanInternalServerIsThrown
PaymentsApiException.class,
() -> feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
)
);
Expand All @@ -239,13 +245,15 @@ void shouldFailOnCreatePaymentsApiTwiceThenHaveSuccessfulRetry() {
CardPaymentStatusResponse govPaymentRequest =
feesPaymentService.createGovPaymentRequest(
"2801090368574910",
"en",
BEARER_TOKEN
);

assertThat(govPaymentRequest).isEqualTo(CardPaymentStatusResponse.from(response));

verify(paymentsClient, times(3)).createGovPayCardPaymentRequest(
"2023-1701090705688",

BEARER_TOKEN,
CARD_PAYMENT_SERVICE_REQUEST
);
Expand Down