use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticScheduledPaymentConsentsApiController method getDomesticScheduledPaymentConsentsConsentId.
public ResponseEntity getDomesticScheduledPaymentConsentsConsentId(String consentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRDomesticScheduledConsent> isDomesticScheduledConsent = domesticScheduledConsentRepository.findById(consentId);
if (!isDomesticScheduledConsent.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Domestic scheduled consent '" + consentId + "' can't be found");
}
FRDomesticScheduledConsent domesticScheduledConsent = isDomesticScheduledConsent.get();
return ResponseEntity.ok(responseEntity(domesticScheduledConsent));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticScheduledPaymentsApiController method createDomesticScheduledPayments.
public ResponseEntity<OBWriteDomesticScheduledResponse5> 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));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticScheduledPaymentsApiController method getDomesticScheduledPaymentsDomesticScheduledPaymentId.
public ResponseEntity getDomesticScheduledPaymentsDomesticScheduledPaymentId(String domesticScheduledPaymentId, String authorization, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRDomesticScheduledPaymentSubmission> isPaymentSubmission = domesticScheduledPaymentSubmissionRepository.findById(domesticScheduledPaymentId);
if (!isPaymentSubmission.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment submission '" + domesticScheduledPaymentId + "' can't be found");
}
FRDomesticScheduledPaymentSubmission frPaymentSubmission = isPaymentSubmission.get();
Optional<FRDomesticScheduledConsent> isPaymentSetup = domesticScheduledConsentRepository.findById(domesticScheduledPaymentId);
if (!isPaymentSetup.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment setup behind payment submission '" + domesticScheduledPaymentId + "' can't be found");
}
FRDomesticScheduledConsent frPaymentSetup = isPaymentSetup.get();
return ResponseEntity.ok(responseEntity(frPaymentSubmission, frPaymentSetup));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent 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));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRDomesticScheduledConsent in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticScheduledPaymentsApiController method getDomesticScheduledPaymentsDomesticScheduledPaymentId.
@Override
public ResponseEntity getDomesticScheduledPaymentsDomesticScheduledPaymentId(String domesticScheduledPaymentId, String authorization, String xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
Optional<FRDomesticScheduledPaymentSubmission> isPaymentSubmission = domesticScheduledPaymentSubmissionRepository.findById(domesticScheduledPaymentId);
if (!isPaymentSubmission.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment submission '" + domesticScheduledPaymentId + "' can't be found");
}
FRDomesticScheduledPaymentSubmission frPaymentSubmission = isPaymentSubmission.get();
Optional<FRDomesticScheduledConsent> isPaymentSetup = domesticScheduledConsentRepository.findById(domesticScheduledPaymentId);
if (!isPaymentSetup.isPresent()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment setup behind payment submission '" + domesticScheduledPaymentId + "' can't be found");
}
FRDomesticScheduledConsent frPaymentSetup = isPaymentSetup.get();
return ResponseEntity.ok(responseEntity(frPaymentSubmission, frPaymentSetup));
}
Aggregations