Skip to content

Commit

Permalink
fix(list-payments-webhooks): remove debugs unnecessary
Browse files Browse the repository at this point in the history
  • Loading branch information
wisley7l committed Aug 2, 2024
1 parent b34bc7b commit a0bea46
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 29 deletions.
1 change: 0 additions & 1 deletion functions/lib/galaxpay/create-axios.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ module.exports = (accessToken, isSandbox) => {
'Content-Type': 'application/json'
}
if (accessToken) {
console.log('> token ', accessToken)
headers.Authorization = `Bearer ${accessToken}`
}

Expand Down
27 changes: 1 addition & 26 deletions functions/routes/ecom/modules/list-payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,37 +20,14 @@ 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: []
}
// 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) {
Expand Down Expand Up @@ -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'))
Expand Down
6 changes: 4 additions & 2 deletions functions/routes/ecom/webhook.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand All @@ -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) => {
Expand Down Expand Up @@ -492,6 +492,8 @@ exports.post = async ({ appSdk, admin }, req, res) => {
message
})
}
} else {
return res.send(ECHO_SKIP)
}
})
})
Expand Down

0 comments on commit a0bea46

Please sign in to comment.