Skip to content

Commit

Permalink
Add support for Bizum transactions in Revolut (#459)
Browse files Browse the repository at this point in the history
* fix: rename proprietaryBank to proprietaryBankTransactionCode

* feat: Add support for RevolutRevolt21 Bizum transactions

* test: Add RevolutRevolt21 bizum transactions tests

* chore: Add upcoming release note

* fix: Add missing bookingDate to tests

* fix: sort everything alphabetically
  • Loading branch information
hostyn authored Sep 26, 2024
1 parent 835b698 commit 0757f9d
Show file tree
Hide file tree
Showing 5 changed files with 149 additions and 35 deletions.
70 changes: 36 additions & 34 deletions src/app-gocardless/bank-factory.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,16 +16,17 @@ import IntegrationBank from './banks/integration-bank.js';
import KBCkredbebb from './banks/kbc_kredbebb.js';
import MbankRetailBrexplpw from './banks/mbank-retail-brexplpw.js';
import NationwideNaiaGB21 from './banks/nationwide-naiagb21.js';
import NbgEthngraaxxx from './banks/nbg_ethngraaxxx.js';
import NorwegianXxNorwnok1 from './banks/norwegian-xx-norwnok1.js';
import RevolutRevolt21 from './banks/revolut_revolt21.js';
import SandboxfinanceSfin0000 from './banks/sandboxfinance-sfin0000.js';
import SEBKortBankAB from './banks/seb-kort-bank-ab.js';
import SEBPrivat from './banks/seb-privat.js';
import SandboxfinanceSfin0000 from './banks/sandboxfinance-sfin0000.js';
import SparNordSpNoDK22 from './banks/sparnord-spnodk22.js';
import SpkKarlsruhekarsde66 from './banks/spk-karlsruhe-karsde66.js';
import SpkMarburgBiedenkopfHeladef1mar from './banks/spk-marburg-biedenkopf-heladef1mar.js';
import SpkWormsAlzeyRiedMalade51wor from './banks/spk-worms-alzey-ried-malade51wor.js';
import VirginNrnbgb22 from './banks/virgin_nrnbgb22.js';
import NbgEthngraaxxx from './banks/nbg_ethngraaxxx.js';

export const banks = [
AbancaCaglesmm,
Expand All @@ -45,64 +46,65 @@ export const banks = [
KBCkredbebb,
MbankRetailBrexplpw,
NationwideNaiaGB21,
NbgEthngraaxxx,
NorwegianXxNorwnok1,
RevolutRevolt21,
SandboxfinanceSfin0000,
SEBKortBankAB,
SEBPrivat,
SandboxfinanceSfin0000,
SparNordSpNoDK22,
SpkKarlsruhekarsde66,
SpkMarburgBiedenkopfHeladef1mar,
SpkWormsAlzeyRiedMalade51wor,
VirginNrnbgb22,
NbgEthngraaxxx,
];

export default (institutionId) =>
banks.find((b) => b.institutionIds.includes(institutionId)) ||
IntegrationBank;

export const BANKS_WITH_LIMITED_HISTORY = [
'BANCA_AIDEXA_AIDXITMM',
'BANCA_PATRIMONI_SENVITT1',
'BANCA_SELLA_SELBIT2B',
'BANKINTER_BKBKESMM',
'BBVA_BBVAESMM',
'BRED_BREDFRPPXXX',
'INDUSTRA_MULTLV2X',
'MEDICINOSBANK_MDBALT22XXX',
'CAIXABANK_CAIXESBB',
'CARTALIS_CIMTITR1',
'CESKA_SPORITELNA_LONG_GIBACZPX',
'COOP_EKRDEE22',
'DOTS_HYEEIT22',
'HYPE_BUSINESS_HYEEIT22',
'HYPE_HYEEIT2',
'ILLIMITY_ITTPIT2M',
'INDUSTRA_MULTLV2X',
'JEKYLL_JEYKLL002',
'LABORALKUTXA_CLPEES2M',
'LHV_LHVBEE22',
'LUMINOR_NDEALT2X',
'LUMINOR_RIKOEE22',
'LUMINOR_AGBLLT2X',
'LUMINOR_NDEALV2X',
'LUMINOR_NDEAEE2X',
'LUMINOR_NDEALT2X',
'LUMINOR_NDEALV2X',
'LUMINOR_RIKOEE22',
'LUMINOR_RIKOLV2X',
'MEDICINOSBANK_MDBALT22XXX',
'NORDEA_NDEADKKK',
'OPYN_BITAITRRB2B',
'PAYTIPPER_PAYTITM1',
'REVOLUT_REVOLT21',
'SANTANDER_BSCHESMM',
'SANTANDER_DE_SCFBDE33',
'SEB_CBVILT2X',
'SEB_EEUHEE2X',
'SEB_UNLALV2X',
'SELLA_PERSONAL_CREDIT_SELBIT22',
'SMARTIKA_SELBIT22',
'SWEDBANK_HABAEE2X',
'SWEDBANK_HABALT22',
'SWEDBANK_HABALV22',
'SWEDBANK_SWEDSESS',
'SEB_CBVILT2X',
'SEB_UNLALV2X',
'SEB_EEUHEE2X',
'LABORALKUTXA_CLPEES2M',
'BANKINTER_BKBKESMM',
'CAIXABANK_CAIXESBB',
'JEKYLL_JEYKLL002',
'SANTANDER_DE_SCFBDE33',
'BBVA_BBVAESMM',
'COOP_EKRDEE22',
'BANCA_AIDEXA_AIDXITMM',
'BANCA_PATRIMONI_SENVITT1',
'BANCA_SELLA_SELBIT2B',
'CARTALIS_CIMTITR1',
'DOTS_HYEEIT22',
'HYPE_BUSINESS_HYEEIT22',
'HYPE_HYEEIT2',
'ILLIMITY_ITTPIT2M',
'SMARTIKA_SELBIT22',
'TIM_HYEEIT22',
'TOT_SELBIT2B',
'OPYN_BITAITRRB2B',
'PAYTIPPER_PAYTITM1',
'SELLA_PERSONAL_CREDIT_SELBIT22',
'SANTANDER_BSCHESMM',
'NORDEA_NDEADKKK',
'VUB_BANKA_SUBASKBX',
'REVOLUT_REVOLT21',
];
60 changes: 60 additions & 0 deletions src/app-gocardless/banks/revolut_revolt21.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
import { formatPayeeName } from '../../util/payee-name.js';
import * as d from 'date-fns';
import Fallback from './integration-bank.js';

/** @type {import('./bank.interface.js').IBank} */
export default {
...Fallback,

institutionIds: ['REVOLUT_REVOLT21'],

accessValidForDays: 90,

normalizeTransaction(transaction, _booked) {
if (
transaction.remittanceInformationUnstructuredArray[0].startsWith(
'Bizum payment from: ',
)
) {
const date =
transaction.bookingDate ||
transaction.bookingDateTime ||
transaction.valueDate ||
transaction.valueDateTime;

return {
...transaction,
payeeName:
transaction.remittanceInformationUnstructuredArray[0].replace(
'Bizum payment from: ',
'',
),
remittanceInformationUnstructured:
transaction.remittanceInformationUnstructuredArray[1],
date: d.format(d.parseISO(date), 'yyyy-MM-dd'),
};
}

if (
transaction.remittanceInformationUnstructuredArray[0].startsWith(
'Bizum payment to: ',
)
) {
const date =
transaction.bookingDate ||
transaction.bookingDateTime ||
transaction.valueDate ||
transaction.valueDateTime;

return {
...transaction,
payeeName: formatPayeeName(transaction),
remittanceInformationUnstructured:
transaction.remittanceInformationUnstructuredArray[1],
date: d.format(d.parseISO(date), 'yyyy-MM-dd'),
};
}

return Fallback.normalizeTransaction(transaction, _booked);
},
};
46 changes: 46 additions & 0 deletions src/app-gocardless/banks/tests/revolut_revolt21.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import RevolutRevolt21 from '../revolut_revolt21.js';

describe('RevolutRevolt21', () => {
describe('#normalizeTransaction', () => {
it('returns the expected remittanceInformationUnstructured from a bizum expense transfer', () => {
const transaction = {
transactionAmount: { amount: '-1.00', currency: 'EUR' },
remittanceInformationUnstructuredArray: [
'Bizum payment to: CREDITOR NAME',
'Bizum description',
],
bookingDate: '2024-09-21',
};

const normalizedTransaction = RevolutRevolt21.normalizeTransaction(
transaction,
true,
);

expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
'Bizum description',
);
});
});

it('returns the expected payeeName and remittanceInformationUnstructured from a bizum income transfer', () => {
const transaction = {
transactionAmount: { amount: '1.00', currency: 'EUR' },
remittanceInformationUnstructuredArray: [
'Bizum payment from: DEBTOR NAME',
'Bizum description',
],
bookingDate: '2024-09-21',
};

const normalizedTransaction = RevolutRevolt21.normalizeTransaction(
transaction,
true,
);

expect(normalizedTransaction.payeeName).toEqual('DEBTOR NAME');
expect(normalizedTransaction.remittanceInformationUnstructured).toEqual(
'Bizum description',
);
});
});
2 changes: 1 addition & 1 deletion src/app-gocardless/gocardless-node.types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -423,7 +423,7 @@ export type Transaction = {
/**
* Proprietary bank transaction code as used within a community or within an financial institution
*/
proprietaryBank?: string;
proprietaryBankTransactionCode?: string;

/**
* Conditional
Expand Down
6 changes: 6 additions & 0 deletions upcoming-release-notes/459.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
category: Enhancements
authors: [hostyn]
---

Add support for Bizum transactions in Revolut

0 comments on commit 0757f9d

Please sign in to comment.