try mollie

This commit is contained in:
Kiara Grouwstra 2021-09-29 23:24:01 +02:00
parent 69a283be52
commit 644df861f0
10 changed files with 3141 additions and 8437 deletions

View File

@ -1,13 +1,17 @@
BIJ1 Compliance Facilitator App
===============================
`npm install` installs the dependencies
`yarn install` installs the dependencies
If you also want to develop you'll want to run:
`npm install --also=dev`
set the [AirTable API key](https://airtable.com/account):
`export AIRTABLE_API_KEY=MY_API_KEY`
set the API keys for [AirTable](https://airtable.com/account) and [Mollie](https://www.mollie.com/dashboard/org_3678554/developers/api-keys):
```bash
export NODE_OPTIONS=--experimental-vm-modules npx jest
export AIRTABLE_API_KEY=<MY_KEY>
export MOLLIE_API_KEY_LEDEN=<MY_KEY>
export MOLLIE_API_KEY_DOEMEE=<MY_KEY>
export MOLLIE_API_KEY_SHOP=<MY_KEY>
export MOLLIE_API_KEY_DONEER=<MY_KEY>
```
`npm start` launches the app

8409
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,6 +2,8 @@
"name": "bij1-compliance",
"version": "0.0.1",
"description": "BIJ1 Compliance Facilitator App",
"type": "module",
"transform": {},
"main": "src/app.js",
"scripts": {
"start": "node src/app.js",
@ -19,9 +21,12 @@
},
"homepage": "https://gitlab.com/bij1/bij1-compliance#readme",
"dependencies": {
"@mollie/api-client": "^3.5.1",
"airtable": "^0.11.1",
"chokidar-cli": "^3.0.0",
"mollie": "^2.0.2"
"mollie": "^2.0.2",
"rxjs": "^7.3.0",
"typescript": "^4.4.3"
},
"devDependencies": {
"chokidar": "^3.5.2",

9
src/airtable.js Normal file
View File

@ -0,0 +1,9 @@
"use strict";
import Airtable from 'airtable';
const base = 'appXWc6Btm4KkIg8G';
const table = 'leden';
const airtable = new Airtable({});
export const tbl = airtable
.base(base)
.table(table);

View File

@ -1,18 +1,3 @@
"use strict";
const Airtable = require('airtable');
const base = 'appXWc6Btm4KkIg8G';
const table = 'leden';
const airtable = new Airtable({});
airtable
.base(base)
.table(table)
.select()
.firstPage()
// .eachPage()
// .forEach()
.then(records => {
records.forEach(record => {
console.log(record.fields);
});
});
// import "./airtable.js";
// import "./mollie.js";

22
src/mollie.js Normal file
View File

@ -0,0 +1,22 @@
"use strict";
import mergeMap from "rxjs/operators";
import { of, from, concat } from "rxjs";
export const mollieKeys = {
leden: process.env.MOLLIE_API_KEY_LEDEN,
doemee: process.env.MOLLIE_API_KEY_DOEMEE,
shop: process.env.MOLLIE_API_KEY_SHOP,
doneer: process.env.MOLLIE_API_KEY_DONEER,
};
export function unrollResult(result) {
// log(result);
// const { count, nextPage, links } = result;
return concat(of(result), of(result.nextPage ? listAll(result.nextPage()) : []));
}
export function listAll(page$) {
return from(page$).pipe(
mergeMap(unrollResult)
);
}

15
tests/airtable.test.js Normal file
View File

@ -0,0 +1,15 @@
import { tbl } from '../src/airtable.js';
test('airtable can print records', () => {
tbl
.select()
.firstPage()
// .eachPage()
// .forEach()
.then(records => {
records.forEach(record => {
console.log(record.fields);
});
});
expect(true).toBe(true);
});

View File

@ -1,7 +1,3 @@
/**
* @jest-environment jsdom
*/
test('Hello tests', () => {
expect(true).toBe(true);
});

31
tests/mollie.test.js Normal file
View File

@ -0,0 +1,31 @@
import { createMollieClient } from '@mollie/api-client';
import { mollieKeys, listAll } from '../src/mollie.js';
const log = console.log.bind(console);
test('airtable can print records', () => {
const mollieClient = createMollieClient({ apiKey: mollieKeys.leden });
const entity = mollieClient.customers;
const obs = listAll(entity.list());
log('just before subscribe');
obs.subscribe({
next(x) { log('got value ' + x); },
error(err) { console.error('something wrong occurred: ' + err); },
complete() { log('done'); }
});
log('just after subscribe');
// mollyEntity
// .list()
// .then(result => {
// console.log(result);
// // const { count, nextPage, links } = result;
// // result.forEach(item => {
// // console.log(item);
// // })
// });
// same for payments, refunds, chargebacks
expect(true).toBe(true);
});

3046
yarn.lock Normal file

File diff suppressed because it is too large Load Diff