Search in sources :

Example 26 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalScheduledPaymentsApiController method createInternationalScheduledPayments.

@Override
public ResponseEntity createInternationalScheduledPayments(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalScheduled2 obWriteInternationalScheduled2, @ApiParam(value = "The unique id of the ASPSP to which the request is issued. The unique id will be issued by OB.", required = true) @RequestHeader(value = "x-fapi-financial-id", required = true) String xFapiFinancialId, @ApiParam(value = "An Authorisation Token as per https://tools.ietf.org/html/rfc6750", required = true) @RequestHeader(value = "Authorization", required = true) String authorization, @ApiParam(value = "Every request will be processed only once per x-idempotency-key.  The Idempotency Key will be valid for 24 hours.", required = true) @RequestHeader(value = "x-idempotency-key", required = true) String xIdempotencyKey, @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 = "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-customer-last-logged-time", required = false) @DateTimeFormat(pattern = HTTP_DATE_FORMAT) DateTime xFapiCustomerLastLoggedTime, @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, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteInternationalScheduled2);
    FRWriteInternationalScheduled frInternationalScheduled = toFRWriteInternationalScheduled(obWriteInternationalScheduled2);
    log.trace("Converted to: '{}'", frInternationalScheduled);
    String paymentId = obWriteInternationalScheduled2.getData().getConsentId();
    FRInternationalScheduledConsent paymentConsent = internationalScheduledConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRInternationalScheduledPaymentSubmission frPaymentSubmission = FRInternationalScheduledPaymentSubmission.builder().id(paymentId).internationalScheduledPayment(frInternationalScheduled).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : FRWriteInternationalScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduled) FRWriteInternationalScheduledConverter.toFRWriteInternationalScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConverter.toFRWriteInternationalScheduled) FRInternationalScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledPaymentSubmission) IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) Date(java.util.Date)

Example 27 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class DomesticPaymentsApiController method createDomesticPayments.

public ResponseEntity<OBWriteDomesticResponse3> createDomesticPayments(OBWriteDomestic2 obWriteDomestic2, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteDomestic2);
    FRWriteDomestic frWriteDomestic = toFRWriteDomestic(obWriteDomestic2);
    log.trace("Converted to: '{}'", frWriteDomestic);
    String paymentId = obWriteDomestic2.getData().getConsentId();
    FRDomesticConsent paymentConsent = domesticConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRDomesticPaymentSubmission frPaymentSubmission = FRDomesticPaymentSubmission.builder().id(obWriteDomestic2.getData().getConsentId()).domesticPayment(frWriteDomestic).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent) FRDomesticPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRWriteDomestic(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomestic) FRWriteDomesticConverter.toFRWriteDomestic(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticConverter.toFRWriteDomestic) Date(java.util.Date)

Example 28 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalScheduledPaymentsApiController method createInternationalScheduledPayments.

public ResponseEntity<OBWriteInternationalScheduledResponse6> createInternationalScheduledPayments(OBWriteInternationalScheduled3 obWriteInternationalScheduled3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteInternationalScheduled3);
    FRWriteInternationalScheduled frInternationalScheduled = toFRWriteInternationalScheduled(obWriteInternationalScheduled3);
    log.trace("Converted to: '{}'", frInternationalScheduled);
    String paymentId = obWriteInternationalScheduled3.getData().getConsentId();
    FRInternationalScheduledConsent paymentConsent = internationalScheduledConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRInternationalScheduledPaymentSubmission frPaymentSubmission = FRInternationalScheduledPaymentSubmission.builder().id(paymentId).internationalScheduledPayment(frInternationalScheduled).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : FRWriteInternationalScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduled) FRWriteInternationalScheduledConverter.toFRWriteInternationalScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalScheduledConverter.toFRWriteInternationalScheduled) FRInternationalScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledPaymentSubmission) IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRInternationalScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalScheduledConsent) Date(java.util.Date)

Example 29 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter in project openbanking-aspsp by OpenBankingToolkit.

the class InternationalStandingOrdersApiController method createInternationalStandingOrders.

public ResponseEntity<OBWriteInternationalStandingOrderResponse7> createInternationalStandingOrders(OBWriteInternationalStandingOrder4 obWriteInternationalStandingOrder4, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
    log.debug("Received payment submission: '{}'", obWriteInternationalStandingOrder4);
    FRWriteInternationalStandingOrder frInternationalStandingOrder = toFRWriteInternationalStandingOrder(obWriteInternationalStandingOrder4);
    log.trace("Converted to: '{}'", frInternationalStandingOrder);
    String paymentId = obWriteInternationalStandingOrder4.getData().getConsentId();
    FRInternationalStandingOrderConsent paymentConsent = internationalStandingOrderConsentRepository.findById(paymentId).orElseThrow(() -> new OBErrorResponseException(HttpStatus.BAD_REQUEST, OBRIErrorResponseCategory.REQUEST_INVALID, OBRIErrorType.PAYMENT_CONSENT_BEHIND_SUBMISSION_NOT_FOUND.toOBError1(paymentId)));
    log.debug("Found consent '{}' to match this payment id: {} ", paymentConsent, paymentId);
    FRInternationalStandingOrderPaymentSubmission frPaymentSubmission = FRInternationalStandingOrderPaymentSubmission.builder().id(paymentId).internationalStandingOrder(frInternationalStandingOrder).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).version(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalStandingOrderPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : FRInternationalStandingOrderPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderPaymentSubmission) IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRInternationalStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRWriteInternationalStandingOrder(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrder) FRWriteInternationalStandingOrderConverter.toFRWriteInternationalStandingOrder(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalStandingOrderConverter.toFRWriteInternationalStandingOrder) Date(java.util.Date)

Example 30 with IdempotentRepositoryAdapter

use of com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter 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

IdempotentRepositoryAdapter (com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter)38 OBErrorResponseException (com.forgerock.openbanking.exceptions.OBErrorResponseException)37 Date (java.util.Date)37 FRWriteInternationalStandingOrder (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalStandingOrder)6 FRDomesticStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent)6 FRDomesticStandingOrderPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderPaymentSubmission)6 FRInternationalStandingOrderConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderConsent)6 FRInternationalStandingOrderPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalStandingOrderPaymentSubmission)6 FRWriteInternationalStandingOrderConverter.toFRWriteInternationalStandingOrder (com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalStandingOrderConverter.toFRWriteInternationalStandingOrder)6 FRWriteDomestic (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomestic)5 FRWriteDomesticScheduled (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled)5 FRWriteDomesticStandingOrder (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrder)5 FRWriteInternational (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational)5 FRWriteInternationalScheduled (com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternationalScheduled)5 FRDomesticConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticConsent)5 FRDomesticPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticPaymentSubmission)5 FRDomesticScheduledConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent)5 FRDomesticScheduledPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission)5 FRInternationalConsent (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent)5 FRInternationalPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalPaymentSubmission)5