forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.ts
79 lines (56 loc) · 2.05 KB
/
index.ts
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
/* tslint:disable */
/* eslint-disable */
export * from './runtime';
import { Invoice } from './invoice';
export { Invoice } from './invoice';
import { Transaction, Balance } from './balance_and_transaction';
export { Transaction, Balance } from './balance_and_transaction';
import { Refund } from './refund';
export { Refund } from './refund';
import { Payout } from './payout';
export { Payout } from './payout';
import { PaymentRequest } from './payment_request';
export { PaymentRequest } from './payment_request';
import { PaymentMethod } from './payment_method';
export { PaymentMethod } from './payment_method';
import { Customer } from './customer';
export { Customer } from './customer';
export interface XenditOpts {
secretKey: string;
xenditURL?: string;
}
export class Xendit {
opts: XenditOpts;
Invoice: Invoice;
Transaction: Transaction;
Balance: Balance;
Refund: Refund;
Payout: Payout;
PaymentRequest: PaymentRequest;
PaymentMethod: PaymentMethod;
Customer: Customer;
constructor({ secretKey: _secretKey, xenditURL: _xenditURL }: XenditOpts) {
const secretKey = _secretKey || ''
const xenditURL = _xenditURL || 'https://api.xendit.co';
if (secretKey.startsWith('xnd_development_')) {
console.warn(`You are using Xendit's TEST secret key. Please use your LIVE secret key when you are ready to go live.`)
} else if (secretKey.startsWith('xnd_production_')) {
// do nothing
} else {
console.error(`Invalid secret key provided. Please use your Xendit secret key that starts with 'xnd_'`)
}
this.opts = {
secretKey,
xenditURL
}
this.Invoice = new Invoice(this.opts);
this.Transaction = new Transaction(this.opts);
this.Balance = new Balance(this.opts);
this.Refund = new Refund(this.opts);
this.Payout = new Payout(this.opts);
this.PaymentRequest = new PaymentRequest(this.opts);
this.PaymentMethod = new PaymentMethod(this.opts);
this.Customer = new Customer(this.opts);
}
}
export default Xendit;