33 lines
844 B
JavaScript
33 lines
844 B
JavaScript
const midtransClient = require('midtrans-client');
|
|
require('dotenv').config();
|
|
|
|
class MidtransCoreService {
|
|
constructor() {
|
|
this.isProduction = process.env.MIDTRANS_IS_PRODUCTION === 'true';
|
|
this.serverKey = process.env.MIDTRANS_SERVER_KEY;
|
|
this.clientKey = process.env.MIDTRANS_CLIENT_KEY;
|
|
|
|
this.coreApi = new midtransClient.CoreApi({
|
|
isProduction: this.isProduction,
|
|
serverKey: this.serverKey,
|
|
clientKey: this.clientKey
|
|
});
|
|
|
|
this.snap = new midtransClient.Snap({
|
|
isProduction: this.isProduction,
|
|
serverKey: this.serverKey,
|
|
clientKey: this.clientKey
|
|
});
|
|
}
|
|
|
|
getCoreApi() {
|
|
return this.coreApi;
|
|
}
|
|
|
|
getSnap() {
|
|
return this.snap;
|
|
}
|
|
}
|
|
|
|
module.exports = new MidtransCoreService();
|