use of com.forgerock.openbanking.exceptions.OBErrorResponseException in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentConsentsApiController method createFilePaymentConsents.
public ResponseEntity<OBWriteFileConsentResponse3> createFilePaymentConsents(OBWriteFileConsent3 obWriteFileConsent3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
return rsEndpointWrapperService.paymentEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyJwsDetachedSignature(xJwsSignature, request);
}).execute((String tppId) -> {
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-client-id", tppId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteFileConsentResponse3.class, obWriteFileConsent3);
});
}
use of com.forgerock.openbanking.exceptions.OBErrorResponseException in project openbanking-aspsp by OpenBankingToolkit.
the class FilePaymentsApiController method createFilePayments.
public ResponseEntity<OBWriteFileResponse2> createFilePayments(OBWriteFile2 obWriteFile2, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
String consentId = obWriteFile2.getData().getConsentId();
FRFileConsent payment = paymentsService.getPayment(consentId);
return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).payment(payment).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
f.verifyPaymentIdWithAccessToken();
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyPaymentStatus();
f.verifyInitiation(toFRWriteFileDataInitiation(obWriteFile2.getData().getInitiation()));
f.verifyJwsDetachedSignature(xJwsSignature, request);
}).execute((String tppId) -> {
// Modify the status of the payment
log.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTINPROCESS);
log.info("Updating payment");
paymentsService.updatePayment(payment);
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-payment-id", consentId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteFileResponse2.class, obWriteFile2);
});
}
use of com.forgerock.openbanking.exceptions.OBErrorResponseException in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticScheduledPaymentConsentsApiController method createDomesticScheduledPaymentConsents.
@Override
public ResponseEntity<OBWriteDomesticScheduledConsentResponse4> createDomesticScheduledPaymentConsents(OBWriteDomesticScheduledConsent4 obWriteDomesticScheduledConsent4, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
return rsEndpointWrapperService.paymentEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyJwsDetachedSignature(xJwsSignature, request);
f.validateRisk(obWriteDomesticScheduledConsent4.getRisk());
}).execute((String tppId) -> {
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-client-id", tppId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticScheduledConsentResponse4.class, obWriteDomesticScheduledConsent4);
});
}
use of com.forgerock.openbanking.exceptions.OBErrorResponseException in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrderConsentsApiController method createDomesticStandingOrderConsents.
@Override
public ResponseEntity<OBWriteDomesticStandingOrderConsentResponse5> createDomesticStandingOrderConsents(OBWriteDomesticStandingOrderConsent5 obWriteDomesticStandingOrderConsent5, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
return rsEndpointWrapperService.paymentEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyJwsDetachedSignature(xJwsSignature, request);
f.validateRisk(obWriteDomesticStandingOrderConsent5.getRisk());
}).execute((String tppId) -> {
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-client-id", tppId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderConsentResponse5.class, obWriteDomesticStandingOrderConsent5);
});
}
use of com.forgerock.openbanking.exceptions.OBErrorResponseException in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrdersApiController method createDomesticStandingOrders.
@Override
public ResponseEntity<OBWriteDomesticStandingOrderResponse5> createDomesticStandingOrders(OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, String authorization, String xIdempotencyKey, String xJwsSignature, DateTime xFapiAuthDate, String xFapiCustomerIpAddress, String xFapiInteractionId, String xCustomerUserAgent, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
String consentId = obWriteDomesticStandingOrder3.getData().getConsentId();
FRDomesticStandingOrderConsent payment = paymentsService.getPayment(consentId);
return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(rsEndpointWrapperService.rsConfiguration.financialId).payment(payment).principal(principal).obVersion(getOBVersion(request.getRequestURI())).filters(f -> {
f.verifyPaymentIdWithAccessToken();
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyPaymentStatus();
f.verifyRiskAndInitiation(toFRWriteDomesticStandingOrderDataInitiation(obWriteDomesticStandingOrder3.getData().getInitiation()), toFRRisk(obWriteDomesticStandingOrder3.getRisk()));
f.verifyJwsDetachedSignature(xJwsSignature, request);
}).execute((String tppId) -> {
// Modify the status of the payment
log.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
FRWriteDomesticStandingOrderDataInitiation initiation = payment.getInitiation();
DateTime firstPaymentDateTime = initiation.getFirstPaymentDateTime();
FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(initiation.getCreditorAccount()).frequency(initiation.getFrequency()).reference(initiation.getReference()).firstPaymentDateTime(initiation.getFirstPaymentDateTime()).firstPaymentAmount(initiation.getFirstPaymentAmount()).nextPaymentAmount(initiation.getRecurringPaymentAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(initiation.getFirstPaymentDateTime(), initiation.getFrequency())).finalPaymentDateTime(initiation.getFinalPaymentDateTime()).finalPaymentAmount(initiation.getFinalPaymentAmount()).standingOrderId(payment.getId()).build();
String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
standingOrderService.createStandingOrder(standingOrder, pispId);
log.info("Updating standing order '{}'", payment.getId());
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
paymentsService.updatePayment(payment);
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-payment-id", consentId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderResponse5.class, obWriteDomesticStandingOrder3);
});
}
Aggregations