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));
}
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));
}
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));
}
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));
}
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));
}
Aggregations