-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathsample.js
86 lines (78 loc) · 2.04 KB
/
sample.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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
let Flutterwave = require('./flutterwave')
require('dotenv').config()
// Initialize the flutterwave class
let flutterwave = new Flutterwave(
process.env.flutterwave_secret_key,
process.env.flutterwave_public_key,
process.env.flutterwave_encryption_key
)
// For making Transfers to bank
const payToBankFunction = async () => {
let data = {
account_bank: '044',
account_number: '0690000031',
amount: 1000,
currency: 'NGN',
beneficiary_name: 'Forest Green'
}
let response = await flutterwave.transferToBank(data)
console.log(response)
}
// For charging Cards
const chargeCardFunction = async () => {
let data = {
amount: 1000,
currency: 'NGN',
card_number: '5531886652142950',
cvv: '564',
expiry_month: '09',
expiry_year: '32',
email: 'hi@tay.com',
tx_ref: 'testMe',
pin: '3310'
}
let response = await flutterwave.chargeCard(data)
console.log(response)
}
// This is for validating Bank or Card charges
const validateChargeFunction = async () => {
let data = {
otp: '12345',
flw_ref: 'FLW-MOCK-049a789dc6a675e3d16c0d348245c1cc'
}
let response = await flutterwave.validateCharge(data)
console.log(response)
}
// Pay by transferring from your bank to a unique bank account
const payWithBankTransferFunction = async () => {
let data = {
amount: 1000,
email: 'hi@tay.com',
currency: 'NGN',
tx_ref: 'testMe'
}
let response = await flutterwave.payWithBankTransfer(data)
console.log(response)
}
// Charge bank account
const payWithBankWithdrawalFunction = async () => {
let data = {
account_bank: '044',
account_number: '0690000031',
amount: 1000,
email: 'hi@tay.com',
tx_ref: 'testMe',
currency: 'NGN'
}
let response = await flutterwave.payWithBankWithdrawal(data)
console.log(response)
}
// Verify account name of a bank account
const verifyAccountNumberFunction = async () => {
let data = {
accountNumber: '0690000031',
bankCode: '044'
}
let response = await flutterwave.verifyAccountNumber(data)
console.log(response)
}