use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalStandingOrdersApiController method createInternationalStandingOrders.
@Override
public ResponseEntity<OBWriteInternationalStandingOrderResponse1> createInternationalStandingOrders(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteInternationalStandingOrder1 obWriteInternationalStandingOrder1, @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 {
String consentId = obWriteInternationalStandingOrder1.getData().getConsentId();
FRInternationalStandingOrderConsent payment = paymentsService.getPayment(consentId);
return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).payment(payment).principal(principal).filters(f -> {
f.verifyPaymentIdWithAccessToken();
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyPaymentStatus();
f.verifyRiskAndInitiation(toFRWriteInternationalStandingOrderDataInitiation(obWriteInternationalStandingOrder1.getData().getInitiation()), toFRRisk(obWriteInternationalStandingOrder1.getRisk()));
f.verifyJwsDetachedSignature(xJwsSignature, request);
}).execute((String tppId) -> {
// Modify the status of the payment
LOGGER.info("Switch status of payment {} to 'accepted settlement in process'.", consentId);
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTCOMPLETED);
LOGGER.info("Updating payment");
paymentsService.updatePayment(payment);
FRWriteInternationalStandingOrderDataInitiation paymentInitiation = payment.getInitiation();
FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(paymentInitiation.getCreditorAccount()).frequency(paymentInitiation.getFrequency()).reference(paymentInitiation.getReference()).firstPaymentDateTime(paymentInitiation.getFirstPaymentDateTime()).firstPaymentAmount(paymentInitiation.getInstructedAmount()).nextPaymentAmount(paymentInitiation.getInstructedAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(paymentInitiation.getFirstPaymentDateTime(), paymentInitiation.getFrequency())).finalPaymentDateTime(paymentInitiation.getFinalPaymentDateTime()).finalPaymentAmount(paymentInitiation.getInstructedAmount()).standingOrderId(payment.getId()).build();
String pispId = tppStoreService.findByClientId(tppId).map(tpp -> tpp.getId()).orElse(null);
standingOrderService.createStandingOrder(standingOrder, pispId);
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-payment-id", consentId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteInternationalStandingOrderResponse1.class, obWriteInternationalStandingOrder1);
});
}
use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrdersApiController method createDomesticStandingOrders.
@Override
public ResponseEntity<OBWriteDomesticStandingOrderResponse1> createDomesticStandingOrders(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticStandingOrder1 obWriteDomesticStandingOrder1, @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 {
String consentId = obWriteDomesticStandingOrder1.getData().getConsentId();
FRDomesticStandingOrderConsent payment = paymentsService.getPayment(consentId);
return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).payment(payment).principal(principal).filters(f -> {
f.verifyPaymentIdWithAccessToken();
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyPaymentStatus();
f.verifyRiskAndInitiation(toFRWriteDomesticStandingOrderDataInitiation(obWriteDomesticStandingOrder1.getData().getInitiation()), toFRRisk(obWriteDomesticStandingOrder1.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 paymentInitiation = payment.getInitiation();
DateTime firstPaymentDateTime = paymentInitiation.getFirstPaymentDateTime();
FRStandingOrderData standingOrder = FRStandingOrderData.builder().accountId(payment.getAccountId()).standingOrderStatusCode(FRStandingOrderData.FRStandingOrderStatus.ACTIVE).creditorAccount(paymentInitiation.getCreditorAccount()).frequency(paymentInitiation.getFrequency()).reference(paymentInitiation.getReference()).firstPaymentDateTime(firstPaymentDateTime).firstPaymentAmount(paymentInitiation.getFirstPaymentAmount()).nextPaymentAmount(paymentInitiation.getRecurringPaymentAmount()).nextPaymentDateTime(frequencyService.getNextDateTime(firstPaymentDateTime, paymentInitiation.getFrequency())).finalPaymentDateTime(paymentInitiation.getFinalPaymentDateTime()).finalPaymentAmount(paymentInitiation.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);
ParameterizedTypeReference<OBWriteDomesticStandingOrderResponse1> ptr = new ParameterizedTypeReference<OBWriteDomesticStandingOrderResponse1>() {
};
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderResponse1.class, obWriteDomesticStandingOrder1);
});
}
use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrdersApiController method createDomesticStandingOrders.
@Override
public ResponseEntity<OBWriteDomesticStandingOrderResponse3> createDomesticStandingOrders(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticStandingOrder3 obWriteDomesticStandingOrder3, @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 {
String consentId = obWriteDomesticStandingOrder3.getData().getConsentId();
FRDomesticStandingOrderConsent payment = paymentsService.getPayment(consentId);
return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).payment(payment).principal(principal).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.findPispIdByTppId(tppId);
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(), OBWriteDomesticStandingOrderResponse3.class, obWriteDomesticStandingOrder3);
});
}
use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticStandingOrderConsentsApiController method createDomesticStandingOrderConsents.
@Override
public ResponseEntity<OBWriteDomesticStandingOrderConsentResponse3> createDomesticStandingOrderConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticStandingOrderConsent3 OBWriteDomesticStandingOrderConsent3Param, @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 {
return rsEndpointWrapperService.paymentEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).principal(principal).filters(f -> {
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyJwsDetachedSignature(xJwsSignature, request);
f.validateRisk(OBWriteDomesticStandingOrderConsent3Param.getRisk());
}).execute((String tppId) -> {
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-client-id", tppId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticStandingOrderConsentResponse3.class, OBWriteDomesticStandingOrderConsent3Param);
});
}
use of com.forgerock.openbanking.constants.OpenBankingConstants.HTTP_DATE_FORMAT in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentSubmissionsApiController method createPaymentSubmission.
public ResponseEntity createPaymentSubmission(@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 = "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 = "Header containing a detached JWS signature of the body of the payload.", required = true) @RequestHeader(value = "x-jws-signature", required = false) 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 = "Setup a single immediate payment", required = true) @Valid @RequestBody OBPaymentSubmission1 paymentSubmission, HttpServletRequest request, Principal principal) throws OBErrorResponseException {
String paymentId = paymentSubmission.getData().getPaymentId();
FRPaymentSetup payment = paymentsService.getPayment(paymentId);
return rsEndpointWrapperService.paymentSubmissionEndpoint().authorization(authorization).xFapiFinancialId(xFapiFinancialId).payment(payment).principal(principal).filters(f -> {
f.verifyPaymentIdWithAccessToken();
f.verifyIdempotencyKeyLength(xIdempotencyKey);
f.verifyPaymentStatus();
f.verifyRiskAndInitiation(toFRWriteDomesticDataInitiation(paymentSubmission.getData().getInitiation()), toFRRisk(paymentSubmission.getRisk()));
f.verifyJwsDetachedSignature(xJwsSignature, request);
}).execute((String tppId) -> {
// Modify the status of the payment
LOGGER.info("Switch status of payment {} to 'accepted settlement in process'.", paymentId);
payment.setStatus(ConsentStatusCode.ACCEPTEDSETTLEMENTINPROCESS);
LOGGER.info("Updating payment");
paymentsService.updatePayment(payment);
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-payment-id", paymentId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBPaymentSubmissionResponse1.class, paymentSubmission);
});
}
Aggregations