Search in sources :

Example 6 with IdempotentRepositoryAdapter

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

the class DomesticScheduledPaymentsApiController method createDomesticScheduledPayments.

public ResponseEntity<OBWriteDomesticScheduledResponse3> createDomesticScheduledPayments(OBWriteDomesticScheduled2 obWriteDomesticScheduled2, 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: '{}'", obWriteDomesticScheduled2);
    FRWriteDomesticScheduled frWriteDomesticScheduled = toFRWriteDomesticScheduled(obWriteDomesticScheduled2);
    log.trace("Converted to: '{}'", frWriteDomesticScheduled);
    String paymentId = obWriteDomesticScheduled2.getData().getConsentId();
    FRDomesticScheduledConsent paymentConsent = domesticScheduledConsentRepository.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);
    // Save Payment
    FRDomesticScheduledPaymentSubmission frPaymentSubmission = FRDomesticScheduledPaymentSubmission.builder().id(paymentId).domesticScheduledPayment(frWriteDomesticScheduled).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticScheduledPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticScheduledConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent) FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticScheduledConverter.toFRWriteDomesticScheduled) FRWriteDomesticScheduled(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticScheduled) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticScheduledPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledPaymentSubmission) Date(java.util.Date)

Example 7 with IdempotentRepositoryAdapter

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

the class DomesticStandingOrdersApiController method createDomesticStandingOrders.

public ResponseEntity<OBWriteDomesticStandingOrderResponse4> createDomesticStandingOrders(OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, 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: '{}'", obWriteDomesticStandingOrder3);
    String paymentId = obWriteDomesticStandingOrder3.getData().getConsentId();
    FRDomesticStandingOrderConsent paymentConsent = domesticStandingOrderConsentRepository.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);
    FRDomesticStandingOrderPaymentSubmission frPaymentSubmission = FRDomesticStandingOrderPaymentSubmission.builder().id(paymentId).domesticStandingOrder(toFRWriteDomesticStandingOrder(obWriteDomesticStandingOrder3)).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticStandingOrderPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRDomesticStandingOrderPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderPaymentSubmission) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) Date(java.util.Date)

Example 8 with IdempotentRepositoryAdapter

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

the class DomesticStandingOrdersApiController method createDomesticStandingOrders.

public ResponseEntity<OBWriteDomesticStandingOrderResponse6> createDomesticStandingOrders(OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, 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: '{}'", obWriteDomesticStandingOrder3);
    FRWriteDomesticStandingOrder frWriteDomesticStandingOrder = toFRWriteDomesticStandingOrder(obWriteDomesticStandingOrder3);
    log.trace("Converted to: '{}'", frWriteDomesticStandingOrder);
    String paymentId = obWriteDomesticStandingOrder3.getData().getConsentId();
    FRDomesticStandingOrderConsent paymentConsent = domesticStandingOrderConsentRepository.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);
    FRDomesticStandingOrderPaymentSubmission frPaymentSubmission = FRDomesticStandingOrderPaymentSubmission.builder().id(paymentId).domesticStandingOrder(frWriteDomesticStandingOrder).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(domesticStandingOrderPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRWriteDomesticStandingOrderConverter.toFRWriteDomesticStandingOrder(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteDomesticStandingOrderConverter.toFRWriteDomesticStandingOrder) FRWriteDomesticStandingOrder(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteDomesticStandingOrder) FRDomesticStandingOrderPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderPaymentSubmission) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRDomesticStandingOrderConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticStandingOrderConsent) Date(java.util.Date)

Example 9 with IdempotentRepositoryAdapter

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

the class InternationalPaymentsApiController method createInternationalPayments.

public ResponseEntity<OBWriteInternationalResponse5> createInternationalPayments(OBWriteInternational3 obWriteInternational3, 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: '{}'", obWriteInternational3);
    FRWriteInternational frWriteInternational = toFRWriteInternational(obWriteInternational3);
    log.trace("Converted to: '{}'", frWriteInternational);
    String paymentId = obWriteInternational3.getData().getConsentId();
    FRInternationalConsent paymentConsent = internationalConsentRepository.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);
    FRInternationalPaymentSubmission frPaymentSubmission = FRInternationalPaymentSubmission.builder().id(paymentId).internationalPayment(frWriteInternational).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRWriteInternational(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational) FRWriteInternationalConverter.toFRWriteInternational(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteInternationalConverter.toFRWriteInternational) FRInternationalConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalConsent) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRInternationalPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRInternationalPaymentSubmission) Date(java.util.Date)

Example 10 with IdempotentRepositoryAdapter

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

the class FilePaymentsApiController method createFilePayments.

@Override
public ResponseEntity createFilePayments(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteFile2 obWriteFile2, @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: '{}'", obWriteFile2);
    FRWriteFile frWriteFile = toFRWriteFile(obWriteFile2);
    log.trace("Converted to: '{}'", frWriteFile);
    String paymentId = obWriteFile2.getData().getConsentId();
    FRFileConsent paymentConsent = fileConsentRepository.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);
    FRFilePaymentSubmission frPaymentSubmission = FRFilePaymentSubmission.builder().id(paymentId).filePayment(frWriteFile).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
    frPaymentSubmission = new IdempotentRepositoryAdapter<>(filePaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
    return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRFileConsent(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFileConsent) FRWriteFile(com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteFile) FRWriteFileConverter.toFRWriteFile(com.forgerock.openbanking.common.services.openbanking.converter.payment.FRWriteFileConverter.toFRWriteFile) OBErrorResponseException(com.forgerock.openbanking.exceptions.OBErrorResponseException) FRFilePaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRFilePaymentSubmission) 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