use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentSetup method tracePaymentSetup.
private FRPaymentSetup tracePaymentSetup(OBHeaders headers, OBPaymentSetup1 paymentSetupPOSTRequest, String paymentID) {
FRPaymentSetup paymentSetupEntity = new FRPaymentSetup();
paymentSetupEntity.setId(paymentID);
paymentSetupEntity.setPaymentSetupRequest(toFRWriteDomesticConsent(paymentSetupPOSTRequest));
// paymentSetupEntity = paymentSetupsService.createPaymentSetup(paymentSetupEntity);
return paymentSetupEntity;
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentSetup method create.
public OBPaymentSetupResponse1 create(OBHeaders headers, String tppId, OBPaymentSetup1 paymentSetupPOSTRequest) {
String paymentID = paymentId.create();
log.debug("FRPaymentConsent ID generated '{}'.", paymentID);
FRPaymentSetup payment = registerPendingPayment(tppId, paymentSetupPOSTRequest, paymentID);
FRPaymentSetup paymentSetupEntity = tracePaymentSetup(headers, paymentSetupPOSTRequest, paymentID);
updatePaymentToAcceptedTechnicalValidation(payment);
return updatePaymentSetup(paymentSetupPOSTRequest, payment, paymentSetupEntity);
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentsApiController method createSingleImmediatePayment.
@Override
public ResponseEntity createSingleImmediatePayment(@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 = "The PISP ID") @RequestHeader(value = "x-ob-client-id", required = false) String clientId, @ApiParam(value = "Setup a single immediate payment", required = true) @Valid @RequestBody OBPaymentSetup1 paymentSetupPOSTRequest, HttpServletRequest httpServletRequest) throws OBErrorResponseException {
log.debug("Received a POST payment setup request '{}'.", paymentSetupPOSTRequest);
final Tpp tpp = tppRepository.findByClientId(clientId);
log.debug("Got TPP '{}' for client Id '{}'", tpp, clientId);
Optional<FRPaymentSetup> consentByIdempotencyKey = frPaymentSetupRepository.findByIdempotencyKeyAndPispId(xIdempotencyKey, tpp.getId());
if (consentByIdempotencyKey.isPresent()) {
validateIdempotencyRequest(xIdempotencyKey, paymentSetupPOSTRequest, consentByIdempotencyKey.get(), () -> consentByIdempotencyKey.get().getPaymentSetupRequest());
log.info("Idempotent request is valid. Returning [201 CREATED] but take no further action.");
return ResponseEntity.status(HttpStatus.CREATED).body(packageIntoPaymentSetupResponse(consentByIdempotencyKey.get()));
}
log.debug("No consent with matching idempotency key has been found. Creating new consent.");
FRPaymentSetup frPaymentSetup = new FRPaymentSetup();
frPaymentSetup.setId(IntentType.PAYMENT_SINGLE_REQUEST.generateIntentId());
frPaymentSetup.setStatus(ConsentStatusCode.ACCEPTEDTECHNICALVALIDATION);
frPaymentSetup.setPaymentSetupRequest(toFRWriteDomesticConsent(paymentSetupPOSTRequest));
frPaymentSetup.setPisp(tpp);
frPaymentSetup.setIdempotencyKey(xIdempotencyKey);
frPaymentSetup.setObVersion(VersionPathExtractor.getVersionFromPath(httpServletRequest));
consentMetricService.sendConsentActivity(new ConsentStatusEntry(frPaymentSetup.getId(), frPaymentSetup.getStatus().name()));
frPaymentSetup = frPaymentSetupRepository.save(frPaymentSetup);
return ResponseEntity.status(HttpStatus.CREATED).body(packageIntoPaymentSetupResponse(frPaymentSetup));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class PaymentSubmissionsApiController method createPaymentSubmission.
@Override
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 = "The payment ID") @RequestHeader(value = "x-ob-payment-id", required = false) String paymentId, @ApiParam(value = "Setup a single immediate payment", required = true) @Valid @RequestBody OBPaymentSubmission1 paymentSubmission, HttpServletRequest httpServletRequest) throws OBErrorResponseException {
log.debug("Received payment submission: '{}'", paymentSubmission);
Optional<FRPaymentSetup> isPaymentSetup = frPaymentSetupRepository.findById(paymentId);
if (isPaymentSetup.isEmpty()) {
return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment setup behind payment submission '" + paymentId + "' can't be found");
}
// Trace the payment submission request
FRPaymentSubmission frPaymentSubmission = new FRPaymentSubmission();
frPaymentSubmission.setId(paymentId);
frPaymentSubmission.setPaymentSubmission(paymentSubmission);
frPaymentSubmission.setIdempotencyKey(xIdempotencyKey);
frPaymentSubmission.setObVersion(VersionPathExtractor.getVersionFromPath(httpServletRequest));
frPaymentSubmission = new IdempotentRepositoryAdapter<>(frPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
FRPaymentSetup frPaymentSetup = isPaymentSetup.get();
return ResponseEntity.status(HttpStatus.CREATED).body(packageToPaymentSubmission(frPaymentSubmission, frPaymentSetup));
}
use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup in project openbanking-aspsp by OpenBankingToolkit.
the class RCSConsentDecisionApiControllerIT method getConsentDetailsForSinglePayment.
@Test
public void getConsentDetailsForSinglePayment() throws Exception {
// Given
FRWriteDomesticConsentData writeDomesticConsentData = FRWriteDomesticConsentData.builder().initiation(FRWriteDomesticDataInitiation.builder().build()).build();
FRPaymentSetup payment = FRPaymentSetup.builder().pispId(PISP_ID).pispName(PISP_NAME).status(ConsentStatusCode.AWAITINGAUTHORISATION).paymentSetupRequest(FRWriteDomesticConsent.builder().data(writeDomesticConsentData).build()).build();
payment.getInitiation().setInstructedAmount(FRAmount.builder().build());
when(singlePaymentService.getPayment(any())).thenReturn(payment);
String signedJwtEncoded = toEncodedSignedTestJwt("jwt/singlePaymentConsentRequestPayload.json");
// When
HttpResponse<SinglePaymentConsentDetails> response = Unirest.post("https://rs-rcs:" + port + "/api/rcs/consent/details/").header(OBHeaders.CONTENT_TYPE, CONTENT_TYPE_JWT).header("Cookie", MOCK_COOKIE).body(signedJwtEncoded).asObject(SinglePaymentConsentDetails.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
SinglePaymentConsentDetails resp = response.getBody();
assertThat(resp.getClientId()).isEqualTo(PISP_ID);
assertThat(resp.getPispName()).isEqualTo(PISP_NAME);
assertThat(resp.getUsername()).isEqualTo(USER_ID);
assertThat(resp.getIntentType()).isEqualTo(IntentType.PAYMENT_SINGLE_REQUEST);
assertThat(resp.getDecisionAPIUri()).isEqualTo(EXPECTED_DECISION_API_URI);
}
Aggregations