-
Notifications
You must be signed in to change notification settings - Fork 63
/
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 { Customer } from './customer';
export { Customer } from './customer';
import { PaymentRequest } from './payment_request';
export { PaymentRequest } from './payment_request';
import { Payout } from './payout';
export { Payout } from './payout';
import { Invoice } from './invoice';
export { Invoice } from './invoice';
import { Refund } from './refund';
export { Refund } from './refund';
import { Balance, Transaction } from './balance_and_transaction';
export { Balance, Transaction } from './balance_and_transaction';
import { PaymentMethod } from './payment_method';
export { PaymentMethod } from './payment_method';
export interface XenditOpts {
secretKey: string;
xenditURL?: string;
}
export class Xendit {
opts: XenditOpts;
Customer: Customer;
PaymentRequest: PaymentRequest;
Payout: Payout;
Invoice: Invoice;
Refund: Refund;
Balance: Balance;
Transaction: Transaction;
PaymentMethod: PaymentMethod;
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.Customer = new Customer(this.opts);
this.PaymentRequest = new PaymentRequest(this.opts);
this.Payout = new Payout(this.opts);
this.Invoice = new Invoice(this.opts);
this.Refund = new Refund(this.opts);
this.Balance = new Balance(this.opts);
this.Transaction = new Transaction(this.opts);
this.PaymentMethod = new PaymentMethod(this.opts);
}
}
export default Xendit;