diff --git a/openapi/send.openapi.yaml b/openapi/send.openapi.yaml index 8fd1bca..5da68b3 100644 --- a/openapi/send.openapi.yaml +++ b/openapi/send.openapi.yaml @@ -68,8 +68,8 @@ components: maxLength: 140 description: "The name of payee (e.g. EC name or Company Name)" example: "Comune di Roma" - protocolId: - $ref: "#/components/schemas/ProtocolId" + payTrxRef: + $ref: "#/components/schemas/PayTrxRef" required: - payeeId - name @@ -130,10 +130,10 @@ components: description: "See idPA field" url: "https://docs.pagopa.it/sanp/appendici/primitive#paverifypaymentnotice" - ProtocolId: + PayTrxRef: type: string pattern: "^[ -~]{1,140}$" - description: "The protocol id" + description: "The Pay Transaction Reference" example: "ABC/124" RtpId: diff --git a/src/main/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapper.java b/src/main/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapper.java index 11b0a4f..c69ee47 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapper.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapper.java @@ -10,16 +10,18 @@ @Component public class RtpDtoMapper { - public Rtp toRtp(CreateRtpDto createRtpDto) { + public Rtp toRtp(CreateRtpDto createRtpDto) { return Rtp.builder().noticeNumber(createRtpDto.getPaymentNotice().getNoticeNumber()) .amount(createRtpDto.getPaymentNotice().getAmount()).resourceID(ResourceID.createNew()) .description(createRtpDto.getPaymentNotice().getDescription()) .expiryDate(createRtpDto.getPaymentNotice().getExpiryDate()) .savingDateTime(LocalDateTime.now()) + .payerName(createRtpDto.getPayer().getName()) .payerId(createRtpDto.getPayer().getPayerId()).payeeName(createRtpDto.getPayee().getName()) .payeeId(createRtpDto.getPayee().getPayeeId()).rtpSpId("rtpSpId").endToEndId("endToEndId").iban("iban") - .payTrxRef("payTrxRef").flgConf("flgConf").build(); + .subject(createRtpDto.getPaymentNotice().getSubject()) + .payTrxRef(createRtpDto.getPayee().getPayTrxRef()).flgConf("flgConf").build(); } } diff --git a/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java b/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java index 476932e..5a4382d 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java @@ -7,9 +7,9 @@ @Builder public record Rtp(String noticeNumber, BigDecimal amount, String description, LocalDate expiryDate, - String payerId, String payeeName, String payeeId, ResourceID resourceID, - LocalDateTime savingDateTime, String rtpSpId, String endToEndId, String iban, - String payTrxRef, String flgConf, RtpStatus status) { + String payerId, String payerName, String payeeName, String payeeId, ResourceID resourceID, + String subject, LocalDateTime savingDateTime, String rtpSpId, String endToEndId, String iban, + String payTrxRef, String flgConf, RtpStatus status) { public Rtp toRtpWithActivationInfo(String rtpSpId) { return Rtp.builder() @@ -18,6 +18,7 @@ public Rtp toRtpWithActivationInfo(String rtpSpId) { .iban(this.iban()) .payTrxRef(this.payTrxRef()) .flgConf(this.flgConf()) + .payerName(this.payerName()) .payerId(this.payerId()) .payeeName(this.payeeName()) .payeeId(this.payeeId()) @@ -26,6 +27,7 @@ public Rtp toRtpWithActivationInfo(String rtpSpId) { .description(this.description()) .expiryDate(this.expiryDate()) .resourceID(this.resourceID()) + .subject(this.subject()) .savingDateTime(this.savingDateTime()) .status(RtpStatus.CREATED) .build(); @@ -38,6 +40,7 @@ public Rtp toRtpSent(Rtp rtp) { .iban(rtp.iban()) .payTrxRef(rtp.payTrxRef()) .flgConf(rtp.flgConf()) + .payerName(this.payerName()) .payerId(rtp.payerId()) .payeeName(rtp.payeeName()) .payeeId(rtp.payeeId()) @@ -46,6 +49,7 @@ public Rtp toRtpSent(Rtp rtp) { .description(rtp.description()) .expiryDate(rtp.expiryDate()) .resourceID(rtp.resourceID()) + .subject(this.subject()) .savingDateTime(rtp.savingDateTime()) .status(RtpStatus.SENT) .build(); diff --git a/src/main/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpEntity.java b/src/main/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpEntity.java index e799a3b..3d620a0 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpEntity.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpEntity.java @@ -23,9 +23,11 @@ public class RtpEntity { private BigDecimal amount; private String description; private Instant expiryDate; + private String payerName; private String payerId; private String payeeName; private String payeeId; + private String subject; private Instant savingDateTime; private String rtpSpId; private String iban; diff --git a/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapper.java b/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapper.java index 4c8c3ab..f2d9d20 100644 --- a/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapper.java +++ b/src/main/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapper.java @@ -1,6 +1,5 @@ package it.gov.pagopa.rtp.activator.service.rtp; - import java.net.URI; import java.util.ArrayList; import java.util.List; @@ -83,7 +82,7 @@ public SepaRequestToPayRequestResourceDto toRequestToPay(Rtp rtp) { personIdentification13EPC25922V30DS02WrapperDto.setPrvtId(personIdentification13EPC25922V30DS02Dto); PartyIdentification135EPC25922V30DS022Dto partyIdentification135EPC25922V30DS022Dto = new PartyIdentification135EPC25922V30DS022Dto(); - partyIdentification135EPC25922V30DS022Dto.setNm("Mario Rossi");// FIXED TO CHANGE + partyIdentification135EPC25922V30DS022Dto.setNm(rtp.payerName()); partyIdentification135EPC25922V30DS022Dto .setId(personIdentification13EPC25922V30DS02WrapperDto); @@ -95,7 +94,7 @@ public SepaRequestToPayRequestResourceDto toRequestToPay(Rtp rtp) { .setFinInstnId(dbtFinancialInstitutionIdentification18EPC25922V30DS02Dto); PaymentIdentification6EPC25922V30DS02Dto paymentIdentification6EPC25922V30DS02Dto = new PaymentIdentification6EPC25922V30DS02Dto( - rtp.resourceID().getId().toString(), rtp.endToEndId()); + rtp.resourceID().getId().toString(), rtp.noticeNumber()); ExternalServiceLevel1CodeWrapperDto externalServiceLevel1CodeWrapperDto = new ExternalServiceLevel1CodeWrapperDto(); externalServiceLevel1CodeWrapperDto.setCd(ExternalServiceLevel1CodeDto.SRTP);// FIXED @@ -125,22 +124,27 @@ public SepaRequestToPayRequestResourceDto toRequestToPay(Rtp rtp) { .setFinInstnId(financialInstitutionIdentification18EPC25922V30DS02Dto); ExternalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto externalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto = new ExternalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto(); - externalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto.setCd(ExternalOrganisationIdentification1CodeEPC25922V30DS022Dto.BOID); + externalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto + .setCd(ExternalOrganisationIdentification1CodeEPC25922V30DS022Dto.BOID); GenericOrganisationIdentification1EPC25922V30DS022Dto genericOrganisationIdentification1EPC25922V30DS022Dto = new GenericOrganisationIdentification1EPC25922V30DS022Dto(); genericOrganisationIdentification1EPC25922V30DS022Dto.setId(rtp.payeeId()); - genericOrganisationIdentification1EPC25922V30DS022Dto.setSchmeNm(externalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto); + genericOrganisationIdentification1EPC25922V30DS022Dto + .setSchmeNm(externalOrganisationIdentification1CodeEPC25922V30DS022WrapperDto); List lGenericOrganisationIdentification1EPC25922V30DS022Dtos = new ArrayList<>(); - lGenericOrganisationIdentification1EPC25922V30DS022Dtos.add(genericOrganisationIdentification1EPC25922V30DS022Dto); + lGenericOrganisationIdentification1EPC25922V30DS022Dtos + .add(genericOrganisationIdentification1EPC25922V30DS022Dto); OrganisationIdentification29EPC25922V30DS022Dto organisationIdentification29EPC25922V30DS022Dto = new OrganisationIdentification29EPC25922V30DS022Dto(); - - organisationIdentification29EPC25922V30DS022Dto.setOthr(lGenericOrganisationIdentification1EPC25922V30DS022Dtos); + + organisationIdentification29EPC25922V30DS022Dto + .setOthr(lGenericOrganisationIdentification1EPC25922V30DS022Dtos); OrganisationIdentification29EPC25922V30DS022WrapperDto organisationIdentification29EPC25922V30DS022WrapperDto = new OrganisationIdentification29EPC25922V30DS022WrapperDto(); - organisationIdentification29EPC25922V30DS022WrapperDto.setOrgId(organisationIdentification29EPC25922V30DS022Dto); - + organisationIdentification29EPC25922V30DS022WrapperDto + .setOrgId(organisationIdentification29EPC25922V30DS022Dto); + PartyIdentification135EPC25922V30DS023Dto partyIdentification135EPC25922V30DS023Dto = new PartyIdentification135EPC25922V30DS023Dto(); partyIdentification135EPC25922V30DS023Dto.setNm(rtp.payeeName()); partyIdentification135EPC25922V30DS023Dto @@ -153,7 +157,7 @@ public SepaRequestToPayRequestResourceDto toRequestToPay(Rtp rtp) { cashAccount40EPC25922V30DS022Dto.setId(iban2007IdentifierWrapperDto); InstructionForCreditorAgent3EPC25922V30DS02Dto payTrxRefinstructionForCreditorAgent3EPC25922V30DS02Dto = new InstructionForCreditorAgent3EPC25922V30DS02Dto( - rtp.payTrxRef()); + "ATR113/"+rtp.payTrxRef()); InstructionForCreditorAgent3EPC25922V30DS02Dto flgConfRefinstructionForCreditorAgent3EPC25922V30DS02Dto = new InstructionForCreditorAgent3EPC25922V30DS02Dto( rtp.flgConf()); @@ -164,8 +168,8 @@ public SepaRequestToPayRequestResourceDto toRequestToPay(Rtp rtp) { .add(flgConfRefinstructionForCreditorAgent3EPC25922V30DS02Dto); List lUstrd = new ArrayList<>(); - lUstrd.add("TARI immobile 1234/BU-2024-23231312 -");// FIXED VALUE TO CHANGE - lUstrd.add(rtp.description()); + lUstrd.add(rtp.subject() + "/" + rtp.noticeNumber() + " -"); + lUstrd.add("ATS001/" + rtp.description()); RemittanceInformation21EPC25922V30DS02Dto remittanceInformation21EPC25922V30DS02Dto = new RemittanceInformation21EPC25922V30DS02Dto(); remittanceInformation21EPC25922V30DS02Dto.setUstrd(lUstrd); diff --git a/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapperTest.java b/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapperTest.java index aa8ca28..6e01e80 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapperTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/RtpDtoMapperTest.java @@ -31,11 +31,14 @@ void testToRtp() { paymentNoticeDto.setNoticeNumber("12345"); paymentNoticeDto.setDescription("Payment Description"); paymentNoticeDto.setExpiryDate(LocalDate.now()); + paymentNoticeDto.setSubject("Subject"); createRtpDto.setPaymentNotice(paymentNoticeDto); payerDto.setPayerId("payer123"); + payerDto.setName("John Doe"); createRtpDto.setPayer(payerDto); payeeDto.setPayeeId("payee123"); payeeDto.setName("Payee Name"); + payeeDto.setPayTrxRef("ABC/124"); createRtpDto.setPayee(payeeDto); Rtp rtp = rtpDtoMapper.toRtp(createRtpDto); assertThat(rtp).isNotNull(); @@ -45,13 +48,15 @@ void testToRtp() { assertThat(rtp.amount()).isEqualTo(createRtpDto.getPaymentNotice().getAmount()); assertThat(rtp.description()).isEqualTo(createRtpDto.getPaymentNotice().getDescription()); assertThat(rtp.expiryDate()).isEqualTo(createRtpDto.getPaymentNotice().getExpiryDate()); + assertThat(rtp.payerName()).isEqualTo(createRtpDto.getPayer().getName()); + assertThat(rtp.subject()).isEqualTo(createRtpDto.getPaymentNotice().getSubject()); assertThat(rtp.payerId()).isEqualTo(createRtpDto.getPayer().getPayerId()); assertThat(rtp.payeeName()).isEqualTo(createRtpDto.getPayee().getName()); assertThat(rtp.payeeId()).isEqualTo(createRtpDto.getPayee().getPayeeId()); assertThat(rtp.rtpSpId()).isEqualTo("rtpSpId"); assertThat(rtp.endToEndId()).isEqualTo("endToEndId"); assertThat(rtp.iban()).isEqualTo("iban"); - assertThat(rtp.payTrxRef()).isEqualTo("payTrxRef"); + assertThat(rtp.payTrxRef()).isEqualTo(createRtpDto.getPayee().getPayTrxRef()); assertThat(rtp.flgConf()).isEqualTo("flgConf"); } } \ No newline at end of file diff --git a/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/SendAPIControllerImplTest.java b/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/SendAPIControllerImplTest.java index ccba3ba..2cd8c58 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/SendAPIControllerImplTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/controller/rtp/SendAPIControllerImplTest.java @@ -63,14 +63,18 @@ void setup() { String endToEndId = "endToEndId"; String rtpSpId = "rtpSpId"; String iban = "IT60X0542811101000000123456"; - String payTrxRef = "payTrxRef"; String flgConf = "flgConf"; + String payerName = "John Doe"; + String payTrxRef = "ABC/124"; + String subject = "subject"; expectedRtp = Rtp.builder().noticeNumber(noticeNumber).amount(amount).description(description) .expiryDate(expiryDate) .payerId(payerId).payeeName(payeeName).payeeId(payeeId) .resourceID(ResourceID.createNew()) .savingDateTime(LocalDateTime.now()).rtpSpId(rtpSpId).endToEndId(endToEndId) + .payerName(payerName) + .subject(subject) .iban(iban).payTrxRef(payTrxRef) .flgConf(flgConf).build(); @@ -167,8 +171,9 @@ private CreateRtpDto generateSendRequest() { payeeDto.setName("payeeName"); payeeDto.setPayeeId("77777777777"); + payeeDto.setPayTrxRef("ABC/124"); - payerDto.setName("payername"); + payerDto.setName("payerName"); payerDto.setPayerId("12345678911"); paymentNoticeDto.setAmount(BigDecimal.valueOf(1)); @@ -189,6 +194,7 @@ private CreateRtpDto generateWrongSendRequest() { payeeDto.setName("payeeName"); payeeDto.setPayeeId("77777777777"); + payeeDto.setPayTrxRef("ABC/124"); payerDto.setName("payername"); payerDto.setPayerId("badfiscalcode"); @@ -211,11 +217,13 @@ private CreateRtpDto generateWrongAmountSendRequest() { payeeDto.setName("payeeName"); payeeDto.setPayeeId("77777777777"); + payeeDto.setPayTrxRef("ABC/124"); payerDto.setName("payername"); payerDto.setPayerId("payerId"); paymentNoticeDto.setAmount(new BigDecimal("999999999999")); + paymentNoticeDto.setSubject("subject"); paymentNoticeDto.setDescription("description"); paymentNoticeDto.setNoticeNumber("311111111112222222"); paymentNoticeDto.setExpiryDate(LocalDate.now()); diff --git a/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDBRepositoryTest.java b/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDBRepositoryTest.java index 32a6514..2631294 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDBRepositoryTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDBRepositoryTest.java @@ -43,13 +43,15 @@ void testSaveRtp() { .description("Test Description") .expiryDate(LocalDate.now()) .payerId("payer123") + .payerName("John Doe") .payeeName("Payee Name") .payeeId("payee123") + .subject("subject") .resourceID(new ResourceID(UUID.randomUUID())) .savingDateTime(LocalDateTime.now()) .rtpSpId("rtpSpId") .iban("iban123") - .payTrxRef("payTrxRef123") + .payTrxRef("ABC/124") .flgConf("Y") .status(RtpStatus.CREATED) .build(); diff --git a/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDtoMapperTest.java b/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDtoMapperTest.java index 8522b44..83e8af9 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDtoMapperTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/repository/rtp/RtpDtoMapperTest.java @@ -33,13 +33,15 @@ void toDomain() { .description("Test Description") .expiryDate(Instant.now()) .payerId("payer123") + .payerName("John Doe") .payeeName("Payee Name") .payeeId("payee123") + .subject("subject") .resourceID(uuid) .savingDateTime(Instant.now()) .rtpSpId("rtpSpId") .iban("iban123") - .payTrxRef("payTrxRef123") + .payTrxRef("ABC/124") .flgConf("Y") .status(RtpStatus.CREATED.name()) .build(); @@ -71,14 +73,16 @@ void toDbEntity() { .amount(BigDecimal.valueOf(100.50)) .description("Test Description") .expiryDate(LocalDate.now()) + .payerName("John Doe") .payerId("payer123") .payeeName("Payee Name") .payeeId("payee123") .resourceID(new ResourceID(uuid)) + .subject("subject") .savingDateTime(LocalDateTime.now()) .rtpSpId("rtpSpId") .iban("iban123") - .payTrxRef("payTrxRef123") + .payTrxRef("ABC/124") .flgConf("Y") .status(RtpStatus.CREATED) .build(); diff --git a/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java b/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java index d226cb6..a782b96 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SendRTPServiceTest.java @@ -52,7 +52,7 @@ class SendRTPServiceTest { final String endToEndId = "endToEndId"; final String rtpSpId = "rtpSpId"; final String iban = "IT60X0542811101000000123456"; - final String payTrxRef = "payTrxRef"; + final String payTrxRef = "ABC/124"; final String flgConf = "flgConf"; Rtp inputRtp; diff --git a/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapperTest.java b/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapperTest.java index 05bd1c9..f904dc5 100644 --- a/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapperTest.java +++ b/src/test/java/it/gov/pagopa/rtp/activator/service/rtp/SepaRequestToPayMapperTest.java @@ -42,7 +42,7 @@ void testToRequestToPay() { LocalDate expiryDate = LocalDate.now().plusDays(5); String description = "Pagamento TARI"; String noticeNumber = "123456"; - String payTrxRef = "payTrxRef123"; + String payTrxRef = "ABC/124"; String flgConf = "flgConf123"; when(rtp.resourceID()).thenReturn(resourceId); @@ -66,7 +66,7 @@ void testToRequestToPay() { assertEquals(resourceId.getId().toString(), result.getResourceId()); assertEquals("http://spsrtp.api.cstar.pagopa.it", result.getCallbackUrl().toString()); assertEquals(resourceId.getId().toString(), result.getDocument().getCdtrPmtActvtnReq().getGrpHdr().getMsgId()); - assertTrue(result.getDocument().getCdtrPmtActvtnReq().getPmtInf().get(0).getCdtTrfTx().get(0).getRmtInf().getUstrd().contains(description)); + assertTrue(result.getDocument().getCdtrPmtActvtnReq().getPmtInf().get(0).getCdtTrfTx().get(0).getRmtInf().getUstrd().get(1).contains(description)); } }