Compare commits
No commits in common. "c98b8da9ba2332959b583986090e5b00c84f10c0" and "11aeb44bac9b290ebfdf1f9d5cca098264cbe9a0" have entirely different histories.
c98b8da9ba
...
11aeb44bac
|
@ -3,7 +3,7 @@ import { DatabaseListen } from '../../constants';
|
||||||
import { EventBus } from '@nestjs/cqrs';
|
import { EventBus } from '@nestjs/cqrs';
|
||||||
import { ChangeDocEvent } from '../../domain/events/change-doc.event';
|
import { ChangeDocEvent } from '../../domain/events/change-doc.event';
|
||||||
import { ConfigService } from '@nestjs/config';
|
import { ConfigService } from '@nestjs/config';
|
||||||
import { apm } from 'src/core/apm';
|
|
||||||
import * as Nano from 'nano';
|
import * as Nano from 'nano';
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
@ -49,10 +49,7 @@ export class CouchService {
|
||||||
const nano = this.nanoInstance;
|
const nano = this.nanoInstance;
|
||||||
const db = nano.use(database);
|
const db = nano.use(database);
|
||||||
return await db.insert(data);
|
return await db.insert(data);
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
console.log(error);
|
|
||||||
apm.captureError(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async deleteDoc(data, database) {
|
public async deleteDoc(data, database) {
|
||||||
|
@ -61,10 +58,7 @@ export class CouchService {
|
||||||
const db = nano.use(database);
|
const db = nano.use(database);
|
||||||
const result = await db.get(data.id);
|
const result = await db.get(data.id);
|
||||||
await db.destroy(data.id, result._rev);
|
await db.destroy(data.id, result._rev);
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
console.log(error);
|
|
||||||
apm.captureError(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async updateDoc(data, database) {
|
public async updateDoc(data, database) {
|
||||||
|
@ -76,10 +70,7 @@ export class CouchService {
|
||||||
...data,
|
...data,
|
||||||
_rev: result._rev,
|
_rev: result._rev,
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {}
|
||||||
console.log(error);
|
|
||||||
apm.captureError(error);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public async getDoc(id: string, database: string) {
|
public async getDoc(id: string, database: string) {
|
||||||
|
@ -89,8 +80,6 @@ export class CouchService {
|
||||||
const result = await db.get(id);
|
const result = await db.get(id);
|
||||||
return result;
|
return result;
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.log(error);
|
|
||||||
apm.captureError(error);
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,7 +11,6 @@ import { TransactionChangeStatusEvent } from '../../entities/event/transaction-c
|
||||||
import * as _ from 'lodash';
|
import * as _ from 'lodash';
|
||||||
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
import { TABLE_NAME } from 'src/core/strings/constants/table.constants';
|
||||||
import { generateInvoiceCodeHelper } from '../managers/helpers/generate-invoice-code.helper';
|
import { generateInvoiceCodeHelper } from '../managers/helpers/generate-invoice-code.helper';
|
||||||
import { apm } from 'src/core/apm';
|
|
||||||
|
|
||||||
@EventsHandler(MidtransCallbackEvent)
|
@EventsHandler(MidtransCallbackEvent)
|
||||||
export class MidtransCallbackHandler
|
export class MidtransCallbackHandler
|
||||||
|
@ -23,11 +22,6 @@ export class MidtransCallbackHandler
|
||||||
) {}
|
) {}
|
||||||
|
|
||||||
async handle(event: MidtransCallbackEvent) {
|
async handle(event: MidtransCallbackEvent) {
|
||||||
const apmTransactions = apm.startTransaction(
|
|
||||||
`callback-midtrans`,
|
|
||||||
'handler',
|
|
||||||
);
|
|
||||||
|
|
||||||
const data_id = event.data.id;
|
const data_id = event.data.id;
|
||||||
const data = event.data.data;
|
const data = event.data.data;
|
||||||
let old_data = undefined;
|
let old_data = undefined;
|
||||||
|
@ -39,8 +33,6 @@ export class MidtransCallbackHandler
|
||||||
});
|
});
|
||||||
old_data = _.cloneDeep(transaction);
|
old_data = _.cloneDeep(transaction);
|
||||||
|
|
||||||
apmTransactions.setLabel('status', data.transaction_status);
|
|
||||||
|
|
||||||
if (['capture', 'settlement'].includes(data.transaction_status)) {
|
if (['capture', 'settlement'].includes(data.transaction_status)) {
|
||||||
Object.assign(transaction, {
|
Object.assign(transaction, {
|
||||||
status: STATUS.SETTLED,
|
status: STATUS.SETTLED,
|
||||||
|
@ -77,7 +69,5 @@ export class MidtransCallbackHandler
|
||||||
op: OPERATION.UPDATE,
|
op: OPERATION.UPDATE,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
apmTransactions.end();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue