Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Bizum transactions in Revolut #459

Merged
merged 7 commits into from
Sep 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,15 +16,16 @@ 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 VirginNrnbgb22 from './banks/virgin_nrnbgb22.js';
import NbgEthngraaxxx from './banks/nbg_ethngraaxxx.js';

export const banks = [
AbancaCaglesmm,
Expand All @@ -44,63 +45,64 @@ export const banks = [
KBCkredbebb,
MbankRetailBrexplpw,
NationwideNaiaGB21,
NbgEthngraaxxx,
NorwegianXxNorwnok1,
RevolutRevolt21,
hostyn marked this conversation as resolved.
Show resolved Hide resolved
SandboxfinanceSfin0000,
SEBKortBankAB,
SEBPrivat,
SandboxfinanceSfin0000,
SparNordSpNoDK22,
SpkKarlsruhekarsde66,
SpkMarburgBiedenkopfHeladef1mar,
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