mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 12:56:51 +00:00
feature/TODO Implement IBAN Checker in Mapper mode
This commit is contained in:
parent
c85e25fe58
commit
2ec2358725
@ -469,6 +469,13 @@
|
||||
<version>1.0.45</version>
|
||||
</dependency>
|
||||
<!--json schema validation end-->
|
||||
|
||||
<!-- https://mvnrepository.com/artifact/org.iban4j/iban4j -->
|
||||
<dependency>
|
||||
<groupId>org.iban4j</groupId>
|
||||
<artifactId>iban4j</artifactId>
|
||||
<version>3.2.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@ -388,9 +388,9 @@ object SwaggerDefinitionsJSON {
|
||||
)
|
||||
|
||||
val sepaCreditTransfersBerlinGroupV13 = SepaCreditTransfersBerlinGroupV13(
|
||||
debtorAccount = PaymentAccount(iban = "12345"),
|
||||
debtorAccount = PaymentAccount(iban = "GB33BUKB20201555555555"),
|
||||
instructedAmount = amountOfMoneyJsonV121,
|
||||
creditorAccount = PaymentAccount(iban = "54321"),
|
||||
creditorAccount = PaymentAccount(iban = "DE75512108001245126199"),
|
||||
creditorName = "John Miles"
|
||||
)
|
||||
|
||||
|
||||
@ -85,6 +85,8 @@ import net.liftweb.mapper.{By, _}
|
||||
import net.liftweb.util.Helpers.{hours, now, time, tryo}
|
||||
import net.liftweb.util.Mailer
|
||||
import net.liftweb.util.Mailer.{From, PlainMailBodyType, Subject, To}
|
||||
import org.iban4j
|
||||
import org.iban4j.{CountryCode, IbanFormat}
|
||||
import org.mindrot.jbcrypt.BCrypt
|
||||
import scalacache.ScalaCache
|
||||
import scalacache.guava.GuavaCache
|
||||
@ -121,8 +123,29 @@ object LocalMappedConnector extends Connector with MdcLoggable {
|
||||
), callContext))
|
||||
|
||||
override def validateAndCheckIbanNumber(iban: String, callContext: Option[CallContext]): OBPReturnType[Box[IbanChecker]] = Future {
|
||||
// TODO Implement IBAN Checker
|
||||
(Full(IbanChecker(true, None)), callContext)
|
||||
import org.iban4j.CountryCode
|
||||
import org.iban4j.Iban
|
||||
import org.iban4j.IbanFormat
|
||||
import org.iban4j.IbanFormatException
|
||||
import org.iban4j.IbanUtil
|
||||
import org.iban4j.InvalidCheckDigitException
|
||||
import org.iban4j.UnsupportedCountryException
|
||||
|
||||
// Validate Iban
|
||||
try { // 1st try
|
||||
IbanUtil.validate(iban) // IBAN as String: "DE89370400440532013000"
|
||||
(Full(IbanChecker(true, None)), callContext) // valid
|
||||
} catch {
|
||||
case error@(_: IbanFormatException | _: InvalidCheckDigitException | _: UnsupportedCountryException) =>
|
||||
// invalid
|
||||
try { // 2nd try
|
||||
IbanUtil.validate(iban, IbanFormat.Default) // IBAN as formatted String: "DE89 3704 0044 0532 0130 00"
|
||||
(Full(IbanChecker(true, None)), callContext) // valid
|
||||
} catch {
|
||||
case error@(_: IbanFormatException | _: InvalidCheckDigitException | _: UnsupportedCountryException) =>
|
||||
(Full(IbanChecker(false, None)), callContext) // invalid
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Gets current challenge level for transaction request
|
||||
|
||||
@ -45,7 +45,7 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|
||||
| "amount": "1234"
|
||||
|},
|
||||
|"creditorAccount": {
|
||||
| "iban": "123"
|
||||
| "iban": "DE75512108001245126199"
|
||||
|},
|
||||
|"creditorName": "70charname"
|
||||
}""".stripMargin
|
||||
@ -69,7 +69,7 @@ class PaymentInitiationServicePISApiTest extends BerlinGroupServerSetupV1_3 with
|
||||
| "amount": "-1234"
|
||||
|},
|
||||
|"creditorAccount": {
|
||||
| "iban": "12321"
|
||||
| "iban": "DE75512108001245126199"
|
||||
|},
|
||||
|"creditorName": "70charname"
|
||||
}""".stripMargin
|
||||
|
||||
@ -16,6 +16,7 @@ import com.openbankproject.commons.model.enums.AccountRoutingScheme
|
||||
import net.liftweb.common.Box
|
||||
import net.liftweb.mapper.{By, MetaMapper}
|
||||
import net.liftweb.util.Helpers._
|
||||
import org.iban4j
|
||||
|
||||
import scala.util.Random
|
||||
|
||||
@ -62,7 +63,7 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
.BankId(bankId.value)
|
||||
.AccountId(accountId.value)
|
||||
.AccountRoutingScheme(AccountRoutingScheme.IBAN.toString)
|
||||
.AccountRoutingAddress(randomString(20))
|
||||
.AccountRoutingAddress(iban4j.Iban.random().toString())
|
||||
.saveMe
|
||||
BankAccountRouting.create
|
||||
.BankId(bankId.value)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user