From 8f731226eed47fbec3341c019c3be3129724c0a4 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 14 Sep 2023 15:02:36 +0700 Subject: [PATCH 01/21] - fix when base url stg cannot order on prod --- src/transaction/transaction.controller.ts | 27 ++++++++++++++++------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index 9213032..8fd660e 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -90,14 +90,25 @@ export class TransactionController { @Body() orderTransactionDto: OrderTransactionDto, @Request() req, ) { - return { - data: await this.transactionService.orderTransactionProd( - orderTransactionDto, - req.user, - ), - statusCode: HttpStatus.CREATED, - message: 'success', - }; + if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { + return { + data: await this.transactionService.orderTransaction( + orderTransactionDto, + req.user, + ), + statusCode: HttpStatus.CREATED, + message: 'success', + }; + } else { + return { + data: await this.transactionService.orderTransactionProd( + orderTransactionDto, + req.user, + ), + statusCode: HttpStatus.CREATED, + message: 'success', + }; + } } @Post('order-bill-prod') From 28f98de87c7d0d800de0e29c5082b697599eedb5 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 22:07:06 +0700 Subject: [PATCH 02/21] - integrating vocagame supplier --- src/helper/irs-api.ts | 59 +++++++++++++++++++ .../entities/product-sub-category.entity.ts | 5 ++ src/transaction/ppob_callback.controller.ts | 20 +++++++ src/transaction/transaction.service.ts | 59 ++++++++++++++++--- 4 files changed, 136 insertions(+), 7 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 4a9be30..e770682 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -1,5 +1,6 @@ import axios from 'axios'; import {HttpException, HttpStatus, NotFoundException} from "@nestjs/common"; +import {createHmac} from "crypto"; const irs_url = 'http://h2h.elangpixiu.com/api/h2h'; const irs_id = 'PT0005'; @@ -15,6 +16,8 @@ export const doTransaction = async ( authorization, typePaid, billTrxId, + productVocaSubCategoryId, + productPrice ) => { try { if (supplier.code == 'IRS') { @@ -29,6 +32,62 @@ export const doTransaction = async ( ); return res.data; + } else if (supplier.code == 'Vocagame') { + const merchantId = supplier.irs_user; + const reference = idtrx + const endpoint = `/transaction/${reference}`; + const secretKey = supplier.irs_pass; + const signature = createHmac('sha256', secretKey) + .update(merchantId + endpoint) + .digest('hex'); + + const options = { + headers: {'Content-Type': 'application/json'}, + }; + + const mergedDestination = destination; + const regex = /\(([^)]+)\)/; + const match = regex.exec(mergedDestination); + + let productDestination = "" + let productRegion = "" + if (match) { + productDestination = match[0] + const insideBrackets = match[1]; + productRegion = insideBrackets // This will print inside brackets + } else { + productDestination = destination + } + + const data = + { + productId: productVocaSubCategoryId, // Sub Kategori ID + productItemId: productCode, // Product Code + data: { // Get object from user input within endpoint /products/detail + userId: productDestination, + zoneId: productRegion // Optional + }, + price: productPrice, // Price equals from items + reference: reference, // Your reference I + callbackUrl: "https://ppob-backend.k3s.bangun-kreatif.com/v1/ppob_callback/vocagame" // Set your endpoint callback + } + + const res = await axios.post( + `${supplier.url}/v1/core/transaction?signature=${signature}`, + data, + options, + ); + + var responseVoca = res.data; + + if (responseVoca != null) { + const resDetail = await axios.get( + `${supplier.url}/v1/core/transaction/${responseVoca.invoiceId}/detail?signature=${signature}`, + options, + ); + + return resDetail + } } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; diff --git a/src/product/entities/product-sub-category.entity.ts b/src/product/entities/product-sub-category.entity.ts index c1035ad..e8cfaf3 100644 --- a/src/product/entities/product-sub-category.entity.ts +++ b/src/product/entities/product-sub-category.entity.ts @@ -16,6 +16,11 @@ export class ProductSubCategories extends BaseModel { }) code: string; + @Column({ + nullable: true, + }) + code_voca: string; + @ManyToOne(() => ProductCategories, (categories) => categories.sub_categories) category: ProductCategories; diff --git a/src/transaction/ppob_callback.controller.ts b/src/transaction/ppob_callback.controller.ts index 681d65a..f2294a0 100644 --- a/src/transaction/ppob_callback.controller.ts +++ b/src/transaction/ppob_callback.controller.ts @@ -174,4 +174,24 @@ export class PpobCallbackController { ); } } + + @Public() + @Post('/vocagame') + async getVoca(@Req() request: FastifyRequest) { + const response = request.body; + console.log('responsevocagame', response); + if (response['status'] != 'Success') { + //TODO: UPDATE GAGAL + await this.transactionService.checkCallbackOrderFailed( + response['reference'], + response, + ); + } else { + //TODO: UPDATE BERHASIL + await this.transactionService.checkCallbackOrderSuccess( + response['reference'], + response, + ); + } + } } diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 4be7440..1c7e1e5 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -637,7 +637,9 @@ export class TransactionService { supplier, hitLoginHemat.data, product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ) : await doTransaction( orderTransactionDto.productCode, orderTransactionDto.destination, @@ -645,7 +647,9 @@ export class TransactionService { supplier, "", product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ); // let hitSupplier; @@ -672,6 +676,16 @@ export class TransactionService { if (orderTransactionDto.bill_trx_id !== null) { hitSupplier.harga = product_price.price; } + } else if (supplier.code == 'Vocagame') { + const newHitSupplier = { + status: hitSupplier.data.status, + success: hitSupplier.data.status.includes('Success') || hitSupplier.data.status.includes('Processing'), + harga: hitSupplier.data.totalAmount, + msg: hitSupplier.message, + sn: hitSupplier.data.sn, + }; + + hitSupplier = newHitSupplier; } else if (supplier.code == 'Hemat') { const newHitSupplier = { success: hitSupplier.success, @@ -786,6 +800,20 @@ export class TransactionService { } else { transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory; + if (supplier.code == 'Vocagame') { + + if (hitSupplier.status == 'Processing') { + transactionData.status = statusTransaction.PENDING; + status = statusTransaction[transactionData.status]; + } else { + transactionData.seri_number = hitSupplier.sn; + transactionData.status = statusTransaction.SUCCESS; + status = statusTransaction[transactionData.status]; + } + + } else { + + if ( hitSupplier.sn == null || hitSupplier.sn == '' || @@ -798,6 +826,9 @@ export class TransactionService { transactionData.status = statusTransaction.SUCCESS; status = statusTransaction[transactionData.status]; } + + } + } await manager.insert(Transactions, transactionData); @@ -921,7 +952,9 @@ export class TransactionService { supplier, hitLoginHemat.data, product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ) : await doTransaction( orderTransactionDto.productCode, orderTransactionDto.destination, @@ -929,7 +962,9 @@ export class TransactionService { supplier, "", product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ); if (supplier.code != 'IRS') { @@ -1081,7 +1116,9 @@ export class TransactionService { supplier, hitLoginHemat.data, 'INQUIRY', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ) } else if (supplier.code == 'Digiflazz') { hitSupplier = await doTransaction( @@ -1091,7 +1128,9 @@ export class TransactionService { supplier, hitLoginHemat.data, 'INQUIRY', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ) } else { hitSupplier = await doTransaction( @@ -1101,7 +1140,9 @@ export class TransactionService { supplier, "", 'INQUIRY', - orderTransactionDto.bill_trx_id + orderTransactionDto.bill_trx_id, + product.sub_categories.code_voca, + product_price.price ); } // const parsingResponse = hitSupplier.split(' '); @@ -1590,6 +1631,10 @@ export class TransactionService { if (callback['sn']) { dataTransaction.seri_number = callback['sn']; } + } else if (supplier.code == 'Vocagame') { + if (callback['sn']) { + dataTransaction.seri_number = callback['sn']; + } } else { if (callback['sn']) { dataTransaction.seri_number = callback['sn']; From e030ca897f7ee8abc7839ce51704dfbf8395f765 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 22:23:34 +0700 Subject: [PATCH 03/21] - comment order-prod condition to test vocagames --- src/transaction/transaction.controller.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index 8fd660e..d7357d4 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -90,16 +90,16 @@ export class TransactionController { @Body() orderTransactionDto: OrderTransactionDto, @Request() req, ) { - if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { - return { - data: await this.transactionService.orderTransaction( - orderTransactionDto, - req.user, - ), - statusCode: HttpStatus.CREATED, - message: 'success', - }; - } else { + // if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { + // return { + // data: await this.transactionService.orderTransaction( + // orderTransactionDto, + // req.user, + // ), + // statusCode: HttpStatus.CREATED, + // message: 'success', + // }; + // } else { return { data: await this.transactionService.orderTransactionProd( orderTransactionDto, @@ -108,7 +108,7 @@ export class TransactionController { statusCode: HttpStatus.CREATED, message: 'success', }; - } + // } } @Post('order-bill-prod') From 2f470ad69f250763108fef1c956ba4c867d29643 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:01:07 +0700 Subject: [PATCH 04/21] - log code sub category --- src/transaction/transaction.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 1c7e1e5..ef36001 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -628,7 +628,7 @@ export class TransactionService { if (supplier.code == 'Hemat') { hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier); } - + console.log('inicodesubcategory', product.sub_categories.code) let hitSupplier = supplier.code == 'Hemat' ? await doTransaction( orderTransactionDto.productCode, From ed962c24c8e2b2514a79547eb3ee765a8164bdde Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:09:52 +0700 Subject: [PATCH 05/21] - fix code voca in subcategory column --- src/product/entities/product.entity.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/product/entities/product.entity.ts b/src/product/entities/product.entity.ts index 6959c49..9e6022c 100644 --- a/src/product/entities/product.entity.ts +++ b/src/product/entities/product.entity.ts @@ -44,7 +44,7 @@ export class Product extends BaseModel { return ProductSubCategories; }, (subCategories) => { - return subCategories.product; + return subCategories.id; }, ) sub_categories: ProductSubCategories; From 395a59b287333ef692c4b06196ed86bc0912bd72 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:15:21 +0700 Subject: [PATCH 06/21] - fix code voca in subcategory column --- src/transaction/transaction.service.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index ef36001..6c0b17a 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -628,7 +628,7 @@ export class TransactionService { if (supplier.code == 'Hemat') { hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier); } - console.log('inicodesubcategory', product.sub_categories.code) + console.log('inicodesubcategory', product.sub_categories.name) let hitSupplier = supplier.code == 'Hemat' ? await doTransaction( orderTransactionDto.productCode, From 04270e20f203e582a430821803841f8fd22eeae0 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:25:17 +0700 Subject: [PATCH 07/21] - fix code voca in subcategory column --- src/product/entities/product.entity.ts | 2 +- src/transaction/transaction.service.ts | 30 +++++++++++++++++++------- 2 files changed, 23 insertions(+), 9 deletions(-) diff --git a/src/product/entities/product.entity.ts b/src/product/entities/product.entity.ts index 9e6022c..6959c49 100644 --- a/src/product/entities/product.entity.ts +++ b/src/product/entities/product.entity.ts @@ -44,7 +44,7 @@ export class Product extends BaseModel { return ProductSubCategories; }, (subCategories) => { - return subCategories.id; + return subCategories.product; }, ) sub_categories: ProductSubCategories; diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 6c0b17a..21dd7a6 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -47,6 +47,7 @@ import { doAuthorizeHemat } from '../helper/sihemat-authorization'; import { ProductHistoryStatusService } from '../product/history-status/history-status.service'; import { Workbook } from 'exceljs'; import moment from "moment"; +import {ProductSubCategoriesService} from "../product/product-sub-categories.service"; @Injectable() export class TransactionService { @@ -67,6 +68,7 @@ export class TransactionService { private callbackPartnerRepository: Repository, private coaService: CoaService, private productService: ProductService, + private productSubcategoriesService: ProductSubCategoriesService, private productHistoryPriceService: ProductHistoryPriceService, private productHistoryStatusService: ProductHistoryStatusService, private userService: UsersService, @@ -531,6 +533,10 @@ export class TransactionService { orderTransactionDto.productId, ); + const productSubcategories = await this.productSubcategoriesService.findOne( + product.sub_categories_id + ); + const supplier = await this.supplierService.findByCode( product.supplier.code, ); @@ -628,7 +634,7 @@ export class TransactionService { if (supplier.code == 'Hemat') { hitLoginHemat = await doAuthorizeHemat(supplier.irs_user, supplier.irs_pass, supplier); } - console.log('inicodesubcategory', product.sub_categories.name) + console.log('inicodesubcategory', productSubcategories.code) let hitSupplier = supplier.code == 'Hemat' ? await doTransaction( orderTransactionDto.productCode, @@ -638,7 +644,7 @@ export class TransactionService { hitLoginHemat.data, product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ) : await doTransaction( orderTransactionDto.productCode, @@ -648,7 +654,7 @@ export class TransactionService { "", product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ); @@ -891,6 +897,10 @@ export class TransactionService { orderTransactionDto.productId ); + const productSubcategories = await this.productSubcategoriesService.findOne( + product.sub_categories_id + ); + const supplier = await this.supplierService.findByCode( product.supplier.code, ); @@ -953,7 +963,7 @@ export class TransactionService { hitLoginHemat.data, product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ) : await doTransaction( orderTransactionDto.productCode, @@ -963,7 +973,7 @@ export class TransactionService { "", product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ); @@ -1080,6 +1090,10 @@ export class TransactionService { orderTransactionDto.productId ); + const productSubcategories = await this.productSubcategoriesService.findOne( + product.sub_categories_id + ); + const supplier = await this.supplierService.findByCode( product.supplier.code, ); @@ -1117,7 +1131,7 @@ export class TransactionService { hitLoginHemat.data, 'INQUIRY', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ) } else if (supplier.code == 'Digiflazz') { @@ -1129,7 +1143,7 @@ export class TransactionService { hitLoginHemat.data, 'INQUIRY', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ) } else { @@ -1141,7 +1155,7 @@ export class TransactionService { "", 'INQUIRY', orderTransactionDto.bill_trx_id, - product.sub_categories.code_voca, + productSubcategories.code_voca, product_price.price ); } From 3b246e9ebc3966f62b02ce520185d43a315d001e Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:31:23 +0700 Subject: [PATCH 08/21] - fix code voca in subcategory column --- src/transaction/transaction.module.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/transaction/transaction.module.ts b/src/transaction/transaction.module.ts index be743cd..66f2179 100644 --- a/src/transaction/transaction.module.ts +++ b/src/transaction/transaction.module.ts @@ -15,6 +15,7 @@ import { CallbackPartner } from './entities/callback-partner.entity'; import { ProductHistoryPrice } from '../product/entities/product-history-price.entity'; import { ProductHistoryStatus } from '../product/entities/product-history-status.entity'; import { ExcelController } from './excel.controller'; +import {ProductSubCategories} from "../product/entities/product-sub-category.entity"; @Module({ imports: [ @@ -26,6 +27,7 @@ import { ExcelController } from './excel.controller'; CallbackPartner, ProductHistoryPrice, ProductHistoryStatus, + ProductSubCategories ]), ProductModule, ConfigurableModule, From f707e0836effccac260ddf4b843d0a69f01bf01c Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:41:17 +0700 Subject: [PATCH 09/21] - fix code voca in subcategory column --- src/product/product.module.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/product/product.module.ts b/src/product/product.module.ts index 9a7e88d..1f332a8 100644 --- a/src/product/product.module.ts +++ b/src/product/product.module.ts @@ -32,6 +32,6 @@ import {ProductHistoryStatusService} from "./history-status/history-status.servi ProductHistoryPriceService, ProductHistoryStatusService, ], - exports: [ProductService, ProductHistoryPriceService, ProductHistoryStatusService], + exports: [ProductService, ProductHistoryPriceService, ProductHistoryStatusService, ProductSubCategoriesService], }) export class ProductModule {} From b3c514483c23f6609f7af995f3ae089c068fcda1 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:52:30 +0700 Subject: [PATCH 10/21] - fix code voca in subcategory column --- src/helper/irs-api.ts | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index e770682..1092505 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -33,7 +33,7 @@ export const doTransaction = async ( return res.data; } else if (supplier.code == 'Vocagame') { - const merchantId = supplier.irs_user; + const merchantId = supplier.irs_id; const reference = idtrx const endpoint = `/transaction/${reference}`; const secretKey = supplier.irs_pass; @@ -52,7 +52,8 @@ export const doTransaction = async ( let productDestination = "" let productRegion = "" if (match) { - productDestination = match[0] + var productSplit = destination.split('(') + productDestination = productSplit[0] const insideBrackets = match[1]; productRegion = insideBrackets // This will print inside brackets } else { From 56967904dd0e8e4a3f73be59023c5a8bd4377498 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Wed, 20 Sep 2023 23:54:58 +0700 Subject: [PATCH 11/21] - fix code voca in subcategory column --- src/helper/irs-api.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 1092505..a079e08 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -42,7 +42,8 @@ export const doTransaction = async ( .digest('hex'); const options = { - headers: {'Content-Type': 'application/json'}, + headers: {'Content-Type': 'application/json', + 'X-Merchant': `${merchantId}`}, }; const mergedDestination = destination; From 844d5f4571960d10762a18508ec2a21751066e3a Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:03:16 +0700 Subject: [PATCH 12/21] - fix code voca in subcategory column --- src/helper/irs-api.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index a079e08..2be4215 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -81,7 +81,7 @@ export const doTransaction = async ( ); var responseVoca = res.data; - + console.log('iniresponsevoca', responseVoca) if (responseVoca != null) { const resDetail = await axios.get( `${supplier.url}/v1/core/transaction/${responseVoca.invoiceId}/detail?signature=${signature}`, From 3aeef208af7dd215b4d2b8c2e4bf5b8f0cec4e14 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:10:01 +0700 Subject: [PATCH 13/21] - fix code voca in subcategory column --- src/helper/irs-api.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 2be4215..bd38b3b 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -80,7 +80,7 @@ export const doTransaction = async ( options, ); - var responseVoca = res.data; + var responseVoca = res.data.data; console.log('iniresponsevoca', responseVoca) if (responseVoca != null) { const resDetail = await axios.get( @@ -88,7 +88,7 @@ export const doTransaction = async ( options, ); - return resDetail + return resDetail.data } } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { From 6438c663975aedb83aeee95be5afec728258acff Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:23:10 +0700 Subject: [PATCH 14/21] - fix code voca in subcategory column --- src/helper/irs-api.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index bd38b3b..92d1e2f 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -83,13 +83,18 @@ export const doTransaction = async ( var responseVoca = res.data.data; console.log('iniresponsevoca', responseVoca) if (responseVoca != null) { + const endpointDetail = `/transaction/${responseVoca.invoiceId}/detail`; + const signatureDetail = createHmac('sha256', secretKey) + .update(merchantId + endpointDetail) + .digest('hex'); const resDetail = await axios.get( - `${supplier.url}/v1/core/transaction/${responseVoca.invoiceId}/detail?signature=${signature}`, + `${supplier.url}/v1/core/transaction/${responseVoca.invoiceId}/detail?signature=${signatureDetail}`, options, ); return resDetail.data } + } else if (supplier.code == 'Digiflazz') { if (typePaid == 'INQUIRY') { const md5HashDigiflazz = `${supplier.irs_user}${supplier.irs_pass}${idtrx}`; From 8324e1c50baa8ac72e7d015e0a3161d784570216 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:29:41 +0700 Subject: [PATCH 15/21] - fix code voca in subcategory column --- src/transaction/transaction.service.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 21dd7a6..50c5df3 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -685,7 +685,7 @@ export class TransactionService { } else if (supplier.code == 'Vocagame') { const newHitSupplier = { status: hitSupplier.data.status, - success: hitSupplier.data.status.includes('Success') || hitSupplier.data.status.includes('Processing'), + success: hitSupplier.data.status.includes('Success') || hitSupplier.data.status.includes('Processing') || hitSupplier.data.status.includes('Pending'), harga: hitSupplier.data.totalAmount, msg: hitSupplier.message, sn: hitSupplier.data.sn, @@ -808,7 +808,7 @@ export class TransactionService { coaAccount.amount - product_price.mark_up_price - costInventory; if (supplier.code == 'Vocagame') { - if (hitSupplier.status == 'Processing') { + if (hitSupplier.status == 'Processing' || hitSupplier.status == 'Pending') { transactionData.status = statusTransaction.PENDING; status = statusTransaction[transactionData.status]; } else { From 26cb992c96c268daaa4d39ce6dea4cf27b6beef4 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:39:18 +0700 Subject: [PATCH 16/21] - fix code voca in subcategory column --- src/transaction/ppob_callback.controller.ts | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/transaction/ppob_callback.controller.ts b/src/transaction/ppob_callback.controller.ts index f2294a0..5e618fc 100644 --- a/src/transaction/ppob_callback.controller.ts +++ b/src/transaction/ppob_callback.controller.ts @@ -182,16 +182,20 @@ export class PpobCallbackController { console.log('responsevocagame', response); if (response['status'] != 'Success') { //TODO: UPDATE GAGAL - await this.transactionService.checkCallbackOrderFailed( - response['reference'], - response, - ); + if (response['status'] != 'Processing') { + await this.transactionService.checkCallbackOrderFailed( + response['reference'], + response, + ); + } } else { //TODO: UPDATE BERHASIL - await this.transactionService.checkCallbackOrderSuccess( - response['reference'], - response, - ); + if (response['status'] != 'Processing') { + await this.transactionService.checkCallbackOrderSuccess( + response['reference'], + response, + ); + } } } } From b4a1259de6098e11613396385b2a59183bb5c0b8 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:47:00 +0700 Subject: [PATCH 17/21] -logs callback voca --- src/transaction/ppob_callback.controller.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/transaction/ppob_callback.controller.ts b/src/transaction/ppob_callback.controller.ts index 5e618fc..e474fc5 100644 --- a/src/transaction/ppob_callback.controller.ts +++ b/src/transaction/ppob_callback.controller.ts @@ -182,7 +182,9 @@ export class PpobCallbackController { console.log('responsevocagame', response); if (response['status'] != 'Success') { //TODO: UPDATE GAGAL + console.log('responsevocagame1', response['status']) if (response['status'] != 'Processing') { + console.log('responsevocagame2', response['status']) await this.transactionService.checkCallbackOrderFailed( response['reference'], response, @@ -190,7 +192,9 @@ export class PpobCallbackController { } } else { //TODO: UPDATE BERHASIL + console.log('responsevocagame3', response['status']) if (response['status'] != 'Processing') { + console.log('responsevocagame4', response['status']) await this.transactionService.checkCallbackOrderSuccess( response['reference'], response, From 5defbff68749b8f4e64e85224395ef1cdb3230f3 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 00:55:06 +0700 Subject: [PATCH 18/21] -logs callback voca --- src/transaction/transaction.service.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 50c5df3..eeb01e2 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -790,8 +790,9 @@ export class TransactionService { transactionData.partner_trx_id = orderTransactionDto.trx_id; transactionData.supplier_trx_id = trxId; transactionData.check_bill = orderTransactionDto.bill_trx_id; - + console.log('statushitsupplier', hitSupplier.success) if (!hitSupplier.success) { + console.log('masukstatusgagal', 'masuk') transactionData.balance_remaining = coaAccount.amount; transactionData.status = statusTransaction.FAILED; status = statusTransaction[transactionData.status]; @@ -804,6 +805,7 @@ export class TransactionService { HttpStatus.INTERNAL_SERVER_ERROR, ); } else { + console.log('masukstatuspending', 'masuk') transactionData.balance_remaining = coaAccount.amount - product_price.mark_up_price - costInventory; if (supplier.code == 'Vocagame') { From 3f78367ce4a2ad3dafb34e8f34b4fd371e82d715 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 21 Sep 2023 01:02:57 +0700 Subject: [PATCH 19/21] -uncomment order prod condition --- src/transaction/transaction.controller.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index d7357d4..8fd660e 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -90,16 +90,16 @@ export class TransactionController { @Body() orderTransactionDto: OrderTransactionDto, @Request() req, ) { - // if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { - // return { - // data: await this.transactionService.orderTransaction( - // orderTransactionDto, - // req.user, - // ), - // statusCode: HttpStatus.CREATED, - // message: 'success', - // }; - // } else { + if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { + return { + data: await this.transactionService.orderTransaction( + orderTransactionDto, + req.user, + ), + statusCode: HttpStatus.CREATED, + message: 'success', + }; + } else { return { data: await this.transactionService.orderTransactionProd( orderTransactionDto, @@ -108,7 +108,7 @@ export class TransactionController { statusCode: HttpStatus.CREATED, message: 'success', }; - // } + } } @Post('order-bill-prod') From 034a666729dd8f18eda03bfa86ba0df6ea5e499d Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Mon, 2 Oct 2023 11:38:03 +0700 Subject: [PATCH 20/21] -comment order prod condition --- src/transaction/transaction.controller.ts | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index 8fd660e..d7357d4 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -90,16 +90,16 @@ export class TransactionController { @Body() orderTransactionDto: OrderTransactionDto, @Request() req, ) { - if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { - return { - data: await this.transactionService.orderTransaction( - orderTransactionDto, - req.user, - ), - statusCode: HttpStatus.CREATED, - message: 'success', - }; - } else { + // if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { + // return { + // data: await this.transactionService.orderTransaction( + // orderTransactionDto, + // req.user, + // ), + // statusCode: HttpStatus.CREATED, + // message: 'success', + // }; + // } else { return { data: await this.transactionService.orderTransactionProd( orderTransactionDto, @@ -108,7 +108,7 @@ export class TransactionController { statusCode: HttpStatus.CREATED, message: 'success', }; - } + // } } @Post('order-bill-prod') From d9c8917fd6884259ded9a27738705f550030fec3 Mon Sep 17 00:00:00 2001 From: Muhammad Fadli Date: Thu, 5 Oct 2023 23:49:08 +0700 Subject: [PATCH 21/21] feat : - implement vocagame supplier in prod --- src/helper/irs-api.ts | 2 +- src/transaction/transaction.controller.ts | 22 +++++++++++----------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/helper/irs-api.ts b/src/helper/irs-api.ts index 92d1e2f..97fd487 100644 --- a/src/helper/irs-api.ts +++ b/src/helper/irs-api.ts @@ -71,7 +71,7 @@ export const doTransaction = async ( }, price: productPrice, // Price equals from items reference: reference, // Your reference I - callbackUrl: "https://ppob-backend.k3s.bangun-kreatif.com/v1/ppob_callback/vocagame" // Set your endpoint callback + callbackUrl: "https://api.wndsolutions.id/v1/ppob_callback/vocagame" // Set your endpoint callback } const res = await axios.post( diff --git a/src/transaction/transaction.controller.ts b/src/transaction/transaction.controller.ts index d7357d4..8fd660e 100644 --- a/src/transaction/transaction.controller.ts +++ b/src/transaction/transaction.controller.ts @@ -90,16 +90,16 @@ export class TransactionController { @Body() orderTransactionDto: OrderTransactionDto, @Request() req, ) { - // if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { - // return { - // data: await this.transactionService.orderTransaction( - // orderTransactionDto, - // req.user, - // ), - // statusCode: HttpStatus.CREATED, - // message: 'success', - // }; - // } else { + if (req.get('host').includes('ppob-backend.k3s.bangun-kreatif.com')) { + return { + data: await this.transactionService.orderTransaction( + orderTransactionDto, + req.user, + ), + statusCode: HttpStatus.CREATED, + message: 'success', + }; + } else { return { data: await this.transactionService.orderTransactionProd( orderTransactionDto, @@ -108,7 +108,7 @@ export class TransactionController { statusCode: HttpStatus.CREATED, message: 'success', }; - // } + } } @Post('order-bill-prod')