Skip to content

Commit

Permalink
chore: modify tokenization list payments
Browse files Browse the repository at this point in the history
  • Loading branch information
matheusgnreis authored Apr 1, 2024
1 parent 6dd7b33 commit 850ed68
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 45 deletions.
24 changes: 24 additions & 0 deletions functions/assets/appmax-hash.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
;(function () {
window._appmaxHash = function (cardClient) {
return new Promise(function (resolve, reject) {
window.axios({
method: 'post',
url: 'https://admin.appmax.com.br/api/v3/security/visitor',
data: {
public_key: window._appmaxKey,
card: {
number: cardClient.number,
name: cardClient.name,
month: cardClient.month,
year: cardClient.year,
cvv: cardClient.cvc
}
}
})
.then(function (response) {
resolve(response.data.data.data)
})
.catch(reject)
})
}
}())
42 changes: 0 additions & 42 deletions functions/assets/onload-expression.js

This file was deleted.

1 change: 1 addition & 0 deletions functions/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@ recursiveReadDir(routesDir).filter(filepath => filepath.endsWith('.js')).forEach
})

server.use(router)
server.use(express.static('assets'))

exports[functionName] = functions.https.onRequest(server)
console.log(`-- Starting '${app.title}' E-Com Plus app with Function '${functionName}'`)
Expand Down
5 changes: 2 additions & 3 deletions functions/routes/ecom/modules/list-payments.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,8 @@ exports.post = ({ appSdk }, req, res) => {
gateway.icon = `${baseUri}/credit-card.png`
}
gateway.js_client = {
script_uri: 'https://assets.pagar.me/pagarme-js/4.8/pagarme.min.js',
onload_expression: `window._appmaxKey="${config.public_key}";` +
fs.readFileSync(path.join(__dirname, '../../../assets/dist/onload-expression.min.js'), 'utf8'),
script_uri: `${baseUri}/dist/appmax-hash.min.js`,
onload_expression: `window._appmaxKey="${config.public_key}";`,
cc_hash: {
function: '_appmaxHash',
is_promise: true
Expand Down

0 comments on commit 850ed68

Please sign in to comment.