use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequest in project openbanking-aspsp by OpenBankingToolkit.
the class FRDomesticVRPConvertersTest method success_toFRDomesticVRPRequest.
@Test
public void success_toFRDomesticVRPRequest() {
// Given
OBDomesticVRPRequest obDomesticVRPPaymentRequest = getOBDomesticVRPRequest();
// When
FRDomesticVRPRequest frDomesticVRPRequest = FRDomesticVRPConverters.toFRDomesticVRPRequest(obDomesticVRPPaymentRequest);
// Then
assertThat(frDomesticVRPRequest).isNotNull();
assertThat(frDomesticVRPRequest.getData()).isNotNull();
FRDomesticVRPRequestData frRequestData = frDomesticVRPRequest.getData();
OBDomesticVRPRequestData obRequestData = obDomesticVRPPaymentRequest.getData();
assertThat(frRequestData.getConsentId()).isNotNull();
assertThat(frRequestData.getConsentId()).isEqualTo(obRequestData.getConsentId());
assertThat(frRequestData.getPsuAuthenticationMethod()).isNotNull();
assertThat(frRequestData.getPsuAuthenticationMethod()).isEqualTo(obRequestData.getPsUAuthenticationMethod());
assertThat(frRequestData.getInitiation()).isNotNull();
assertThat(frRequestData.getInstruction()).isNotNull();
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequest in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticVrpsApiController method domesticVrpPost.
@Override
public /**
* @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true)
* @RequestHeader(value = "Authorization", required = true) String authorization,
*
* @ApiParam(value = "A detached JWS signature of the body of the payload.", required = true)
* @RequestHeader(value = "x-jws-signature", required = true) String xJwsSignature,
*
* @ApiParam(value = "Default", required = true)
* @Valid
* @RequestBody OBDomesticVRPRequest obDomesticVRPRequest,
*
* @ApiParam(value = "The time when the PSU last logged in with the TPP. All dates in the HTTP headers are represented as RFC 7231 Full Dates. An example is below: Sun, 10 Sep 2017 19:43:31 UTC")
* @RequestHeader(value = "x-fapi-auth-date", required = false) String xFapiAuthDate,
*
* @ApiParam(value = "The PSU's IP address if the PSU is currently logged in with the TPP.")
* @RequestHeader(value = "x-fapi-customer-ip-address", required = false) String xFapiCustomerIpAddress,
*
* @ApiParam(value = "An RFC4122 UID used as a correlation id.")
* @RequestHeader(value = "x-fapi-interaction-id", required = false) String xFapiInteractionId,
*
* @ApiParam(value = "Indicates the user-agent that the PSU is using.")
* @RequestHeader(value = "x-customer-user-agent", required = false) String xCustomerUserAgent,
*/
ResponseEntity<OBDomesticVRPResponse> domesticVrpPost(String authorization, String xJwsSignature, OBDomesticVRPRequest obDomesticVRPRequest, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
log.debug("Received VRP payment submission: '{}'", obDomesticVRPRequest);
String consentId = obDomesticVRPRequest.getData().getConsentId();
FRDomesticVRPConsent frDomesticVRPConsent = domesticVRPConsentRepository.findById(consentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(consentId)));
log.debug("Found VRP consent '{}' to match this consent id: {} ", frDomesticVRPConsent, consentId);
FRDomesticVRPRequest frDomesticVRPRequest = toFRDomesticVRPRequest(obDomesticVRPRequest);
FRDomesticVrpPaymentSubmission vrpPaymentSubmission = FRDomesticVrpPaymentSubmission.builder().id(consentId).domesticVrpPayment(frDomesticVRPRequest).status(OBDomesticVRPResponseData.StatusEnum.PENDING).created(new Date()).updated(new Date()).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
vrpPaymentSubmission = new IdempotentRepositoryAdapter<>(paymentSubmissionRepository).idempotentSave(vrpPaymentSubmission);
return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(obDomesticVRPRequest, vrpPaymentSubmission, frDomesticVRPConsent));
}
Aggregations