From a0bea46c98871f71c60d02860c4644ea4196b17a Mon Sep 17 00:00:00 2001 From: Wisley Alves Date: Fri, 2 Aug 2024 18:22:05 -0300 Subject: [PATCH] fix(list-payments-webhooks): remove debugs unnecessary --- functions/lib/galaxpay/create-axios.js | 1 - .../routes/ecom/modules/list-payments.js | 27 +------------------ functions/routes/ecom/webhook.js | 6 +++-- 3 files changed, 5 insertions(+), 29 deletions(-) diff --git a/functions/lib/galaxpay/create-axios.js b/functions/lib/galaxpay/create-axios.js index 25f81d5..41ae94c 100644 --- a/functions/lib/galaxpay/create-axios.js +++ b/functions/lib/galaxpay/create-axios.js @@ -7,7 +7,6 @@ module.exports = (accessToken, isSandbox) => { 'Content-Type': 'application/json' } if (accessToken) { - console.log('> token ', accessToken) headers.Authorization = `Bearer ${accessToken}` } diff --git a/functions/routes/ecom/modules/list-payments.js b/functions/routes/ecom/modules/list-payments.js index 8ab03ed..b177443 100644 --- a/functions/routes/ecom/modules/list-payments.js +++ b/functions/routes/ecom/modules/list-payments.js @@ -20,7 +20,7 @@ exports.post = ({ appSdk }, req, res) => { */ const { params, application } = req.body - const { storeId } = req + // const { storeId } = req // setup basic required response object const response = { payment_gateways: [] @@ -28,29 +28,6 @@ exports.post = ({ appSdk }, req, res) => { // merge all app options configured by merchant const appData = Object.assign({}, application.data, application.hidden_data) - /* DO THE STUFF HERE TO FILL RESPONSE OBJECT WITH PAYMENT GATEWAYS */ - - /** - * Sample snippets: - - // add new payment method option - response.payment_gateways.push({ - intermediator: { - code: 'paupay', - link: 'https://www.palpay.com.br', - name: 'paupay' - }, - payment_url: 'https://www.palpay.com.br/', - type: 'payment', - payment_method: { - code: 'banking_billet', - name: 'Boleto Bancário' - }, - label: 'Boleto Bancário', - expiration_date: appData.expiration_date || 14 - }) - - */ let amount = { ...params.amount } || {} if (!appData.galaxpay_id || !appData.galaxpay_hash) { @@ -81,8 +58,6 @@ exports.post = ({ appSdk }, req, res) => { const methodConfig = appData[paymentMethod] || {} const methodMinAmount = methodConfig.min_amount || 0 if (!methodConfig.disable && (methodMinAmount <= amount.total)) { - console.log('s: ', storeId, ' > Plan ', plan.periodicity) - const isCreditCard = paymentMethod === 'credit_card' const isPix = paymentMethod === 'pix' let label = methodConfig.label || (isCreditCard ? 'Cartão de crédito' : (isPix ? 'PIX' : 'Boleto bancário')) diff --git a/functions/routes/ecom/webhook.js b/functions/routes/ecom/webhook.js index 4f43042..416d8d6 100644 --- a/functions/routes/ecom/webhook.js +++ b/functions/routes/ecom/webhook.js @@ -239,8 +239,6 @@ exports.post = async ({ appSdk, admin }, req, res) => { }) }) } else if (trigger.resource === 'products' && trigger.action === 'change') { - console.log('> Edit product ', resourceId, 's: ', storeId) - let query = 'status!=cancelled&transactions.type=recurrence' query += '&transactions.app.intermediator.code=galaxpay_app' @@ -250,6 +248,8 @@ exports.post = async ({ appSdk, admin }, req, res) => { const { result } = await getOrderWithQueryString(appSdk, storeId, query, auth) if (result && result.length) { + console.log('> Edit product ', resourceId, 's: ', storeId) + const galaxPaySubscriptions = await getSubscriptionsByListMyIds( galaxpayAxios, result.reduce((orderIds, order) => { @@ -492,6 +492,8 @@ exports.post = async ({ appSdk, admin }, req, res) => { message }) } + } else { + return res.send(ECHO_SKIP) } }) })