Aplica para aplicaciones web
Incluir el script del Data Collector.
<script src="https://static.greenpay.me/collector/1.0.1/GDataCollector.min.js"></script>
Iniciar el Data Collector. El GDataCollector.init recibe en el primer parámetro, un string, que puede ser 'sand' o 'prod', para Sandbox o Producción respectivamente.
<script>
let sessionIdDiv = document.getElementById("kountSession"); function kountSession(params) { console.log(params.MercSessId); sessionIdDiv.innerHTML = `KOUNT SESSION ${params.MercSessId}`; } GDataCollector.init("sand", null, function (collector) { collector.setupCallback({ // fires when collection has finished "collect-end": kountSession, // fires when collection has started. "collect-begin": function () { console.log("collection has started"); }, }); collector.collectData(); }); </script>
Se debe obtener el valor en params.MercSessId. Este valor se utilizará en el objeto con los datos la tarjeta.
Ejemplo completo
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Datacollector API</title>
</head>
<body>
<div id="kountSession"></div>
<script src="https://static.greenpay.me/collector/1.0.1/GDataCollector.min.js"></script>
<script>
let sessionIdDiv = document.getElementById("kountSession");
function kountSession(params) {
console.log(params.MercSessId);
sessionIdDiv.innerHTML = `KOUNT SESSION ${params.MercSessId}`;
}
GDataCollector.init("sand", null, function (collector) {
collector.setupCallback({
// fires when collection has finished
"collect-end": kountSession,
// fires when collection has started.
"collect-begin": function () {
console.log("collection has started");
},
});
collector.collectData();
});
</script>
</body>