Search in sources :

Example 1 with FRPaymentSubmission

use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSubmission 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));
}
Also used : IdempotentRepositoryAdapter(com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter) FRPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSubmission) FRPaymentSetup(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup)

Example 2 with FRPaymentSubmission

use of com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSubmission in project openbanking-aspsp by OpenBankingToolkit.

the class PaymentSubmissionsApiController method getPaymentSubmission.

@Override
public ResponseEntity getPaymentSubmission(@ApiParam(value = "Unique identification as assigned by the ASPSP to uniquely identify " + "the payment submission resource.", required = true) @PathVariable("PaymentSubmissionId") String paymentSubmissionId, @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 = "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) throws OBErrorResponseException {
    Optional<FRPaymentSubmission> isPaymentSubmission = frPaymentSubmissionRepository.findById(paymentSubmissionId);
    if (isPaymentSubmission.isEmpty()) {
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment submission '" + paymentSubmissionId + "' can't be found");
    }
    FRPaymentSubmission frPaymentSubmission = isPaymentSubmission.get();
    Optional<FRPaymentSetup> isPaymentSetup = frPaymentSetupRepository.findById(paymentSubmissionId);
    if (isPaymentSetup.isEmpty()) {
        return ResponseEntity.status(HttpStatus.BAD_REQUEST).body("Payment setup behind payment submission '" + paymentSubmissionId + "' can't be found");
    }
    FRPaymentSetup frPaymentSetup = isPaymentSetup.get();
    return ResponseEntity.ok(packageToPaymentSubmission(frPaymentSubmission, frPaymentSetup));
}
Also used : FRPaymentSubmission(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSubmission) FRPaymentSetup(com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup)

Aggregations

FRPaymentSetup (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSetup)2 FRPaymentSubmission (com.forgerock.openbanking.common.model.openbanking.persistence.payment.FRPaymentSubmission)2 IdempotentRepositoryAdapter (com.forgerock.openbanking.aspsp.rs.store.repository.IdempotentRepositoryAdapter)1