-
-
Notifications
You must be signed in to change notification settings - Fork 260
/
privacy-add-credit-card.js
executable file
·37 lines (28 loc) · 1.14 KB
/
privacy-add-credit-card.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env ./node_modules/.bin/babel-node
/* eslint-disable camelcase */
import '../server/env';
import { toNumber } from 'lodash';
import models, { sequelize } from '../server/models';
import privacy from '../server/paymentProviders/privacy';
const run = async (CollectiveId, cardNumber, expireDate, cvv) => {
const collective = await models.Collective.findByPk(toNumber(CollectiveId));
const host = await collective.getHostCollective();
await privacy.assignCardToCollective({ cardNumber, expireDate, cvv }, collective, host, { upsert: true });
console.log('Done!');
await sequelize.close();
process.exit(0);
};
if (!module.parent) {
if (process.argv.length < 4 || process.argv[2] === 'help') {
console.log(
'\nUsage:\n npm run script ./scripts/encrypt.js collectiveId "xxxx xxxx xxxx xxxx" "mm/yyyy" "cvv"\n',
);
process.exit(0);
}
const [, , CollectiveId, cardNumber, expireDate, cvv] = process.argv;
if (!CollectiveId || !cardNumber || !expireDate || !cvv) {
console.error('VirtualCard missing cardNumber, expireDate and/or cvv');
process.exit(1);
}
run(CollectiveId, cardNumber, expireDate, cvv);
}