use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2 in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiController method createDomesticPaymentConsents.
@Override
public ResponseEntity<OBWriteDomesticConsentResponse2> createDomesticPaymentConsents(@ApiParam(value = "Default", required = true) @Valid @RequestBody OBWriteDomesticConsent2 obWriteDomesticConsent2Param, @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.validateBalanceTransferPayment(obWriteDomesticConsent2Param);
f.validateMoneyTransferPayment(obWriteDomesticConsent2Param);
f.validatePaymPayment(obWriteDomesticConsent2Param);
f.validateRisk(obWriteDomesticConsent2Param.getRisk());
}).execute((String tppId) -> {
HttpHeaders additionalHttpHeaders = new HttpHeaders();
additionalHttpHeaders.add("x-ob-client-id", tppId);
return rsStoreGateway.toRsStore(request, additionalHttpHeaders, Collections.emptyMap(), OBWriteDomesticConsentResponse2.class, obWriteDomesticConsent2Param);
});
}
use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2 in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testCreateDomesticPaymentConsent_exists_idempotencyKeyValid_noActionButReturn201.
@Test
public void testCreateDomesticPaymentConsent_exists_idempotencyKeyValid_noActionButReturn201() throws UnirestException {
// Given
final String idempotencyKey = UUID.randomUUID().toString();
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
OBWriteDomesticConsent4 consentRequest = JMockData.mock(OBWriteDomesticConsent4.class);
consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
consentRequest.getData().getInitiation().getCreditorPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().supplementaryData(null);
consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().addressLine(Collections.singletonList("3 Queens Square")).country("GP").countrySubDivision("aaa");
consentRequest.getData().getAuthorisation().completionDateTime(null);
FRDomesticConsent existingConsent = JMockData.mock(FRDomesticConsent.class);
existingConsent.setId(UUID.randomUUID().toString());
existingConsent.setStatus(ConsentStatusCode.AUTHORISED);
existingConsent.setDomesticConsent(toFRWriteDomesticConsent(consentRequest));
existingConsent.setIdempotencyKey(idempotencyKey);
repository.save(existingConsent);
// When
HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, idempotencyKey).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(consentRequest).asObject(OBWriteDomesticConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticConsentResponse2 consentResponse = response.getBody();
FRDomesticConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(toOBDomestic2(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
assertThat(consent.getStatus().toOBExternalConsentStatus1Code()).isEqualTo(consentResponse.getData().getStatus());
}
use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2 in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testGetDomesticPaymentConsent.
@Test
public void testGetDomesticPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = JMockData.mock(FRDomesticConsent.class);
consent.setStatus(ConsentStatusCode.AUTHORISED);
consent.setIdempotencyKey(UUID.randomUUID().toString());
consent.getInitiation().setSupplementaryData(FRSupplementaryData.builder().data("{}").build());
repository.save(consent);
// When
HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/" + consent.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
assertThat(response.getBody().getData().getInitiation()).isEqualTo(toOBDomestic2(consent.getInitiation()));
assertThat(response.getBody().getData().getStatus()).isEqualTo(consent.getStatus().toOBExternalConsentStatus1Code());
Assertions.assertThat(response.getBody().getData().getCreationDateTime()).isEqualToIgnoringMillis(consent.getCreated());
Assertions.assertThat(response.getBody().getData().getStatusUpdateDateTime()).isEqualToIgnoringMillis(consent.getStatusUpdate());
}
use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2 in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentConsentsApiControllerIT method testCreateDomesticPaymentConsent.
@Test
public void testCreateDomesticPaymentConsent() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
setupMockTpp(tppRepository);
OBWriteDomesticConsent2 consentRequest = JMockData.mock(OBWriteDomesticConsent2.class);
consentRequest.getData().getInitiation().getInstructedAmount().currency("GBP").amount("1.00");
consentRequest.getData().getInitiation().getCreditorPostalAddress().country("GB").addressLine(Collections.singletonList("3 Queens Square"));
consentRequest.getData().getInitiation().supplementaryData(new OBSupplementaryData1());
consentRequest.getRisk().merchantCategoryCode("ABCD").getDeliveryAddress().countrySubDivision("Wessex").addressLine(Collections.singletonList("3 Queens Square")).country("GP");
// When
HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.post("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payment-consents/").header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").header(OBHeaders.X_IDEMPOTENCY_KEY, UUID.randomUUID().toString()).header(OBHeaders.X_JWS_SIGNATURE, "x-jws-signature").header("x-ob-client-id", MOCK_CLIENT_ID).header(OBHeaders.CONTENT_TYPE, "application/json; charset=utf-8").body(consentRequest).asObject(OBWriteDomesticConsentResponse2.class);
// Then
log.error("The response: {}", response);
assertThat(response.getStatus()).isEqualTo(201);
OBWriteDomesticConsentResponse2 consentResponse = response.getBody();
FRDomesticConsent consent = repository.findById(consentResponse.getData().getConsentId()).get();
assertThat(consent.getPispName()).isEqualTo(MOCK_PISP_NAME);
assertThat(consent.getPispId()).isEqualTo(MOCK_PISP_ID);
assertThat(consent.getId()).isEqualTo(consentResponse.getData().getConsentId());
assertThat(toOBDomestic2(consent.getInitiation())).isEqualTo(consentResponse.getData().getInitiation());
assertThat(consent.getStatus().toOBExternalConsentStatus1Code()).isEqualTo(consentResponse.getData().getStatus());
assertThat(consent.getRisk()).isEqualTo(toFRRisk(consentResponse.getRisk()));
assertThat(consent.getObVersion()).isEqualTo(OBVersion.v3_1);
}
use of uk.org.openbanking.datamodel.payment.OBWriteDomesticConsentResponse2 in project openbanking-aspsp by OpenBankingToolkit.
the class DomesticPaymentsApiControllerIT method testGetDomesticPaymentSubmission.
@Test
public void testGetDomesticPaymentSubmission() throws UnirestException {
// Given
springSecForTest.mockAuthCollector.mockAuthorities(OBRIRole.ROLE_PISP);
FRDomesticConsent consent = saveConsent();
FRDomesticPaymentSubmission submission = savePaymentSubmission(consent, UUID.randomUUID().toString());
// When
HttpResponse<OBWriteDomesticConsentResponse2> response = Unirest.get("https://rs-store:" + port + "/open-banking/v3.1/pisp/domestic-payments/" + submission.getId()).header(OBHeaders.X_FAPI_FINANCIAL_ID, rsConfiguration.financialId).header(OBHeaders.AUTHORIZATION, "token").asObject(OBWriteDomesticConsentResponse2.class);
// Then
assertThat(response.getStatus()).isEqualTo(200);
assertThat(response.getBody().getData().getConsentId()).isEqualTo(consent.getId());
assertThat(response.getBody().getData().getInitiation()).isEqualTo(toOBDomestic2(submission.getDomesticPayment().getData().getInitiation()));
assertThat(response.getBody().getData().getCreationDateTime()).isEqualTo(consent.getCreated());
assertThat(response.getBody().getData().getStatusUpdateDateTime()).isEqualTo(consent.getStatusUpdate());
}
Aggregations