mirror of
https://github.com/OpenBankProject/OBP-API.git
synced 2026-02-06 15:06:50 +00:00
added the OBP_BANK_ID and OBP_ACCOUNT_ID guards for createCounterparty endpoint
and also fixed the relevant payments apis.
This commit is contained in:
parent
659a3ab6c9
commit
4dc5ee052b
@ -1038,11 +1038,11 @@ trait APIMethods220 {
|
||||
|
|
||||
|is_beneficiary : must be set to `true` in order to send payments to this counterparty
|
||||
|
|
||||
|bespoke: It support list of key-value, you can add it to the counterarty.
|
||||
|bespoke: It support list of key-value, you can add it to the counterparty.
|
||||
|
|
||||
|bespoke.key : any info-key you want to add to this counerparty
|
||||
|bespoke.key : any info-key you want to add to this counterparty
|
||||
|
|
||||
|bespoke.value : any info-value you want to add to this counerparty
|
||||
|bespoke.value : any info-value you want to add to this counterparty
|
||||
|
|
||||
|The view specified by VIEW_ID must have the canAddCounterparty permission
|
||||
|
|
||||
@ -1050,9 +1050,9 @@ trait APIMethods220 {
|
||||
| {
|
||||
| "name": "Tesobe1",
|
||||
| "description": "Good Company",
|
||||
| "other_bank_routing_scheme": "bankId",
|
||||
| "other_bank_routing_scheme": "OBP_BANK_ID",
|
||||
| "other_bank_routing_address": "gh.29.uk",
|
||||
| "other_account_routing_scheme": "accountId",
|
||||
| "other_account_routing_scheme": "OBP_ACCOUNT_ID",
|
||||
| "other_account_routing_address": "8ca8a7e4-6d02-48e3-a029-0b2bf89de9f0",
|
||||
| "is_beneficiary": true,
|
||||
| "other_account_secondary_routing_scheme": "",
|
||||
@ -1068,9 +1068,9 @@ trait APIMethods220 {
|
||||
| {
|
||||
| "name": "Tesobe2",
|
||||
| "description": "Good Company",
|
||||
| "other_bank_routing_scheme": "bankId",
|
||||
| "other_bank_routing_scheme": "OBP_BANK_ID",
|
||||
| "other_bank_routing_address": "gh.29.uk",
|
||||
| "other_account_routing_scheme": "accountId",
|
||||
| "other_account_routing_scheme": "OBP_ACCOUNT_ID",
|
||||
| "other_account_routing_address": "8ca8a7e4-6d02-48e3-a029-0b2bf89de9f0",
|
||||
| "other_account_secondary_routing_scheme": "IBAN",
|
||||
| "other_account_secondary_routing_address": "DE89 3704 0044 0532 0130 00",
|
||||
@ -1118,17 +1118,17 @@ trait APIMethods220 {
|
||||
_ <- booleanToBox(postJson.description.length <= 36, s"$InvalidValueLength. The maximum length of `description` field is ${MappedCounterparty.mDescription.maxLen}")
|
||||
|
||||
//If other_account_routing_scheme=="OBP_ACCOUNT_ID" or other_account_secondary_routing_address=="OBP_ACCOUNT_ID" we will check if it is a real obp bank account.
|
||||
_<- if (postJson.other_account_routing_scheme =="OBP_ACCOUNT_ID"){
|
||||
_<- if (postJson.other_bank_routing_scheme == "OBP_BANK_ID" && postJson.other_account_routing_scheme =="OBP_ACCOUNT_ID"){
|
||||
for{
|
||||
(bank, callContext) <- BankX(BankId(postJson.other_bank_routing_address), Some(cc)) ?~! s"$BankNotFound Current BANK_ID = ${postJson.other_bank_routing_address}."
|
||||
account <- Connector.connector.vend.checkBankAccountExistsLegacy(BankId(postJson.other_bank_routing_address), AccountId(postJson.other_account_routing_address), callContext) ?~! s"$BankAccountNotFound Current BANK_ID = ${postJson.other_bank_routing_address}. and Current ACCOUNT_ID = ${postJson.other_account_routing_address}. "
|
||||
} yield {
|
||||
account
|
||||
}
|
||||
} else if (postJson.other_account_secondary_routing_address =="OBP_ACCOUNT_ID"){
|
||||
} else if (postJson.other_bank_routing_scheme == "OBP_BANK_ID" && postJson.other_account_secondary_routing_scheme=="OBP_ACCOUNT_ID"){
|
||||
for{
|
||||
(bank, callContext) <- BankX(BankId(postJson.other_account_secondary_routing_address), Some(cc)) ?~! s"$BankNotFound Current BANK_ID = ${postJson.other_bank_routing_address}."
|
||||
account <- Connector.connector.vend.checkBankAccountExistsLegacy(BankId(postJson.other_bank_routing_address), AccountId(postJson.other_account_routing_address), callContext) ?~! s"$BankAccountNotFound Current BANK_ID = ${postJson.other_bank_routing_address}. and Current ACCOUNT_ID = ${postJson.other_account_routing_address}. "
|
||||
(bank, callContext) <- BankX(BankId(postJson.other_bank_routing_address), Some(cc)) ?~! s"$BankNotFound Current BANK_ID = ${postJson.other_bank_routing_address}."
|
||||
account <- Connector.connector.vend.checkBankAccountExistsLegacy(BankId(postJson.other_bank_routing_address), AccountId(postJson.other_account_secondary_routing_address), callContext) ?~! s"$BankAccountNotFound Current BANK_ID = ${postJson.other_bank_routing_address}. and Current ACCOUNT_ID = ${postJson.other_account_routing_address}. "
|
||||
} yield {
|
||||
account
|
||||
}
|
||||
|
||||
@ -499,15 +499,23 @@ object BankAccountX {
|
||||
* @return BankAccount
|
||||
*/
|
||||
def toBankAccount(counterparty: CounterpartyTrait) : Box[BankAccount] = {
|
||||
if (APIUtil.isSandboxMode)
|
||||
if (counterparty.otherBankRoutingScheme =="OBP_BANK_ID" && counterparty.otherAccountRoutingScheme =="OBP_ACCOUNT_ID")
|
||||
for{
|
||||
toBankId <- Full(BankId(counterparty.otherBankRoutingAddress))
|
||||
toAccountId <- Full(AccountId(counterparty.otherAccountRoutingAddress))
|
||||
toAccount <- BankAccountX(toBankId, toAccountId) ?~! s"${ErrorMessages.CounterpartyNotFound} Current Value: BANK_ID(counterparty.otherBankRoutingAddress=$toBankId) and ACCOUNT_ID(counterparty.otherAccountRoutingAddress=$toAccountId), please use correct OBP BankAccount to create the Counterparty.!!!!! "
|
||||
toAccount <- BankAccountX(toBankId, toAccountId) ?~! s"${ErrorMessages.BankNotFound} Current Value: BANK_ID(counterparty.otherBankRoutingAddress=$toBankId) and ACCOUNT_ID(counterparty.otherAccountRoutingAddress=$toAccountId), please use correct OBP BankAccount to create the Counterparty.!!!!! "
|
||||
} yield{
|
||||
toAccount
|
||||
}
|
||||
else
|
||||
else if (counterparty.otherBankRoutingScheme =="OBP_BANK_ID" && counterparty.otherAccountSecondaryRoutingScheme == "OBP_ACCOUNT_ID")
|
||||
for{
|
||||
toBankId <- Full(BankId(counterparty.otherBankRoutingAddress))
|
||||
toAccountId <- Full(AccountId(counterparty.otherAccountSecondaryRoutingAddress))
|
||||
toAccount <- BankAccountX(toBankId, toAccountId) ?~! s"${ErrorMessages.BankNotFound} Current Value: BANK_ID(counterparty.otherBankRoutingAddress=$toBankId) and ACCOUNT_ID(counterparty.otherAccountRoutingAddress=$toAccountId), please use correct OBP BankAccount to create the Counterparty.!!!!! "
|
||||
} yield{
|
||||
toAccount
|
||||
}
|
||||
else //If we can not create the `BankAccount` from the counterparty, then we just faked the object in memory.
|
||||
Full(
|
||||
BankAccountInMemory(
|
||||
|
||||
@ -523,7 +531,7 @@ object BankAccountX {
|
||||
),
|
||||
|
||||
|
||||
//Can not get from counterparty
|
||||
|
||||
bankId = BankId(""),
|
||||
accountId = AccountId(""),
|
||||
accountType = null,
|
||||
|
||||
@ -97,9 +97,9 @@ class TransactionRequestsTest extends V210ServerSetup with DefaultUsers {
|
||||
|
||||
//prepare for counterparty and SEPA stuff
|
||||
//For SEPA, otherAccountRoutingScheme must be 'IBAN'
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId2.value, "IBAN", "IBAN", true, UUID.randomUUID.toString);
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
//For Counterpart local mapper, the mOtherAccountRoutingScheme='OBP' and mOtherBankRoutingScheme = 'OBP'
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId2.value, "IBAN", "OBP", true, UUID.randomUUID.toString);
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
|
||||
var transactionRequestBodySEPA = TransactionRequestBodySEPAJSON(bodyValue, IbanJson(counterpartySEPA.otherAccountSecondaryRoutingAddress), description, sharedChargePolicy)
|
||||
|
||||
|
||||
@ -111,9 +111,9 @@ class TransactionRequestsTest extends V400ServerSetup with DefaultUsers {
|
||||
|
||||
//prepare for counterparty and SEPA stuff
|
||||
//For SEPA, otherAccountRoutingScheme must be 'IBAN'
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId2.value, "IBAN", "IBAN", true, UUID.randomUUID.toString);
|
||||
val counterpartySEPA = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
//For Counterpart local mapper, the mOtherAccountRoutingScheme='OBP' and mOtherBankRoutingScheme = 'OBP'
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId2.value, "IBAN", "OBP", true, UUID.randomUUID.toString);
|
||||
val counterpartyCounterparty = createCounterparty(bankId.value, accountId2.value, true, UUID.randomUUID.toString);
|
||||
|
||||
var transactionRequestBodySEPA = TransactionRequestBodySEPAJSON(bodyValue, IbanJson(counterpartySEPA.otherAccountSecondaryRoutingAddress), description, sharedChargePolicy)
|
||||
|
||||
|
||||
@ -34,18 +34,18 @@ trait LocalMappedConnectorTestSetup extends TestConnectorSetupWithStandardPermis
|
||||
.saveMe
|
||||
}
|
||||
|
||||
override protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait = {
|
||||
override protected def createCounterparty(bankId: String, accountId: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait = {
|
||||
Counterparties.counterparties.vend.createCounterparty(
|
||||
createdByUserId = createdByUserId,
|
||||
thisBankId = bankId,
|
||||
thisAccountId = accountId,
|
||||
thisViewId = "",
|
||||
name = APIUtil.generateUUID(),
|
||||
otherAccountRoutingScheme = otherAccountRoutingScheme,
|
||||
otherAccountRoutingScheme = "OBP_ACCOUNT_ID",
|
||||
otherAccountRoutingAddress = accountId,
|
||||
otherBankRoutingScheme = "OBP",
|
||||
otherBankRoutingScheme = "OBP_BANK_ID",
|
||||
otherBankRoutingAddress = bankId,
|
||||
otherBranchRoutingScheme ="OBP",
|
||||
otherBranchRoutingScheme ="OBP_BRANCH_ID",
|
||||
otherBranchRoutingAddress ="Berlin",
|
||||
isBeneficiary = isBeneficiary,
|
||||
otherAccountSecondaryRoutingScheme ="IBAN",
|
||||
|
||||
@ -20,7 +20,7 @@ trait TestConnectorSetup {
|
||||
protected def createTransactionRequest(account: BankAccount)
|
||||
protected def updateAccountCurrency(bankId: BankId, accountId : AccountId, currency : String) : BankAccount
|
||||
|
||||
protected def createCounterparty(bankId: String, accountId: String, accountRoutingAddress: String, otherAccountRoutingScheme: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait
|
||||
protected def createCounterparty(bankId: String, accountId: String, isBeneficiary: Boolean, createdByUserId:String): CounterpartyTrait
|
||||
|
||||
/**
|
||||
* This method, will do 4 things:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user