Skip to content

Commit

Permalink
PAYM-5230: Use payments v3 spec
Browse files Browse the repository at this point in the history
  • Loading branch information
polarfish committed Apr 22, 2024
1 parent 3904447 commit 0814065
Show file tree
Hide file tree
Showing 6 changed files with 111 additions and 84 deletions.
27 changes: 27 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@
<arrangement-integration-inbound-api.version>2.7.2</arrangement-integration-inbound-api.version>
<contentservices-client-api.version>2.6.0</contentservices-client-api.version>
<contact-manager-integration-inbound-api.version>2.9.5</contact-manager-integration-inbound-api.version>
<payment-order-client-api.version>3.9.0</payment-order-client-api.version>

</properties>

Expand Down Expand Up @@ -472,6 +473,18 @@
<fromFile>contact-manager-integration-inbound-api-v${contact-manager-integration-inbound-api.version}.yaml</fromFile>
</configuration>
</execution>

<execution>
<id>download-payment-order-client-api-spec</id>
<goals>
<goal>download-single</goal>
</goals>
<phase>generate-sources</phase>
<configuration>
<url>https://repo.backbase.com/specs/payment</url>
<fromFile>payment-order-client-api-v${payment-order-client-api.version}.yaml</fromFile>
</configuration>
</execution>
</executions>
</plugin>

Expand Down Expand Up @@ -642,6 +655,20 @@
</configOptions>
</configuration>
</execution>

<execution>
<id>generate-payment-order-client-api-client-code</id>
<goals>
<goal>generate</goal>
</goals>
<configuration>
<inputSpec>${api.target}/payment-order-client-api-v${payment-order-client-api.version}.yaml</inputSpec>
<configOptions>
<apiPackage>com.backbase.dbs.paymentorder.client.api.v3</apiPackage>
<modelPackage>com.backbase.dbs.paymentorder.client.api.v3.model</modelPackage>
</configOptions>
</configuration>
</execution>
</executions>
</plugin>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.backbase.ct.bbfuel.client.common.RestClient;
import com.backbase.ct.bbfuel.config.BbFuelConfiguration;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId;
import io.restassured.http.ContentType;
import io.restassured.response.Response;
import javax.annotation.PostConstruct;
Expand All @@ -15,7 +15,7 @@ public class PaymentOrderPresentationRestClient extends RestClient {

private final BbFuelConfiguration config;

private static final String SERVICE_VERSION = "v2";
private static final String SERVICE_VERSION = "v3";
private static final String ENDPOINT_PAYMENT_ORDERS = "/payment-orders";

@PostConstruct
Expand All @@ -25,7 +25,7 @@ public void init() {
setInitialPath(config.getDbsServiceNames().getPayments() + "/" + CLIENT_API);
}

public Response initiatePaymentOrder(InitiatePaymentOrder body) {
public Response initiatePaymentOrder(InitiatePaymentOrderWithId body) {
return requestSpec()
.contentType(ContentType.JSON)
.body(body)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
import com.backbase.ct.bbfuel.data.PaymentsDataGenerator;
import com.backbase.ct.bbfuel.util.CommonHelpers;
import com.backbase.ct.bbfuel.util.GlobalProperties;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId;
import com.backbase.dbs.productsummary.presentation.rest.spec.v2.productsummary.ArrangementsByBusinessFunctionGetResponseBody;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -41,6 +41,8 @@ public void ingestPaymentOrders(String externalUserId) {

List<String> ootbPaymentTypes = globalProperties.getList(PROPERTY_PAYMENTS_OOTB_TYPES);

log.info("ootbPaymentTypes is {}", String.join(",", ootbPaymentTypes));

loginRestClient.login(externalUserId, externalUserId);
userContextPresentationRestClient.selectContextBasedOnMasterServiceAgreement();
List<ArrangementsByBusinessFunctionGetResponseBody> sepaCtArrangements = productSummaryPresentationRestClient
Expand Down Expand Up @@ -75,7 +77,7 @@ public void ingestPaymentOrders(String externalUserId) {
throw new IllegalArgumentException("Unknown payment type " + paymentType);
}

InitiatePaymentOrder initiatePaymentOrder = PaymentsDataGenerator
InitiatePaymentOrderWithId initiatePaymentOrder = PaymentsDataGenerator
.generateInitiatePaymentOrder(randomArrangement.getId(), randomArrangement.getCurrency(), paymentType);
paymentOrderPresentationRestClient.initiatePaymentOrder(initiatePaymentOrder)
.then()
Expand Down
152 changes: 75 additions & 77 deletions src/main/java/com/backbase/ct/bbfuel/data/PaymentsDataGenerator.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,31 @@
import static com.backbase.ct.bbfuel.util.CommonHelpers.getRandomFromList;

import com.backbase.ct.bbfuel.util.CommonHelpers;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.AccountIdentification;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.Bank;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.Identification;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.IdentifiedPaymentOrder;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiateCounterpartyAccount;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiatePaymentOrder;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InitiateTransaction;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.InvolvedParty;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.PostalAddress;
import com.backbase.dbs.presentation.paymentorder.rest.spec.v2.paymentorders.Schedule;
import com.backbase.rest.spec.common.types.Currency;
import com.backbase.dbs.paymentorder.client.api.v3.model.AccountIdentification;
import com.backbase.dbs.paymentorder.client.api.v3.model.Bank;
import com.backbase.dbs.paymentorder.client.api.v3.model.CurrencyTyped;
import com.backbase.dbs.paymentorder.client.api.v3.model.Identification;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiateCounterpartyAccount;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiatePaymentOrderWithId;
import com.backbase.dbs.paymentorder.client.api.v3.model.InitiateTransaction;
import com.backbase.dbs.paymentorder.client.api.v3.model.InstructionPriority;
import com.backbase.dbs.paymentorder.client.api.v3.model.InvolvedParty;
import com.backbase.dbs.paymentorder.client.api.v3.model.PaymentMode;
import com.backbase.dbs.paymentorder.client.api.v3.model.PostalAddress;
import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule;
import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule.EveryEnum;
import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule.NonWorkingDayExecutionStrategyEnum;
import com.backbase.dbs.paymentorder.client.api.v3.model.Schedule.TransferFrequencyEnum;
import com.backbase.dbs.paymentorder.client.api.v3.model.SchemeNames;
import com.github.javafaker.Faker;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Random;
import org.apache.commons.lang.time.DateUtils;
import java.util.UUID;

public class PaymentsDataGenerator {

private static Faker faker = new Faker();
private static Random random = new Random();
private static List<String> branchCodes = Arrays
.asList("114923756", "114910222", "124000054", "113011258", "113110586", "121002042", "122003396", "122232109",
"122237625", "122237997", "122238572", "122105045", "122105171", "122105320", "122400779", "123006965",
Expand All @@ -42,26 +44,23 @@ public class PaymentsDataGenerator {
"NWBKGB2LXXX", "COBADEFFXXX", "BNPAFRPPXXX", "POALILITXXX", "LOYDGB2LXXX", "NTSBDEB1XXX", "DEUTDEDBPAL",
"AXISINBB002");

public static InitiatePaymentOrder generateInitiatePaymentOrder(String originatorArrangementId,
public static InitiatePaymentOrderWithId generateInitiatePaymentOrder(String originatorArrangementId,
String originatorArrangementCurrency, String paymentType) {
IdentifiedPaymentOrder.PaymentMode paymentMode = IdentifiedPaymentOrder.PaymentMode.values()[random
.nextInt(IdentifiedPaymentOrder.PaymentMode.values().length)];
PaymentMode paymentMode = getRandomFromEnumValues(PaymentMode.values());
Schedule schedule = null;
Bank counterpartyBank = null;
Bank correspondentBank = null;
Currency currency = new Currency().withAmount(CommonHelpers.generateRandomAmountInRange(1000L, 99999L));
CurrencyTyped currency = new CurrencyTyped().amount(CommonHelpers.generateRandomAmountInRange(1000L, 99999L));
Identification identification;

if (paymentMode.equals(IdentifiedPaymentOrder.PaymentMode.RECURRING)) {
if (paymentMode == PaymentMode.RECURRING) {
schedule = new Schedule()
.withStartDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
.withEvery(getRandomFromEnumValues(Schedule.Every.values()))
.withNonWorkingDayExecutionStrategy(
getRandomFromEnumValues(Schedule.NonWorkingDayExecutionStrategy.values()))
.withTransferFrequency(
getRandomFromEnumValues(Schedule.TransferFrequency.values()))
.withOn(CommonHelpers.generateRandomNumberInRange(1, 7))
.withEndDate(new SimpleDateFormat("yyyy-MM-dd").format(DateUtils.addYears(new Date(), 1)));
.startDate(LocalDate.now())
.every(getRandomFromEnumValues(EveryEnum.values()))
.nonWorkingDayExecutionStrategy(getRandomFromEnumValues(NonWorkingDayExecutionStrategyEnum.values()))
.transferFrequency(getRandomFromEnumValues(TransferFrequencyEnum.values()))
.on(CommonHelpers.generateRandomNumberInRange(1, 7))
.endDate(LocalDate.now().plusYears(1L));
}

if (PAYMENT_TYPE_SEPA_CREDIT_TRANSFER.equals(paymentType)) {
Expand All @@ -78,69 +77,68 @@ public static InitiatePaymentOrder generateInitiatePaymentOrder(String originato
identification = generateBbanIdentification();
}

return new InitiatePaymentOrder()
.withOriginatorAccount(new AccountIdentification()
.withName(faker.lorem().sentence(3, 0).replace(".", ""))
.withIdentification(new Identification().withSchemeName(Identification.SchemeName.ID)
.withIdentification(originatorArrangementId)))
.withBatchBooking(false)
.withInstructionPriority(IdentifiedPaymentOrder.InstructionPriority.values()[random
.nextInt(IdentifiedPaymentOrder.InstructionPriority.values().length)])
.withPaymentMode(paymentMode)
.withPaymentType(paymentType)
.withRequestedExecutionDate(new SimpleDateFormat("yyyy-MM-dd").format(new Date()))
.withSchedule(schedule)
.withTransferTransactionInformation(new InitiateTransaction()
.withEndToEndIdentification(faker.lorem().characters(10))
.withCounterpartyAccount(new InitiateCounterpartyAccount()
.withName(faker.lorem().sentence(3, 0).replace(".", ""))
.withIdentification(identification))
.withInstructedAmount(currency)
.withRemittanceInformation(faker.lorem().sentence(3, 0).replace(".", ""))
.withCounterparty(new InvolvedParty()
.withName(faker.name().fullName())
.withPostalAddress(new PostalAddress()
.withAddressLine1(faker.address().streetAddress())
.withAddressLine2(faker.address().secondaryAddress())
.withStreetName(faker.address().streetAddress())
.withPostCode(faker.address().zipCode())
.withTown(faker.address().city())
.withCountry(faker.address().countryCode())
.withCountrySubDivision(faker.address().state())))
.withCounterpartyBank(counterpartyBank)
.withCorrespondentBank(correspondentBank));
return new InitiatePaymentOrderWithId()
.id(UUID.randomUUID().toString())
.originatorAccount(new AccountIdentification()
.name(faker.lorem().sentence(3, 0).replace(".", ""))
.identification(
new Identification().schemeName(SchemeNames.ID).identification(originatorArrangementId)))
.instructionPriority(getRandomFromEnumValues(InstructionPriority.values()))
.paymentMode(paymentMode)
.paymentType(paymentType)
.requestedExecutionDate(LocalDate.now())
.schedule(schedule)
.transferTransactionInformation(new InitiateTransaction()
.endToEndIdentification(faker.lorem().characters(10))
.counterpartyAccount(new InitiateCounterpartyAccount()
.name(faker.lorem().sentence(3, 0).replace(".", ""))
.identification(identification))
.instructedAmount(currency)
.remittanceInformation(faker.lorem().sentence(3, 0).replace(".", ""))
.counterparty(new InvolvedParty()
.name(faker.name().fullName())
.postalAddress(new PostalAddress()
.addressLine1(faker.address().streetAddress())
.addressLine2(faker.address().secondaryAddress())
.streetName(faker.address().streetAddress())
.postCode(faker.address().zipCode())
.town(faker.address().city())
.country(faker.address().countryCode())
.countrySubDivision(faker.address().state())))
.counterpartyBank(counterpartyBank)
.correspondentBank(correspondentBank));
}

private static Identification generateIbanIdentification() {
return new Identification()
.withSchemeName(Identification.SchemeName.IBAN)
.withIdentification(ProductSummaryDataGenerator.generateRandomIban());
.schemeName(SchemeNames.IBAN)
.identification(ProductSummaryDataGenerator.generateRandomIban());
}

private static Identification generateBbanIdentification() {
return new Identification()
.withSchemeName(Identification.SchemeName.BBAN)
.withIdentification(String.valueOf(CommonHelpers.generateRandomNumberInRange(0, 999999999)));
.schemeName(SchemeNames.BBAN)
.identification(String.valueOf(CommonHelpers.generateRandomNumberInRange(0, 999999999)));
}

private static Bank generateCorrespondentBank() {
return new Bank()
.withBankBranchCode(getRandomFromList(branchCodes))
.withName(faker.name().fullName());
.bankBranchCode(getRandomFromList(branchCodes))
.name(faker.name().fullName());
}

private static Bank generateCounterpartyBank() {
return new Bank()
.withBankBranchCode(getRandomFromList(branchCodes))
.withName(faker.name().fullName())
.withBic(getRandomFromList(bicCodes))
.withPostalAddress(new PostalAddress()
.withAddressLine1(faker.address().streetAddress())
.withAddressLine2(faker.address().secondaryAddress())
.withStreetName(faker.address().streetAddress())
.withPostCode(faker.address().zipCode())
.withTown(faker.address().city())
.withCountry(faker.address().countryCode())
.withCountrySubDivision(faker.address().state()));
.bankBranchCode(getRandomFromList(branchCodes))
.name(faker.name().fullName())
.bic(getRandomFromList(bicCodes))
.postalAddress(new PostalAddress()
.addressLine1(faker.address().streetAddress())
.addressLine2(faker.address().secondaryAddress())
.streetName(faker.address().streetAddress())
.postCode(faker.address().zipCode())
.town(faker.address().city())
.country(faker.address().countryCode())
.countrySubDivision(faker.address().state()));
}
}
2 changes: 1 addition & 1 deletion src/main/resources/data.properties
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ payments.min=10
payments.max=30
# Available OOTB payment types: SEPA_CREDIT_TRANSFER/US_DOMESTIC_WIRE/ACH_DEBIT/US_FOREIGN_WIRE
# This is a comma (,) separated value
payments.ootb.types=SEPA_CREDIT_TRANSFER,US_DOMESTIC_WIRE,ACH_DEBIT,US_FOREIGN_WIRE
payments.ootb.types=SEPA_CREDIT_TRANSFER,US_FOREIGN_WIRE

# Number of messages
ingest.messages=false
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ payments.min=10
payments.max=30
# Available OOTB payment types: SEPA_CREDIT_TRANSFER/US_DOMESTIC_WIRE/ACH_DEBIT/US_FOREIGN_WIRE
# This is a comma (,) separated value
payments.ootb.types=US_DOMESTIC_WIRE,ACH_DEBIT
payments.ootb.types=US_DOMESTIC_WIRE,US_FOREIGN_WIRE

# Number of messages
ingest.messages=false
Expand Down

0 comments on commit 0814065

Please sign in to comment.