Skip to content

Commit

Permalink
CIV-9939 Payment details (#3818)
Browse files Browse the repository at this point in the history
* CIV-9939 Payment details

* CIV-9939 Payment details

* CIV-9939 Payment details

---------

Co-authored-by: Raja Mani <[email protected]>
  • Loading branch information
ElifDenizEsea and rajakm authored Jan 19, 2024
1 parent 828e156 commit 8ef056b
Showing 1 changed file with 16 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

import com.fasterxml.jackson.databind.ObjectMapper;
import feign.FeignException;

import java.util.Collections;

import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
Expand All @@ -13,6 +15,8 @@
import uk.gov.hmcts.reform.civil.callback.CallbackParams;
import uk.gov.hmcts.reform.civil.callback.CaseEvent;
import uk.gov.hmcts.reform.civil.model.CaseData;
import uk.gov.hmcts.reform.civil.model.Fee;
import uk.gov.hmcts.reform.civil.model.SRPbaDetails;
import uk.gov.hmcts.reform.civil.service.PaymentsService;

import java.util.ArrayList;
Expand Down Expand Up @@ -62,11 +66,14 @@ private CallbackResponse makePaymentServiceReq(CallbackParams callbackParams) {
if (isServiceRequestNotRequested(caseData) && !caseData.isHelpWithFees()) {
log.info("Calling payment service request (claim fee) for case {}", caseData.getCcdCaseReference());
String serviceRequestReference = getServiceRequestReference(caseData, authToken);
caseData = caseData.toBuilder().serviceRequestReference(serviceRequestReference).build();
caseData = caseData.toBuilder().serviceRequestReference(serviceRequestReference)
.claimIssuedPBADetails(getClaimIssuePbaDetails(serviceRequestReference, caseData.getClaimFee()))
.build();
}
} catch (FeignException e) {
log.error("Failed creating a payment service request for case {}. Http status: {}. Exception: {}",
caseData.getCcdCaseReference(), e.status(), e);
caseData.getCcdCaseReference(), e.status(), e
);
errors.add(ERROR_MESSAGE);
}
return AboutToStartOrSubmitCallbackResponse.builder()
Expand All @@ -83,4 +90,11 @@ private String getServiceRequestReference(CaseData caseData, String authToken) {
private boolean isServiceRequestNotRequested(CaseData caseData) {
return isNull(caseData.getServiceRequestReference());
}

private SRPbaDetails getClaimIssuePbaDetails(String serviceReference, Fee claimFee) {
return SRPbaDetails.builder()
.serviceReqReference(serviceReference)
.fee(claimFee)
.build();
}
}

0 comments on commit 8ef056b

Please sign in to comment.