Skip to content

Commit

Permalink
feat: [SRTP-209] update mapping (#52)
Browse files Browse the repository at this point in the history
  • Loading branch information
lucaconsalvi authored Jan 17, 2025
1 parent 3cc2e77 commit a5d44d6
Show file tree
Hide file tree
Showing 11 changed files with 62 additions and 31 deletions.
8 changes: 4 additions & 4 deletions openapi/send.openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

}
10 changes: 7 additions & 3 deletions src/main/java/it/gov/pagopa/rtp/activator/domain/rtp/Rtp.java
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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())
Expand All @@ -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();
Expand All @@ -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())
Expand All @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package it.gov.pagopa.rtp.activator.service.rtp;


import java.net.URI;
import java.util.ArrayList;
import java.util.List;
Expand Down Expand Up @@ -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);

Expand All @@ -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
Expand Down Expand Up @@ -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<GenericOrganisationIdentification1EPC25922V30DS022Dto> 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
Expand All @@ -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());

Expand All @@ -164,8 +168,8 @@ public SepaRequestToPayRequestResourceDto toRequestToPay(Rtp rtp) {
.add(flgConfRefinstructionForCreditorAgent3EPC25922V30DS02Dto);

List<String> 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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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();

Expand Down Expand Up @@ -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));
Expand All @@ -189,6 +194,7 @@ private CreateRtpDto generateWrongSendRequest() {

payeeDto.setName("payeeName");
payeeDto.setPayeeId("77777777777");
payeeDto.setPayTrxRef("ABC/124");

payerDto.setName("payername");
payerDto.setPayerId("badfiscalcode");
Expand All @@ -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());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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));
}
}

0 comments on commit a5d44d6

Please sign in to comment.