use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentsApiControllerIT method testGetMissingInternationalPaymentSubmissionReturnNotFound.
@Test
public void testGetMissingInternationalPaymentSubmissionReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRInternationalConsent consent = saveConsent();
FRWriteInternational submissionRequest = JMockData.mock(FRWriteInternational.class);
FRInternationalPaymentSubmission submission = FRInternationalPaymentSubmission.builder().id(consent.getId()).internationalPayment(submissionRequest).build();
// When
HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/international-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentsApiControllerIT method savePaymentSubmission.
private FRInternationalPaymentSubmission savePaymentSubmission(FRInternationalConsent consent) {
FRWriteInternational submissionRequest = JMockData.mock(FRWriteInternational.class);
submissionRequest.getData().getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
FRInternationalPaymentSubmission submission = FRInternationalPaymentSubmission.builder().id(consent.getId()).internationalPayment(submissionRequest).build();
submissionRepository.save(submission);
return submission;
}
use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalStandingOrderPaymentsApiControllerIT method testGetMissingInternationalStandingOrderPaymentSubmissionReturnNotFound.
@Test
public void testGetMissingInternationalStandingOrderPaymentSubmissionReturnNotFound() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRInternationalStandingOrderConsent consent = saveConsent();
FRWriteInternational submissionRequest = JMockData.mock(FRWriteInternational.class);
FRInternationalPaymentSubmission submission = FRInternationalPaymentSubmission.builder().id(consent.getId()).internationalPayment(submissionRequest).build();
// When
HttpResponse<String> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1.1/pisp/international-standing-orders/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(String.class);
// Then
assertThat(response.getStatus()).isEqualTo(400);
}
use of com.forgerock.openbanking.common.model.openbanking.domain.payment.FRWriteInternational in project openbanking-aspsp by OpenBankingToolkit.
the class InternationalPaymentsApiController method createInternationalPayments.
public ResponseEntity<OBWriteInternationalResponse4> createInternationalPayments(OBWriteInternational3 obWriteInternational3, 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: '{}'", obWriteInternational3);
FRWriteInternational frWriteInternational = toFRWriteInternational(obWriteInternational3);
log.trace("Converted to: '{}'", frWriteInternational);
String paymentId = obWriteInternational3.getData().getConsentId();
FRInternationalConsent paymentConsent = internationalConsentRepository.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);
FRInternationalPaymentSubmission frPaymentSubmission = FRInternationalPaymentSubmission.builder().id(paymentId).internationalPayment(frWriteInternational).created(new Date()).updated(new Date()).idempotencyKey(xIdempotencyKey).obVersion(VersionPathExtractor.getVersionFromPath(request)).build();
frPaymentSubmission = new IdempotentRepositoryAdapter<>(internationalPaymentSubmissionRepository).idempotentSave(frPaymentSubmission);
return ResponseEntity.status(HttpStatus.CREATED).body(responseEntity(frPaymentSubmission, paymentConsent));
}
Aggregations