Search in sources :

Example 1 with FRDomesticVRPRequest

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();
}
Also used : OBDomesticVRPRequest(uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequest) FRDomesticVRPRequest(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequest) FRDomesticVRPRequestData(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequestData) OBDomesticVRPRequestData(uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequestData) Test(org.junit.Test)

Example 2 with FRDomesticVRPRequest

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));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticVrpPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVrpPaymentSubmission) FRDomesticVRPRequest(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequest) FRDomesticVRPConverters.toFRDomesticVRPRequest(com.forgerock.openbanking.common.services.openbanking.converter.vrp.FRDomesticVRPConverters.toFRDomesticVRPRequest) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticVRPConsent(com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent) Date(java.util.Date)

Aggregations

FRDomesticVRPRequest (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequest)2 IdempotentRepositoryAdapter (com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter)1 FRDomesticVRPConsent (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPConsent)1 FRDomesticVRPRequestData (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVRPRequestData)1 FRDomesticVrpPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.vrp.FRDomesticVrpPaymentSubmission)1 FRDomesticVRPConverters.toFRDomesticVRPRequest (com.forgerock.openbanking.common.services.openbanking.converter.vrp.FRDomesticVRPConverters.toFRDomesticVRPRequest)1 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)1 Date (java.util.Date)1 Test (org.junit.Test)1 OBDomesticVRPRequest (uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequest)1 OBDomesticVRPRequestData (uk.org.openbanking.datamodel.vrp.OBDomesticVRPRequestData)1