-
Notifications
You must be signed in to change notification settings - Fork 3
/
index.js
44 lines (41 loc) · 1013 Bytes
/
index.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
38
39
40
41
42
43
44
'use strict'
const creditCardPrompt = require('credit-card-prompt')
const ora = require('ora')
const donate = require('./lib/donate')
module.exports = (
apiUrl,
amount,
{ googleMapsKey, currency, description } = {}
) => {
return creditCardPrompt(googleMapsKey).then(res => {
const spinner = ora('Donating...')
const expDateParts = res.expDate.split(' / ')
const card = {
name: res.name,
number: res.cardNumber,
cvc: res.ccv,
address_country: res.country,
address_zip: res.zipCode,
address_state: res.state,
address_city: res.city,
exp_month: expDateParts[0],
exp_year: expDateParts[1],
object: 'card'
}
spinner.start()
return donate(
apiUrl,
card,
(amount = amount * 100),
({ currency = currency, description = description } = {})
)
.then(res => {
spinner.stop()
return res.data
})
.catch(err => {
spinner.stop()
return err
})
})
}